Skip to content

Commit

Permalink
ci: update github action
Browse files Browse the repository at this point in the history
Signed-off-by: black-desk <[email protected]>
  • Loading branch information
black-desk committed Mar 24, 2024
1 parent 2f7c466 commit 7cf8dc7
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 11,384 deletions.
50 changes: 28 additions & 22 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,51 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
type: [Debug, Release]
dependency: [Vendor, Online]
container:
- debian:oldstable-slim
- debian:stable-slim
- debian:sid-slim
cxx: [g++, clang++]
container:
image: ${{ matrix.container }}
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0
# - uses: hendrikmuhs/[email protected]
# with:
# key: ${{ matrix.cxx }}-${{ matrix.type }}
- name: Cache CPM.cmake Source
uses: actions/cache@v4
with:
path: .cache/cpm/source
key: ${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
key: ${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
- name: Setup cmake
uses: jwlawson/[email protected]
- name: Install system dependencies
run: |
sudo apt update &&
sudo apt install libsystemd-dev
- name: Build project with cmake
apt update &&
apt install pkg-config make git g++ clang -y
- name: Build project with cmake by preset debug
run: |
mkdir -p .cache/cpm/source &&
export CXX="${{ matrix.cxx }}" &&
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" &&
export CPM_DOWNLOAD_ALL="ON" &&
export CPM_SOURCE_CACHE="$PWD/.cache/cpm/source" &&
export CFLAGS="$CFLAGS -Wall" &&
export CFLAGS="$CFLAGS -Wextra" &&
export CFLAGS="$CFLAGS -Wpedantic" &&
export CFLAGS="$CFLAGS -Wno-extra-semi -Wno-unused-command-line-argument -Wno-gnu-zero-variadic-macro-arguments" &&
export CFLAGS="$CFLAGS -fsanitize=address,undefined" &&
export CXXFLAGS="$CFLAGS" &&
cmake --preset ${{ matrix.dependency }}${{ matrix.type }} &&
cmake --build --preset ${{ matrix.dependency }}${{ matrix.type }} -j
- name: Run tests
if: ${{ false }} # This project has no tests for now.
cmake --workflow --preset debug
- name: Install extra dependencies
run: |
cmake --build build -t test -j
apt update &&
apt install libexpected-dev libspdlog-dev nlohmann-json3-dev -y
- name: Build project with cmake by preset ci
run: |
mkdir -p .cache/cpm/source &&
export CXX="${{ matrix.cxx }}" &&
export CPM_SOURCE_CACHE="$PWD/.cache/cpm/source" &&
cmake --workflow --preset ci
- name: Build project with cmake by preset ci-with-spdlog
run: |
mkdir -p .cache/cpm/source &&
export CXX="${{ matrix.cxx }}" &&
export CPM_SOURCE_CACHE="$PWD/.cache/cpm/source" &&
cmake --workflow --preset ci
pass:
name: Pass
needs: [checks, build-and-test]
Expand Down
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ if(OCPPI_WITH_SPDLOG)
GIT_TAG "v1.3.1"
GIT_SHALLOW ON
EXCLUDE_FROM_ALL ON
OPTIONS "CMAKE_POSITION_INDEPENDENT_CODE ON" # NOTE:
# https://github.com/gabime/spdlog/issues/1190
OPTIONS
"CMAKE_POSITION_INDEPENDENT_CODE ON" # NOTE:
# https://github.com/gabime/spdlog/issues/1190
)
list(APPEND OCPPI_LINK_LIBRARIES PRIVATE spdlog::spdlog)
endif()
Expand Down
6 changes: 4 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"description": "Configure ocppi for development and debugging.",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CPM_DOWNLOAD_ALL": true,
"CPM_DOWNLOAD_ALL": "ON",
"OCPPI_WITH_SPDLOG": true,
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Og -g -fsanitize=address,undefined",
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
Expand All @@ -25,8 +25,10 @@
"description": "Configure ocppi for CI.",
"binaryDir": "${sourceDir}/build-ci",
"cacheVariables": {
"CPM_LOCAL_PACKAGES_ONLY": true,
"CMAKE_BUILD_TYPE": "Release"
},
"environment": {
"CPM_LOCAL_PACKAGES_ONLY": "ON"
}
},
{
Expand Down
1 change: 0 additions & 1 deletion examples/parse-config/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <exception>
#include <iostream>
#include <map>
#include <string>
#include <string_view>

Expand Down
3 changes: 0 additions & 3 deletions examples/using-crun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ list(APPEND LINK_LIBRARIES PUBLIC ocppi::ocppi)

if(OCPPI_WITH_SPDLOG)
list(APPEND LINK_LIBRARIES PRIVATE spdlog::spdlog)
find_package(PkgConfig REQUIRED)
pkg_check_modules(systemd REQUIRED IMPORTED_TARGET libsystemd)
list(APPEND LINK_LIBRARIES PUBLIC PkgConfig::systemd)
endif()

pfl_add_executable(INTERNAL SOURCES src/main.cpp LINK_LIBRARIES
Expand Down
1 change: 0 additions & 1 deletion examples/using-crun/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <exception>
#include <filesystem>
#include <iostream>
#include <map>
#include <memory>
#include <string>
#include <string_view>
Expand Down
7 changes: 1 addition & 6 deletions examples/with-logger/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@ if(NOT OCPPI_WITH_SPDLOG)
return()
endif()

find_package(
PkgConfig REQUIRED)
pkg_check_modules(systemd REQUIRED IMPORTED_TARGET libsystemd)

pfl_add_executable(
INTERNAL
SOURCES
src/main.cpp
LINK_LIBRARIES
PUBLIC
ocppi::ocppi
spdlog::spdlog
PkgConfig::systemd)
spdlog::spdlog)
27 changes: 5 additions & 22 deletions examples/with-logger/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <bits/types/struct_FILE.h>

#include "nlohmann/json.hpp"
#include "nlohmann/json_fwd.hpp"
#include "ocppi/cli/CLI.hpp"
#include "ocppi/cli/crun/Crun.hpp"
#include "ocppi/runtime/Signal.hpp"
Expand All @@ -24,18 +23,14 @@
#include "ocppi/types/Generators.hpp" // IWYU pragma: keep
#include "spdlog/common.h"
#include "spdlog/logger.h"
#include "spdlog/sinks/ansicolor_sink.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/sinks/systemd_sink.h"
#include "spdlog/sinks/syslog_sink.h"
#include "spdlog/spdlog.h"
#include "tl/expected.hpp"

namespace spdlog
{
namespace sinks
namespace spdlog::sinks
{
class sink;
} // namespace sinks
} // namespace spdlog

void printException(const std::shared_ptr<spdlog::logger> &logger,
Expand All @@ -50,21 +45,9 @@ try {

auto main() -> int
{
std::shared_ptr<spdlog::logger> logger;
{
auto sinks = std::vector<std::shared_ptr<spdlog::sinks::sink>>(
{ std::make_shared<spdlog::sinks::systemd_sink_mt>(
"ocppi") });
if (isatty(stderr->_fileno) != 0) {
sinks.push_back(std::make_shared<
spdlog::sinks::stderr_color_sink_mt>());
}

logger = std::make_shared<spdlog::logger>(
"ocppi", sinks.begin(), sinks.end());

logger->set_level(spdlog::level::trace);
}
std::shared_ptr<spdlog::logger> logger =
spdlog::stderr_color_mt("ocppi");
logger->set_level(spdlog::level::trace);

try {
std::unique_ptr<ocppi::cli::CLI> cli;
Expand Down
17 changes: 12 additions & 5 deletions src/ocppi/cli/CommonCLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,20 @@
#ifdef OCPPI_WITH_SPDLOG
#include <memory>

#if __has_include("spdlog/fmt/ranges.h")
#include "spdlog/fmt/ranges.h" // IWYU pragma: keep
#else
#include "spdlog/fmt/bundled/ranges.h" // IWYU pragma: keep
#endif
#include "spdlog/sinks/null_sink.h"
#include "spdlog/spdlog.h"
#if !defined(SPDLOG_USE_STD_FORMAT)
#if !defined(SPDLOG_FMT_EXTERNAL)
#ifdef SPDLOG_HEADER_ONLY
#ifndef FMT_HEADER_ONLY
#define FMT_HEADER_ONLY
#endif
#endif
#include "spdlog/fmt/bundled/ranges.h"
#else
#include "fmt/ranges.h"
#endif
#endif

namespace spdlog
{
Expand Down
4 changes: 1 addition & 3 deletions tools/iwyu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ mv build-iwyu/{new-,}compile_commands.json

# shellcheck disable=SC2046
"$IWYU_TOOL" -p build-iwyu \
$(find . -path './libs*' \( -name '*.c' -o -name '*.cpp' \) -printf "%p ") \
-- \
-Xiwyu --mapping_file="$(pwd)/tools/iwyu/mapping.imp" |
$(find . -path './libs*' \( -name '*.c' -o -name '*.cpp' \) -printf "%p ") |
tee build/iwyu.out

IWYU_FIX_INCLUDES=${IWYU_FIX_INCLUDES:=$({
Expand Down
Loading

0 comments on commit 7cf8dc7

Please sign in to comment.