Skip to content

Commit

Permalink
ci: add github workflow checks
Browse files Browse the repository at this point in the history
  • Loading branch information
black-desk committed Sep 20, 2024
1 parent 71db641 commit c10672e
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 9 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- directory: /
package-ecosystem: gitsubmodule
schedule:
interval: daily
- directory: /
package-ecosystem: github-actions
schedule:
interval: daily
61 changes: 61 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Checks

on: [pull_request]

jobs:
checks:
name: Run black-desk/checks
permissions:
checks: write
contents: read
issues: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: black-desk/checks@master
build-and-test:
name: Build and tests
runs-on: "ubuntu-latest"
strategy:
matrix:
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
- name: Cache CPM.cmake Source
uses: actions/cache@v4
with:
path: .cache/cpm/source
key: ${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
- name: Setup cmake
uses: jwlawson/[email protected]
- name: Install system dependencies
run: |
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 CPM_SOURCE_CACHE="$PWD/.cache/cpm/source" &&
cmake --workflow --preset debug
pass:
name: Pass
if: always()
needs:
- checks
- build-and-test
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ macro(cpm_add_dependencies)
VERSION 1.0.0
GITHUB_REPOSITORY TartanLlama/expected
GIT_TAG v1.1.0
EXCLUDE_FROM_ALL ON)
EXCLUDE_FROM_ALL ON
OPTIONS "EXPECTED_BUILD_TESTS OFF")
if(NOT TARGET tl::expected)
add_library(tl::expected ALIAS tl-expected)
endif()
Expand Down
48 changes: 48 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
"configurePresets": [
{
"name": "debug",
"displayName": "Debug configuration",
"description": "Configure errors for development and debugging.",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CPM_DOWNLOAD_ALL": "ON",
"OCPPI_WITH_SPDLOG": true,
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Og -g -fsanitize=address,undefined",
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
"CMAKE_COLOR_DIAGNOSTICS": true
}
}
],
"buildPresets": [
{
"name": "debug",
"displayName": "Debug build",
"description": "Build errors for development and debugging.",
"configurePreset": "debug"
}
],
"workflowPresets": [
{
"name": "debug",
"displayName": "Workflow for developers",
"description": "Configure, build then test for developing and debuging ocppi.",
"steps": [
{
"type": "configure",
"name": "debug"
},
{
"type": "build",
"name": "debug"
}
]
}
]
}
2 changes: 2 additions & 0 deletions cmake/.cmake-format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
with section("format"):
disable = True
4 changes: 3 additions & 1 deletion examples/print-messages/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <filesystem>
#include <iostream>

#include "errors/error.hpp"
Expand Down Expand Up @@ -105,7 +106,8 @@ std::ostream &operator<<(std::ostream &os, const errors::error_ptr &err)
for (; current_err != nullptr;
current_err = current_err->cause().get()) {
os << std::endl
<< "[function " << current_err->location().function_name() << " at "
<< "[function " << current_err->location().function_name()
<< " at "
<< std::filesystem::path(current_err->location().file_name())
.filename()
.string()
Expand Down
11 changes: 11 additions & 0 deletions include/errors/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,13 @@ inline std::ostream &operator<<(std::ostream &os, const errors::error_ptr &err)

#if defined(ERRORS_ENABLE_NLOHMANN_JSON_SUPPORT)
#include "nlohmann/json.hpp"
#if defined(NLOHMANN_JSON_NAMESPACE_BEGIN) && \
defined(NLOHMANN_JSON_NAMESPACE_END)
NLOHMANN_JSON_NAMESPACE_BEGIN
#else
namespace nlohmann
{
#endif
template <>
struct adl_serializer< ::errors::error_ptr> {
static void to_json(::nlohmann::json &j, const ::errors::error_ptr &err)
Expand All @@ -198,5 +204,10 @@ struct adl_serializer< ::errors::error_ptr> {
}
}
};
#if defined(NLOHMANN_JSON_NAMESPACE_BEGIN) && \
defined(NLOHMANN_JSON_NAMESPACE_END)
NLOHMANN_JSON_NAMESPACE_END
#else
}
#endif
#endif
22 changes: 17 additions & 5 deletions include/errors/source_location.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ struct source_location {
constexpr source_location(const char *file, const char *function,
uint_least32_t line,
uint_least32_t column) noexcept
: file_name_(file),
function_name_(function),
line_number(line),
column_(column)
: file_name_(file)
, function_name_(function)
, line_number(line)
, column_(column)
{
}

Expand All @@ -117,8 +117,15 @@ struct source_location {

#if defined(ERRORS_ENABLE_NLOHMANN_JSON_SUPPORT)
#include "nlohmann/json.hpp"
#if defined(NLOHMANN_JSON_NAMESPACE_BEGIN) && \
defined(NLOHMANN_JSON_NAMESPACE_END)
NLOHMANN_JSON_NAMESPACE_BEGIN
template <> struct adl_serializer< ::errors::source_location> {
#else
namespace nlohmann
{
#endif
template <>
struct adl_serializer< ::errors::source_location> {
static void to_json(::nlohmann::json &j,
const ::errors::source_location &loc)
{
Expand All @@ -128,5 +135,10 @@ template <> struct adl_serializer< ::errors::source_location> {
j["column"] = loc.column();
}
};
#if defined(NLOHMANN_JSON_NAMESPACE_BEGIN) && \
defined(NLOHMANN_JSON_NAMESPACE_END)
NLOHMANN_JSON_NAMESPACE_END
#else
}
#endif
#endif
3 changes: 1 addition & 2 deletions tests/errors-unit-tests/src/common_error.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <nlohmann/json_fwd.hpp>

#include "catch2/catch_test_macros.hpp"
#include "errors/error.hpp"
#include "nlohmann/json.hpp"

namespace
{
Expand Down

0 comments on commit c10672e

Please sign in to comment.