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] - 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