From 1f66a8b908664ccbf5d0191bf8ab43faacb70e08 Mon Sep 17 00:00:00 2001 From: vintagepc <53943260+vintagepc@users.noreply.github.com> Date: Sat, 16 Sep 2023 20:55:01 -0400 Subject: [PATCH 01/11] Add Actions firmware build --- .github/workflows/build.yml | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6074348 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,58 @@ +name: ci-build + +on: + - push + - pull_request + +jobs: + build: + runs-on: ubuntu-latest + steps: + + # setup base required dependencies + - name: Setup dependencies + run: | + sudo apt-get install cmake ninja-build python3-pyelftools python3-regex python3-polib + + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout ${{ github.event.pull_request.head.ref }} + uses: actions/checkout@v3 + if: ${{ github.event.pull_request }} + with: + ref: ${{ github.event.pull_request.head.sha }} + submodules: true + + - name: Checkout ${{ github.event.ref }} + uses: actions/checkout@v3 + if: ${{ !github.event.pull_request }} + with: + ref: ${{ github.event.ref }} + submodules: true + + - name: Cache Dependencies + uses: actions/cache@v3.0.11 + id: cache-pkgs + with: + path: ".dependencies" + key: "build-deps-1_0_0-linux" + + - name: Setup build dependencies + run: | + ./utils/bootstrap.py + + - name: Cache permissions + run: sudo chmod -R 744 .dependencies + + - name: Build + run: | + mkdir build + cd build + cmake .. -DCMAKE_TOOLCHAIN_FILE="../cmake/AvrGcc.cmake" -DCMAKE_BUILD_TYPE=Release -G Ninja + ninja + + - name: Upload artifacts + if: ${{ !github.event.pull_request }} + uses: actions/upload-artifact@v3.1.1 + with: + name: Firmware + path: build/*.hex From fbb00f38d30789a37a6342afed010eef3fb670f9 Mon Sep 17 00:00:00 2001 From: VintagePC <53943260+vintagepc@users.noreply.github.com> Date: Sun, 17 Sep 2023 18:15:07 -0400 Subject: [PATCH 02/11] - Add tests to cmake run - Share .dependencies cache with pr-size --- .github/workflows/build.yml | 61 +++++++++++++++++++++++++++++++++++ .github/workflows/pr-size.yml | 10 ++++++ tests/CMakeLists.txt | 3 +- 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6074348..887c3e8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,3 +56,64 @@ jobs: with: name: Firmware path: build/*.hex + + tests: + runs-on: ubuntu-latest + + permissions: + pull-requests: write + + steps: + + # setup base required dependencies + - name: Setup dependencies + run: | + sudo apt-get install gcc g++ cmake ninja-build python3-pyelftools python3-regex python3-polib + + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout ${{ github.event.pull_request.head.ref }} + uses: actions/checkout@v3 + if: ${{ github.event.pull_request }} + with: + ref: ${{ github.event.pull_request.head.sha }} + submodules: true + + - name: Checkout ${{ github.event.ref }} + uses: actions/checkout@v3 + if: ${{ !github.event.pull_request }} + with: + ref: ${{ github.event.ref }} + submodules: true + + - name: Cache Dependencies + uses: actions/cache@v3.0.11 + id: cache-pkgs + with: + path: ".dependencies" + key: "build-deps-1_0_0-linux" + + - name: Setup build dependencies + run: | + ./utils/bootstrap.py + + - name: Cache permissions + run: sudo chmod -R 744 .dependencies + + - name: Build + run: | + mkdir build + cd build + cmake .. -G Ninja + ninja test_coverage_report + + - name: Add PR Comment + if: ${{ github.event.pull_request }} + uses: mshick/add-pr-comment@v2 + with: + message-path: build/Summary.txt + + - name: Upload artifacts + uses: actions/upload-artifact@v3.1.1 + with: + name: Coverage + path: build/Coverage diff --git a/.github/workflows/pr-size.yml b/.github/workflows/pr-size.yml index ac7075b..e90d76e 100644 --- a/.github/workflows/pr-size.yml +++ b/.github/workflows/pr-size.yml @@ -24,10 +24,20 @@ jobs: - name: Checkout base uses: actions/checkout@v3 + - name: Cache Dependencies + uses: actions/cache@v3.0.11 + id: cache-pkgs + with: + path: ".dependencies" + key: "build-deps-1_0_0-linux" + - name: Setup build dependencies run: | ./utils/bootstrap.py + - name: Cache permissions + run: sudo chmod -R 744 .dependencies + - name: Build base run: | rm -rf build-base diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e66dc79..a24ba5e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -55,7 +55,8 @@ if(GCOV_ENABLE) COMMAND tar -zcvf Coverage.tar.gz Coverage # Cheat and compare a file to itself to check for existence. File-Not-Found is a failure # code. - COMMAND ../../utils/gcovr.py -r . -e '../../tests' -e '../../lib/Catch2' | tee Summary.txt + COMMAND ${PROJECT_SOURCE_DIR}/utils/gcovr.py -r . -e '../../tests' -e '../../lib/Catch2' | tee + Summary.txt COMMAND ${CMAKE_COMMAND} -E compare_files ${PROJECT_BINARY_DIR}/.ctest-finished ${PROJECT_BINARY_DIR}/.ctest-finished BYPRODUCTS ${PROJECT_BINARY_DIR}/Summary.txt ${PROJECT_BINARY_DIR}/Coverage.tar.gz From 4e9ad8038413fe660d60d9b3d89bd5e016de356b Mon Sep 17 00:00:00 2001 From: VintagePC <53943260+vintagepc@users.noreply.github.com> Date: Sun, 17 Sep 2023 18:18:45 -0400 Subject: [PATCH 03/11] add lcov to packages --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 887c3e8..27d99d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,7 +68,7 @@ jobs: # setup base required dependencies - name: Setup dependencies run: | - sudo apt-get install gcc g++ cmake ninja-build python3-pyelftools python3-regex python3-polib + sudo apt-get install gcc g++ lcov cmake ninja-build python3-pyelftools python3-regex python3-polib # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout ${{ github.event.pull_request.head.ref }} From fe354a1f51c59e046d6b8aff42be5aa4fd2b8de8 Mon Sep 17 00:00:00 2001 From: VintagePC <53943260+vintagepc@users.noreply.github.com> Date: Sun, 17 Sep 2023 18:30:50 -0400 Subject: [PATCH 04/11] - allow report upload on error - fix coverage paths --- .github/workflows/build.yml | 19 ++++++++++++++----- tests/CMakeLists.txt | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 27d99d1..af50b92 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -100,20 +100,29 @@ jobs: run: sudo chmod -R 744 .dependencies - name: Build + id: tests_run + continue-on-error: true run: | mkdir build cd build cmake .. -G Ninja ninja test_coverage_report - - name: Add PR Comment - if: ${{ github.event.pull_request }} - uses: mshick/add-pr-comment@v2 - with: - message-path: build/Summary.txt - name: Upload artifacts uses: actions/upload-artifact@v3.1.1 with: name: Coverage path: build/Coverage + + - name: Report failure + if: steps.tests_run.outcome == 'failure' + run: echo ${{ steps.tests_run.outcome }} && test -n "" + + # We don't PR comment if the tests failed, because + # the report isn't a complete picture... + - name: Add PR Comment + if: ${{ github.event.pull_request }} + uses: mshick/add-pr-comment@v2 + with: + message-path: build/Summary.txt diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a24ba5e..a081796 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -55,8 +55,8 @@ if(GCOV_ENABLE) COMMAND tar -zcvf Coverage.tar.gz Coverage # Cheat and compare a file to itself to check for existence. File-Not-Found is a failure # code. - COMMAND ${PROJECT_SOURCE_DIR}/utils/gcovr.py -r . -e '../../tests' -e '../../lib/Catch2' | tee - Summary.txt + COMMAND ${PROJECT_SOURCE_DIR}/utils/gcovr.py -r ${CMAKE_SOURCE_DIR} -e 'tests' -e 'lib/Catch2' | + tee Summary.txt COMMAND ${CMAKE_COMMAND} -E compare_files ${PROJECT_BINARY_DIR}/.ctest-finished ${PROJECT_BINARY_DIR}/.ctest-finished BYPRODUCTS ${PROJECT_BINARY_DIR}/Summary.txt ${PROJECT_BINARY_DIR}/Coverage.tar.gz From 1d1d2f23ecde4896a638280fff279642fced806a Mon Sep 17 00:00:00 2001 From: VintagePC <53943260+vintagepc@users.noreply.github.com> Date: Sun, 17 Sep 2023 18:48:11 -0400 Subject: [PATCH 05/11] fix message-id --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index af50b92..0d65204 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,7 +68,7 @@ jobs: # setup base required dependencies - name: Setup dependencies run: | - sudo apt-get install gcc g++ lcov cmake ninja-build python3-pyelftools python3-regex python3-polib + sudo apt-get install gcc-11 g++11 lcov cmake ninja-build python3-pyelftools python3-regex python3-polib # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Checkout ${{ github.event.pull_request.head.ref }} @@ -126,3 +126,4 @@ jobs: uses: mshick/add-pr-comment@v2 with: message-path: build/Summary.txt + message-id: "coverage" From 6340421f513de12236e39a970ec061b720c2c0d9 Mon Sep 17 00:00:00 2001 From: VintagePC <53943260+vintagepc@users.noreply.github.com> Date: Sun, 17 Sep 2023 19:00:07 -0400 Subject: [PATCH 06/11] Patch gcovr script --- utils/gcovr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/gcovr.py b/utils/gcovr.py index febd0fe..6f28c63 100755 --- a/utils/gcovr.py +++ b/utils/gcovr.py @@ -632,7 +632,7 @@ def process_gcov_data(data_fname, covdata, source_fname, options): elif tmp[0] == '=': is_code_statement = True uncovered_exceptional.add(lineno) - elif tmp[0] in "0123456789": + elif tmp[0] in "0123456789" and not segments[0].endswith("*"): is_code_statement = True covered[lineno] = int(segments[0].strip()) elif tmp.startswith('branch'): From c60d562c8cdb066a60272373a97cfe5419dd4ec7 Mon Sep 17 00:00:00 2001 From: VintagePC <53943260+vintagepc@users.noreply.github.com> Date: Sun, 17 Sep 2023 19:05:34 -0400 Subject: [PATCH 07/11] Patch gcovr script - take 2 --- utils/gcovr.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/gcovr.py b/utils/gcovr.py index 6f28c63..4bc7ba9 100755 --- a/utils/gcovr.py +++ b/utils/gcovr.py @@ -632,7 +632,9 @@ def process_gcov_data(data_fname, covdata, source_fname, options): elif tmp[0] == '=': is_code_statement = True uncovered_exceptional.add(lineno) - elif tmp[0] in "0123456789" and not segments[0].endswith("*"): + elif tmp[0] in "0123456789" and segments[0].endswith("*"): + continue + elif tmp[0] in "0123456789": is_code_statement = True covered[lineno] = int(segments[0].strip()) elif tmp.startswith('branch'): From 515b93e9e7d80f2ccf3e53b1e07bc28c8e128124 Mon Sep 17 00:00:00 2001 From: VintagePC <53943260+vintagepc@users.noreply.github.com> Date: Sun, 17 Sep 2023 19:39:03 -0400 Subject: [PATCH 08/11] Patch gcovr script - take 3 --- utils/gcovr.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/utils/gcovr.py b/utils/gcovr.py index 4bc7ba9..725b0f1 100755 --- a/utils/gcovr.py +++ b/utils/gcovr.py @@ -619,6 +619,10 @@ def process_gcov_data(data_fname, covdata, source_fname, options): is_code_statement = False if tmp[0] == '-' or (excluding and tmp[0] in "#=0123456789"): is_code_statement = True + if len(segments) < 3: + noncode.add(lineno) + continue + code = segments[2].strip() # remember certain non-executed lines if excluding or is_non_code(segments[2]): @@ -632,11 +636,9 @@ def process_gcov_data(data_fname, covdata, source_fname, options): elif tmp[0] == '=': is_code_statement = True uncovered_exceptional.add(lineno) - elif tmp[0] in "0123456789" and segments[0].endswith("*"): - continue elif tmp[0] in "0123456789": is_code_statement = True - covered[lineno] = int(segments[0].strip()) + covered[lineno] = int(segments[0].strip().rstrip('*')) elif tmp.startswith('branch'): exclude_branch = False if options.exclude_unreachable_branches and \ From 8073ce66fb679e482d9fd6ef3981bb12579e84bf Mon Sep 17 00:00:00 2001 From: VintagePC <53943260+vintagepc@users.noreply.github.com> Date: Sun, 17 Sep 2023 19:45:24 -0400 Subject: [PATCH 09/11] Post comment anyway --- .github/workflows/build.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0d65204..3d60771 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -115,15 +115,13 @@ jobs: name: Coverage path: build/Coverage - - name: Report failure - if: steps.tests_run.outcome == 'failure' - run: echo ${{ steps.tests_run.outcome }} && test -n "" - - # We don't PR comment if the tests failed, because - # the report isn't a complete picture... - name: Add PR Comment if: ${{ github.event.pull_request }} uses: mshick/add-pr-comment@v2 with: message-path: build/Summary.txt message-id: "coverage" + + - name: Report failure + if: steps.tests_run.outcome == 'failure' + run: echo ${{ steps.tests_run.outcome }} && test -n "" From dda38991566d5270813f66e55670a4fafa9568d3 Mon Sep 17 00:00:00 2001 From: vintagepc <53943260+vintagepc@users.noreply.github.com> Date: Mon, 18 Sep 2023 07:29:40 -0400 Subject: [PATCH 10/11] Adjust CTest timeout --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a081796..d7b291e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,7 +15,7 @@ if(GCOV_ENABLE) COMMAND ${CMAKE_COMMAND} -E remove ${PROJECT_BINARY_DIR}/.ctest-finished ) - set(ctest_test_args --timeout 30 --output-on-failure) + set(ctest_test_args --timeout 180 --output-on-failure) include(ProcessorCount) ProcessorCount(N) From b0eac8f523e886983ba70ab598a9d7e29aa2351f Mon Sep 17 00:00:00 2001 From: vintagepc <53943260+vintagepc@users.noreply.github.com> Date: Mon, 18 Sep 2023 07:45:11 -0400 Subject: [PATCH 11/11] Refine triggers --- .github/workflows/build.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3d60771..af2ac48 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,8 +1,11 @@ name: ci-build on: - - push - - pull_request + pull_request: + branches: + - '*' + push: + branches: [ main, MMU_* ] jobs: build: