From 63682e3c440443d831aa7d0b965968420410cb27 Mon Sep 17 00:00:00 2001 From: Hannes Rantzsch Date: Tue, 21 May 2024 20:33:48 +0200 Subject: [PATCH] fix and update CI (#39) * fix runner.os detection * add ubuntu-24.04 and windows-2019 * update checkout and codecov actions * remove deprecated macos-11 * install gcovr with brew on macos * split test and cov, add schedule * restructure strategy matrix --- .github/workflows/check-format.yml | 10 ++-- .github/workflows/ci.yml | 84 +++++++++++++++++++++--------- 2 files changed, 66 insertions(+), 28 deletions(-) diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml index 5d59b17..251758e 100644 --- a/.github/workflows/check-format.yml +++ b/.github/workflows/check-format.yml @@ -2,14 +2,16 @@ name: Check Format on: push: - branches: [ master ] + branches: + - master pull_request: - branches: [ master ] + branches: + - master jobs: check_format: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run clang-format run: clang-format --dry-run --Werror include/keychain/*.h src/*.cpp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf2ad2e..f92c304 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,62 +2,98 @@ name: Build and test on: push: - branches: [ master ] + branches: + - master pull_request: - branches: [ master ] + branches: + - master + schedule: + - cron: '0 4 * * 0' jobs: - Windows-test: - runs-on: windows-2022 + windows-test: + runs-on: ${{ matrix.os.image }} strategy: matrix: + os: + - { + image: windows-2019, + generator: "Visual Studio 16 2019" + } + - { + image: windows-2022, + generator: "Visual Studio 17 2022" + } config: [Debug, Release] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run cmake - run: cmake -G "Visual Studio 17" . -DBUILD_TESTS=yes -DCODE_COVERAGE=no + run: cmake -G "${{ matrix.os.generator }}" . -DBUILD_TESTS=yes -DCODE_COVERAGE=no - name: Build and run tests run: cmake --build . --target test --config ${{ matrix.config }} - Unix-test-and-cover: - runs-on: ${{ matrix.os }} + unix-test-and-coverage: + runs-on: ${{ matrix.os.image }} strategy: matrix: - os: [ubuntu-20.04, ubuntu-22.04, macos-11, macos-12, macos-13, macos-14] - config: [Debug, Release, Coverage] + os: + - { + image: ubuntu-20.04, + coverage: no + } + - { + image: ubuntu-22.04, + coverage: no + } + - { + image: ubuntu-24.04, + coverage: yes + } + - { + image: macos-12, + coverage: no + } + - { + image: macos-13, + coverage: no + } + - { + image: macos-14, + coverage: yes + } steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies run: | - if [ "$RUNNER_OS" == "Linux" ]; then + if [ ${{ runner.os }} == 'Linux' ]; then sudo apt-get install dbus-x11 dbus gnome-keyring libsecret-1-dev gcovr - elif [ "$RUNNER_OS" == "macOS" ]; then - pip3 install gcovr + elif [ ${{ runner.os }} == 'macOS' ]; then + brew install gcovr fi - - name: "CMake: configure coverage" - if: matrix.config == 'Coverage' - run: cmake . -DBUILD_TESTS=yes -DCODE_COVERAGE=yes -DCMAKE_BUILD_TYPE=Debug - - name: "CMake: configure test" - if: matrix.config != 'Coverage' - run: cmake . -DBUILD_TESTS=yes -DCODE_COVERAGE=no -DCMAKE_BUILD_TYPE=${{ matrix.config }} + - name: Run cmake + run: | + cmake . -DBUILD_TESTS=yes \ + -DCODE_COVERAGE=${{ matrix.os.coverage }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.os.coverage == 'yes' && 'Debug' || 'Release' }} - name: Build and run tests run: | - if [ "$RUNNER_OS" == "Linux" ]; then + if [ ${{ runner.os }} == 'Linux' ]; then eval $(DISPLAY=:99.0 dbus-launch --sh-syntax) echo "somepassword" | gnome-keyring-daemon -r -d --unlock fi cmake --build . --target test - name: Generate gcovr report - if: matrix.config == 'Coverage' + if: matrix.os.coverage == 'yes' run: gcovr -r . -f "src/*" -f "include/*" -x -o coverage.xml + - name: Upload coverage to Codecov - if: matrix.config == 'Coverage' - uses: codecov/codecov-action@v3 + if: matrix.os.coverage == 'yes' + uses: codecov/codecov-action@v4 with: file: ./coverage.xml flags: unittests