From a69245f8ab1a85d93b3b43b6a5167cadf360171f Mon Sep 17 00:00:00 2001 From: Josef Angstenberger Date: Fri, 4 Nov 2022 14:19:36 +0100 Subject: [PATCH 1/4] CI: Small improvements on GitHub workflow Use `apt-get` instead of `apt`. Avoids a warning that `apt` is not suitable for automation. Use single installation call to avoid ignored exit code. Add separate steps for smoke test and test preparation. Remove permissions settings which were needed for the remove test report. Explicit setting of shell is not necessary anymore, the tests run fine on Ubuntu without it. Maybe the addition of the executable flags or fixing the `shellcheck` issues helped. These were done in previous commits. --- .github/workflows/ci.yml | 66 ++++++++++++++++++++-------------------- test/CMakeLists.txt | 10 ++++++ 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0f49659..63896df6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,12 +2,6 @@ name: CI on: [push, pull_request] -# Write permissions needed for Test report -# (may be fixed by https://github.com/dorny/test-reporter/pull/174) -permissions: - statuses: write - checks: write - jobs: build: name: Build and Test @@ -26,50 +20,56 @@ jobs: - clang-14 steps: - - uses: actions/checkout@v3 - - name: Install prerequisites - run: | - sudo apt install -y cmake ninja-build - sudo apt install -y doxygen graphviz + run: >- + sudo apt-get install -y + libgcrypt20-dev + ${{ matrix.compiler }} + cmake + ninja-build + doxygen + graphviz - - name: Install compiler (Linux) - if: ${{ startsWith(matrix.os,'ubuntu-') }} - run: | - sudo apt install -y ${{ matrix.compiler }} - - - name: Install libgcrypt - if: ${{ startsWith(matrix.os,'ubuntu-') }} - run: sudo apt install -y libgcrypt20-dev + - uses: actions/checkout@v3 - name: Configure run: | - export SHELL=$(which sh) export CXX=$(echo ${{ matrix.compiler }} | sed -E 's/^(g|clang)(cc)?/\1++/') cmake -G Ninja -S . -B build - name: Build + working-directory: build + run: ninja srecord-executables + + - name: Smoke test working-directory: build run: ninja srecord-executables-version + - name: Build test prerequisites + working-directory: build + run: ninja prepare-test + - name: Test working-directory: build - run: | - ninja test_arglex_ambiguous test_crc16 test_fletcher16 test_hyphen test_url_decode - ctest --output-junit ctest.junit.xml + run: ctest --output-on-failure --output-junit ctest.junit.xml docs: name: Documentation runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - name: Install prerequisites - run: | - sudo apt install -y cmake ninja-build - sudo apt install -y doxygen graphviz - sudo apt install -y groff psutils ghostscript + run: >- + sudo apt-get install -y + cmake + ninja-build + doxygen + graphviz + groff + psutils + ghostscript + + - uses: actions/checkout@v3 - name: Configure run: cmake -G Ninja -S . -B build @@ -78,14 +78,14 @@ jobs: working-directory: build run: ninja man - - name: Doxygen - working-directory: build - run: ninja doxygen - - name: PDF working-directory: build run: ninja doco + - name: Doxygen + working-directory: build + run: ninja doxygen + - name: Web Site working-directory: build run: ninja man-html web-site diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d3b5f7f3..d7e8715b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -37,6 +37,16 @@ file(GLOB_RECURSE TEST_URL_DECODE_SRC "url_decode/*.cc") add_executable(test_url_decode ${TEST_URL_DECODE_SRC}) target_link_libraries(test_url_decode lib_srecord) +add_custom_target(prepare-test + DEPENDS + srecord-executables + test_arglex_ambiguous + test_crc16 + test_fletcher16 + test_hyphen + test_url_decode +) + # Tests enable_testing() file(GLOB_RECURSE SRECORD_TESTS "*/*.sh") From d0492cf7801c2ee6bcde79abbd646aebac110512 Mon Sep 17 00:00:00 2001 From: Josef Angstenberger Date: Fri, 4 Nov 2022 14:35:44 +0100 Subject: [PATCH 2/4] CI: Add QA workflow with specials build Also move the documentation generation to QA. --- .github/workflows/ci.yml | 37 ----------------- .github/workflows/qa.yml | 86 ++++++++++++++++++++++++++++++++++++++++ cspell.config.yaml | 1 + 3 files changed, 87 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/qa.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63896df6..e61cbe4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,40 +52,3 @@ jobs: - name: Test working-directory: build run: ctest --output-on-failure --output-junit ctest.junit.xml - - docs: - name: Documentation - runs-on: ubuntu-22.04 - - steps: - - name: Install prerequisites - run: >- - sudo apt-get install -y - cmake - ninja-build - doxygen - graphviz - groff - psutils - ghostscript - - - uses: actions/checkout@v3 - - - name: Configure - run: cmake -G Ninja -S . -B build - - - name: man pages - working-directory: build - run: ninja man - - - name: PDF - working-directory: build - run: ninja doco - - - name: Doxygen - working-directory: build - run: ninja doxygen - - - name: Web Site - working-directory: build - run: ninja man-html web-site diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml new file mode 100644 index 00000000..dd1ef824 --- /dev/null +++ b/.github/workflows/qa.yml @@ -0,0 +1,86 @@ +--- +name: QA +on: [push, pull_request] + +jobs: + build: + name: Check source + runs-on: ubuntu-22.04 + + steps: + - name: Install prerequisites + run: >- + sudo apt-get install -y + libgcrypt20-dev + clang-14 + cmake + ninja-build + doxygen + graphviz + + - uses: actions/checkout@v3 + + - name: Configure + env: + CXX: clang++-14 + CXXFLAGS: >- + -std=c++11 + -pedantic + -Wall + SRecord_CMake_Flags: >- + -D CMAKE_EXPORT_COMPILE_COMMANDS=ON + run: | + cmake -G Ninja -S . -B build ${SRecord_CMake_Flags} + + - name: Build + working-directory: build + run: ninja srecord-executables + + - name: Smoke test + working-directory: build + run: ninja srecord-executables-version + + - name: Build test prerequisites + working-directory: build + run: ninja prepare-test + + - name: Test + working-directory: build + run: ctest --output-on-failure --output-junit ctest.junit.xml + + docs: + name: Documentation + runs-on: ubuntu-22.04 + + steps: + - name: Install prerequisites + run: >- + sudo apt-get install -y + cmake + ninja-build + doxygen + graphviz + groff + psutils + ghostscript + + - uses: actions/checkout@v3 + + - name: Configure + run: cmake -G Ninja -S . -B build + + - name: man pages + working-directory: build + run: ninja man + + - name: PDF + working-directory: build + run: ninja doco + + - name: Doxygen + working-directory: build + run: ninja doxygen + + - name: Web Site + working-directory: build + run: ninja man-html web-site diff --git a/cspell.config.yaml b/cspell.config.yaml index 6beb0474..b95f1684 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -116,6 +116,7 @@ words: - compl - CSLEN - csum + - CXXFLAGS - DABEDE - datarec - dbyte From 7b7529b2106bec7703a1ba998086ea1a2a3f13ad Mon Sep 17 00:00:00 2001 From: Josef Angstenberger Date: Fri, 4 Nov 2022 14:55:58 +0100 Subject: [PATCH 3/4] CI: Add Windows MSYS2 and MacOS workflow --- .github/workflows/{ci.yml => ci-linux.yml} | 2 +- .github/workflows/ci-macos.yml | 38 ++++++++++++++ .github/workflows/ci-windows.yml | 59 ++++++++++++++++++++++ doc/dictionaries/names.txt | 2 + doc/etc/BUILDING.man | 2 +- 5 files changed, 101 insertions(+), 2 deletions(-) rename .github/workflows/{ci.yml => ci-linux.yml} (98%) create mode 100644 .github/workflows/ci-macos.yml create mode 100644 .github/workflows/ci-windows.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci-linux.yml similarity index 98% rename from .github/workflows/ci.yml rename to .github/workflows/ci-linux.yml index e61cbe4c..88fd8acf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci-linux.yml @@ -1,5 +1,5 @@ --- -name: CI +name: CI-Linux on: [push, pull_request] jobs: diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml new file mode 100644 index 00000000..9038aafa --- /dev/null +++ b/.github/workflows/ci-macos.yml @@ -0,0 +1,38 @@ +--- +name: CI-MacOS +on: [push, pull_request] + +jobs: + build: + name: Build and Test + runs-on: macos-latest + + steps: + - name: Install prerequisites + run: >- + brew install + libgcrypt + ninja + doxygen + graphviz + + - uses: actions/checkout@v3 + + - name: Configure + run: cmake -G Ninja -S . -B build + + - name: Build + working-directory: build + run: ninja srecord-executables + + - name: Smoke test + working-directory: build + run: ninja srecord-executables-version + + - name: Build test prerequisites + working-directory: build + run: ninja prepare-test + + - name: Test + working-directory: build + run: ctest --output-on-failure --output-junit ctest.junit.xml diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml new file mode 100644 index 00000000..ce2b7b24 --- /dev/null +++ b/.github/workflows/ci-windows.yml @@ -0,0 +1,59 @@ +--- +name: CI-Windows +on: [push, pull_request] + +jobs: + build: + name: MSYS2 Build and Test + runs-on: windows-latest + + defaults: + run: + shell: msys2 {0} + + strategy: + fail-fast: false + matrix: + include: + - sys: mingw64 + env: x86_64 + - sys: mingw32 + env: i686 + - sys: ucrt64 + env: ucrt-x86_64 + + steps: + - name: Install prerequisites + uses: msys2/setup-msys2@v2 + with: + # cSpell:ignore msystem + msystem: ${{ matrix.sys }} + install: >- + mingw-w64-${{ matrix.env }}-libgcrypt + mingw-w64-${{ matrix.env }}-gcc + mingw-w64-${{ matrix.env }}-cmake + mingw-w64-${{ matrix.env }}-ninja + mingw-w64-${{ matrix.env }}-doxygen + mingw-w64-${{ matrix.env }}-graphviz + diffutils + + - uses: actions/checkout@v3 + + - name: Configure + run: cmake -G Ninja -S . -B build + + - name: Build + working-directory: build + run: ninja srecord-executables + + - name: Smoke test + working-directory: build + run: ninja srecord-executables-version + + - name: Build test prerequisites + working-directory: build + run: ninja prepare-test + + - name: Test + working-directory: build + run: ctest --output-on-failure --output-junit ctest.junit.xml diff --git a/doc/dictionaries/names.txt b/doc/dictionaries/names.txt index b19944af..64b66bf5 100644 --- a/doc/dictionaries/names.txt +++ b/doc/dictionaries/names.txt @@ -29,6 +29,7 @@ dg1yfe DJGPP Doxygen dpkg +diffutils Dragonball Elektor Elektuur @@ -133,6 +134,7 @@ Torsten Tridge troff TRSDOS +ucrt Uncia uudecode Verilog diff --git a/doc/etc/BUILDING.man b/doc/etc/BUILDING.man index 1a8d556c..53c0def2 100644 --- a/doc/etc/BUILDING.man +++ b/doc/etc/BUILDING.man @@ -112,7 +112,7 @@ will install updates flagged in the updated database.: \f[I]\&...lots of output...\fP \f[B]% \fPpacman -Syu \f[I]\&...lots of output...\fP -\f[B]% \fPpacman -S mingw-w64-x86_64-gcc groff \\ +\f[B]% \fPpacman -S mingw-w64-x86_64-gcc diffutils groff \\ \f[B] \fP mingw-w64-x86_64-libgcrypt mingw-w64-x86_64-cmake \\ \f[B] \fP mingw-w64-x86_64-graphviz mingw-w64-x86_64-ninja \\ \f[B] \fP mingw-w64-x86_64-doxygen mingw-w64-i686-ghostscript \\ From 9425bc206a7117ee9da07685ca5691827ac12ea7 Mon Sep 17 00:00:00 2001 From: Josef Angstenberger Date: Sat, 5 Nov 2022 01:33:20 +0100 Subject: [PATCH 4/4] CI: Add QA check for Clang-Tidy Add minimal example configuration. --- .clang-tidy | 15 +++++++++++++++ .editorconfig | 2 +- .github/workflows/qa.yml | 5 +++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..d43d665c --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,15 @@ +--- +Checks: >- + -*, + abseil-*, + portability-*, + misc-*, + -misc-no-recursion, + -misc-non-private-member-variables-in-classes, + -misc-redundant-expression, + +# All enabled checks shall be reported as error. +WarningsAsErrors: "*" + +# Check all headers of the project. +HeaderFilterRegex: '.*' diff --git a/.editorconfig b/.editorconfig index 62426ba9..7233a12a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,7 +15,7 @@ max_line_length = 80 [*.{html,man,so}] max_line_length = 400 -[*.{yaml,yml}] +[*.{yaml,yml,clang-tidy}] indent_size = 2 tab_width = 2 diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index dd1ef824..4a282929 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -13,6 +13,7 @@ jobs: sudo apt-get install -y libgcrypt20-dev clang-14 + clang-tidy-14 cmake ninja-build doxygen @@ -48,6 +49,10 @@ jobs: working-directory: build run: ctest --output-on-failure --output-junit ctest.junit.xml + - name: clang-tidy + if: always() + run: run-clang-tidy-14 -p build + docs: name: Documentation runs-on: ubuntu-22.04