From ab593b143b4cb993803afff170003b54ff4bb12c Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 10 Jul 2023 12:44:45 +0200 Subject: [PATCH] [INFRA] Update CI --- .github/workflows/api.yml | 28 +-- .github/workflows/ci_coverage.yml | 72 ++------ .github/workflows/ci_documentation.yml | 61 ++++++ .github/workflows/ci_linux.yml | 80 +++----- .github/workflows/ci_macos.yml | 75 ++------ .github/workflows/ci_misc.yml | 129 ++----------- .github/workflows/clang_format.yml | 173 ------------------ .../{documentation.yaml => documentation.yml} | 14 +- .github/workflows/lint.yml | 75 ++++++++ .github/workflows/scripts/gcov.sh | 6 + test/coverage/CMakeLists.txt | 39 ++-- 11 files changed, 254 insertions(+), 498 deletions(-) create mode 100644 .github/workflows/ci_documentation.yml delete mode 100644 .github/workflows/clang_format.yml rename .github/workflows/{documentation.yaml => documentation.yml} (88%) create mode 100644 .github/workflows/lint.yml create mode 100755 .github/workflows/scripts/gcov.sh diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index c0fb448a..f3e60814 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -30,7 +30,7 @@ jobs: strategy: fail-fast: false matrix: - compiler: [10, 11, 12] + compiler: [11, 12, 13] steps: - name: Checkout Sharg @@ -40,30 +40,18 @@ jobs: fetch-depth: 1 submodules: true - # To reuse scripts - - name: Checkout SeqAn3 - uses: actions/checkout@v3 + - name: Setup toolchain + uses: seqan/actions/setup-toolchain@main with: - repository: seqan/seqan3 - ref: aa3df18a6df59679e07e9fe2de4e0998a94af7e7 - path: seqan3 - fetch-depth: 1 - submodules: false - - - name: Configure APT - continue-on-error: true - run: bash ./seqan3/.github/workflows/scripts/configure_apt.sh + compiler: gcc-${{ matrix.compiler }} + ccache_size: 75M - name: Install CMake - run: bash ./seqan3/.github/workflows/scripts/install_cmake.sh - - - name: Install compiler g++-${{ matrix.compiler }} - run: sudo apt-get install --yes g++-${{ matrix.compiler }} + uses: seqan/actions/setup-cmake@main + with: + cmake: 3.16.9 - name: Configure tests - env: - CXX: g++-${{ matrix.compiler }} - CC: gcc-${{ matrix.compiler }} run: | mkdir sharg-build cd sharg-build diff --git a/.github/workflows/ci_coverage.yml b/.github/workflows/ci_coverage.yml index d49a6d8d..6d80f271 100644 --- a/.github/workflows/ci_coverage.yml +++ b/.github/workflows/ci_coverage.yml @@ -1,4 +1,4 @@ -name: CI on Linux +name: Coverage on: push: @@ -20,29 +20,27 @@ concurrency: cancel-in-progress: false # PRs will be canceled by the clang-format CI env: - CMAKE_VERSION: 3.16.9 SHARG_NO_VERSION_CHECK: 1 TZ: Europe/Berlin defaults: run: - shell: bash -ex {0} + shell: bash -Eexuo pipefail {0} jobs: build: name: ${{ matrix.name }} runs-on: ubuntu-22.04 timeout-minutes: 120 - if: github.repository_owner == 'seqan' || github.event_name == 'workflow_dispatch' || github.event.label.name == 'clang-format' + if: github.repository_owner == 'seqan' || github.event_name == 'workflow_dispatch' || github.event.label.name == 'lint' strategy: fail-fast: true matrix: include: - - name: "Coverage gcc12" - cxx: "g++-12" - cc: "gcc-12" + - name: "gcc13" + compiler: "gcc-13" build: coverage - build_type: Debug + build_type: Coverage steps: # How many commits do we need to fetch to also fetch the branch point? @@ -57,58 +55,23 @@ jobs: fetch-depth: ${{ steps.fetch_depth.outputs.depth }} submodules: true - # To reuse scripts - - name: Checkout SeqAn3 - uses: actions/checkout@v3 + - name: Setup toolchain + uses: seqan/actions/setup-toolchain@main with: - repository: seqan/seqan3 - ref: aa3df18a6df59679e07e9fe2de4e0998a94af7e7 - path: seqan3 - fetch-depth: 1 - submodules: false - - - name: Configure APT - continue-on-error: true - run: bash ./seqan3/.github/workflows/scripts/configure_apt.sh + compiler: ${{ matrix.compiler }} + ccache_size: 125M - name: Install CMake - run: bash ./seqan3/.github/workflows/scripts/install_cmake.sh - - - name: Install ccache - run: | - conda install --yes --override-channels --channel conda-forge ccache - sudo ln -s $CONDA/bin/ccache /usr/bin/ccache - - - name: Install compiler ${{ matrix.cxx }} - run: sudo apt-get install --yes ${{ matrix.cxx }} + uses: seqan/actions/setup-cmake@main + with: + cmake: 3.16.9 - name: Install gcovr - env: - CC: ${{ matrix.cc }} run: | sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/${CC/gcc/gcov} 100 - pip install gcovr==5.0 - - - name: Load ccache - uses: actions/cache@v3 - with: - path: .ccache - key: ${{ runner.os }}-${{ matrix.name }}-ccache-${{ github.ref }}-${{ github.run_number }} - # Restoring: From current branch, otherwise from base branch, otherwise from any branch. - restore-keys: | - ${{ runner.os }}-${{ matrix.name }}-ccache-${{ github.ref }} - ${{ runner.os }}-${{ matrix.name }}-ccache-${{ github.base_ref }} - ${{ runner.os }}-${{ matrix.name }}-ccache- - - - name: Tool versions - run: | - env cmake --version - env ${{ matrix.cxx }} --version + pip install gcovr==6.0 - name: Configure tests - env: - CXX: ${{ matrix.cxx }} - CC: ${{ matrix.cc }} run: | mkdir sharg-build cd sharg-build @@ -120,13 +83,8 @@ jobs: - name: Build tests env: - CCACHE_BASEDIR: ${{ github.workspace }} - CCACHE_DIR: ${{ github.workspace }}/.ccache - CCACHE_COMPRESS: true - CCACHE_COMPRESSLEVEL: 12 - CCACHE_MAXSIZE: 125M CCACHE_IGNOREOPTIONS: "-fprofile-abs-path" - GCOV: ${{ github.workspace }}/seqan3/.github/workflows/scripts/gcov.sh + GCOV: ${{ github.workspace }}/sharg/.github/workflows/scripts/gcov.sh run: | ccache -z cd sharg-build diff --git a/.github/workflows/ci_documentation.yml b/.github/workflows/ci_documentation.yml new file mode 100644 index 00000000..c03399d9 --- /dev/null +++ b/.github/workflows/ci_documentation.yml @@ -0,0 +1,61 @@ +name: Documentation + +on: + push: + branches: + # Push events to branches matching refs/heads/main + - 'main' + # Push events to branches matching refs/heads/release* + - 'release*' + # Trigger after PR was unlabeled + pull_request: + types: + - unlabeled + # Enables a manual trigger, may run on any branch + workflow_dispatch: + +concurrency: + group: documentation-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name != 'push' }} + +env: + TZ: Europe/Berlin + +defaults: + run: + shell: bash -Eexuo pipefail {0} + +jobs: + build: + name: Documentation + runs-on: ubuntu-22.04 + timeout-minutes: 120 + if: github.repository_owner == 'seqan' || github.event_name == 'workflow_dispatch' || github.event.label.name == 'lint' + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 1 + submodules: true + + - name: Install CMake + uses: seqan/actions/setup-cmake@main + with: + cmake: 3.16.9 + + - name: Install Doxygen + uses: seqan/actions/setup-doxygen@main + with: + doxygen: 1.9.5 + + - name: Configure tests + run: | + mkdir build + cd build + cmake ../test/documentation + make -j2 download-cppreference-doxygen-web-tag + + - name: Run tests + run: | + cd build + ctest . -j2 --output-on-failure diff --git a/.github/workflows/ci_linux.yml b/.github/workflows/ci_linux.yml index 222e1016..2780f1b2 100644 --- a/.github/workflows/ci_linux.yml +++ b/.github/workflows/ci_linux.yml @@ -1,4 +1,4 @@ -name: CI on Linux +name: Unit Linux on: push: @@ -16,42 +16,43 @@ on: concurrency: group: linux-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name == 'push' }} + cancel-in-progress: ${{ github.event_name != 'push' }} env: - CMAKE_VERSION: 3.16.9 SHARG_NO_VERSION_CHECK: 1 TZ: Europe/Berlin defaults: run: - shell: bash -ex {0} + shell: bash -Eexuo pipefail {0} jobs: build: name: ${{ matrix.name }} runs-on: ubuntu-22.04 timeout-minutes: 120 - if: github.repository_owner == 'seqan' || github.event_name == 'workflow_dispatch' || github.event.label.name == 'clang-format' + if: github.repository_owner == 'seqan' || github.event_name == 'workflow_dispatch' || github.event.label.name == 'lint' strategy: fail-fast: true matrix: include: - - name: "Unit gcc12" - cxx: "g++-12" - cc: "gcc-12" + - name: "clang17" + compiler: "clang-17" build: unit build_type: Release - - name: "Unit gcc11" - cxx: "g++-11" - cc: "gcc-11" + - name: "gcc13" + compiler: "gcc-13" build: unit build_type: Release - - name: "Unit gcc10" - cxx: "g++-10" - cc: "gcc-10" + - name: "gcc12" + compiler: "gcc-12" + build: unit + build_type: Release + + - name: "gcc11" + compiler: "gcc-11" build: unit build_type: Release @@ -63,51 +64,18 @@ jobs: fetch-depth: 1 submodules: true - # To reuse scripts - - name: Checkout SeqAn3 - uses: actions/checkout@v3 + - name: Setup toolchain + uses: seqan/actions/setup-toolchain@main with: - repository: seqan/seqan3 - ref: aa3df18a6df59679e07e9fe2de4e0998a94af7e7 - path: seqan3 - fetch-depth: 1 - submodules: false - - - name: Configure APT - continue-on-error: true - run: bash ./seqan3/.github/workflows/scripts/configure_apt.sh + compiler: ${{ matrix.compiler }} + ccache_size: 75M - name: Install CMake - run: bash ./seqan3/.github/workflows/scripts/install_cmake.sh - - - name: Install ccache - run: | - conda install --yes --override-channels --channel conda-forge ccache - sudo ln -s $CONDA/bin/ccache /usr/bin/ccache - - - name: Install compiler ${{ matrix.cxx }} - run: sudo apt-get install --yes ${{ matrix.cxx }} - - - name: Load ccache - uses: actions/cache@v3 + uses: seqan/actions/setup-cmake@main with: - path: .ccache - key: ${{ runner.os }}-${{ matrix.name }}-ccache-${{ github.ref }}-${{ github.run_number }} - # Restoring: From current branch, otherwise from base branch, otherwise from any branch. - restore-keys: | - ${{ runner.os }}-${{ matrix.name }}-ccache-${{ github.ref }} - ${{ runner.os }}-${{ matrix.name }}-ccache-${{ github.base_ref }} - ${{ runner.os }}-${{ matrix.name }}-ccache- - - - name: Tool versions - run: | - env cmake --version - env ${{ matrix.cxx }} --version + cmake: 3.16.9 - name: Configure tests - env: - CXX: ${{ matrix.cxx }} - CC: ${{ matrix.cc }} run: | mkdir sharg-build cd sharg-build @@ -117,12 +85,6 @@ jobs: make -j2 gtest_build yaml-cpp - name: Build tests - env: - CCACHE_BASEDIR: ${{ github.workspace }} - CCACHE_DIR: ${{ github.workspace }}/.ccache - CCACHE_COMPRESS: true - CCACHE_COMPRESSLEVEL: 12 - CCACHE_MAXSIZE: 50M run: | ccache -z cd sharg-build diff --git a/.github/workflows/ci_macos.yml b/.github/workflows/ci_macos.yml index cd3d186b..b2111446 100644 --- a/.github/workflows/ci_macos.yml +++ b/.github/workflows/ci_macos.yml @@ -1,4 +1,4 @@ -name: CI on macOS +name: Unit macOS on: push: @@ -16,42 +16,38 @@ on: concurrency: group: macos-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name == 'push' }} + cancel-in-progress: ${{ github.event_name != 'push' }} env: - CMAKE_VERSION: 3.16.9 SHARG_NO_VERSION_CHECK: 1 TZ: Europe/Berlin defaults: run: - shell: bash -ex {0} + shell: bash -Eexuo pipefail {0} jobs: build: name: ${{ matrix.name }} runs-on: macos-12 timeout-minutes: 120 - if: github.repository_owner == 'seqan' || github.event_name == 'workflow_dispatch' || github.event.label.name == 'clang-format' + if: github.repository_owner == 'seqan' || github.event_name == 'workflow_dispatch' || github.event.label.name == 'lint' strategy: fail-fast: true matrix: include: - - name: "Unit gcc12" - cxx: "g++-12" - cc: "gcc-12" + - name: "gcc13" + compiler: "gcc-13" build: unit build_type: Release - - name: "Unit gcc11" - cxx: "g++-11" - cc: "gcc-11" + - name: "gcc12" + compiler: "gcc-12" build: unit build_type: Release - - name: "Unit gcc10" - cxx: "g++-10" - cc: "gcc-10" + - name: "gcc11" + compiler: "gcc-11" build: unit build_type: Release @@ -63,51 +59,18 @@ jobs: fetch-depth: 1 submodules: true - # To reuse scripts - - name: Checkout SeqAn3 - uses: actions/checkout@v3 + - name: Setup toolchain + uses: seqan/actions/setup-toolchain@main with: - repository: seqan/seqan3 - ref: aa3df18a6df59679e07e9fe2de4e0998a94af7e7 - path: seqan3 - fetch-depth: 1 - submodules: false - - - name: Configure Homebrew - uses: Homebrew/actions/setup-homebrew@master + compiler: ${{ matrix.compiler }} + ccache_size: 75M - name: Install CMake - run: bash ./seqan3/.github/workflows/scripts/install_cmake.sh - - - name: Install ccache - run: bash ./seqan3/.github/workflows/scripts/install_via_brew.sh ccache - - - name: Install compiler ${{ matrix.cxx }} - env: - CC: ${{ matrix.cc }} - run: bash ./seqan3/.github/workflows/scripts/install_via_brew.sh $(echo ${CC/clang/llvm} | awk -F '-' '{print $1, $2}') - - - name: Load ccache - uses: actions/cache@v3 + uses: seqan/actions/setup-cmake@main with: - path: .ccache - key: ${{ runner.os }}-${{ matrix.name }}-ccache-${{ github.ref }}-${{ github.run_number }} - # Restoring: From current branch, otherwise from base branch, otherwise from any branch. - restore-keys: | - ${{ runner.os }}-${{ matrix.name }}-ccache-${{ github.ref }} - ${{ runner.os }}-${{ matrix.name }}-ccache-${{ github.base_ref }} - ${{ runner.os }}-${{ matrix.name }}-ccache- - - - name: Tool versions - run: | - env cmake --version - env ${{ matrix.cxx }} --version - sudo xcode-select -s '/Applications/Xcode_13.4.1.app/Contents/Developer' # https://github.com/actions/runner-images/issues/6350 + cmake: 3.16.9 - name: Configure tests - env: - CXX: ${{ matrix.cxx }} - CC: ${{ matrix.cc }} run: | mkdir sharg-build cd sharg-build @@ -117,12 +80,6 @@ jobs: make -j3 gtest_build yaml-cpp - name: Build tests - env: - CCACHE_BASEDIR: ${{ github.workspace }} - CCACHE_DIR: ${{ github.workspace }}/.ccache - CCACHE_COMPRESS: true - CCACHE_COMPRESSLEVEL: 12 - CCACHE_MAXSIZE: 75M run: | ccache -z cd sharg-build diff --git a/.github/workflows/ci_misc.yml b/.github/workflows/ci_misc.yml index 0afbc306..b7eac2e2 100644 --- a/.github/workflows/ci_misc.yml +++ b/.github/workflows/ci_misc.yml @@ -1,4 +1,4 @@ -name: CI misc +name: Linux on: push: @@ -16,7 +16,7 @@ on: concurrency: group: misc-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: ${{ github.event_name == 'push' }} + cancel-in-progress: ${{ github.event_name != 'push' }} env: SHARG_NO_VERSION_CHECK: 1 @@ -24,68 +24,35 @@ env: defaults: run: - shell: bash -ex {0} + shell: bash -Eexuo pipefail {0} jobs: build: name: ${{ matrix.name }} runs-on: ubuntu-22.04 timeout-minutes: 120 - if: github.repository_owner == 'seqan' || github.event_name == 'workflow_dispatch' || github.event.label.name == 'clang-format' + if: github.repository_owner == 'seqan' || github.event_name == 'workflow_dispatch' || github.event.label.name == 'lint' strategy: fail-fast: false matrix: include: - name: "Snippet gcc11" - cxx: "g++-11" - cc: "gcc-11" + compiler: "gcc-11" build: snippet build_type: Release - build_threads: 2 test_threads: 1 # snippets create and delete files and some separate tests create/delete the same files - cxx_flags: "-std=c++20" - cmake: 3.16.9 - requires_toolchain: true - requires_ccache: true - skip_build_tests: false - skip_run_tests: false - - name: "Header gcc12" - cxx: "g++-12" - cc: "gcc-12" + - name: "Header gcc13" + compiler: "gcc-13" build: header build_type: Debug - build_threads: 2 test_threads: 2 - cmake: 3.16.9 - requires_toolchain: true - requires_ccache: true - skip_build_tests: false - skip_run_tests: false - - name: "Header gcc10" - cxx: "g++-10" - cc: "gcc-10" + - name: "Header gcc11" + compiler: "gcc-11" build: header build_type: Debug - build_threads: 2 test_threads: 2 - cmake: 3.16.9 - requires_toolchain: true - requires_ccache: true - skip_build_tests: false - skip_run_tests: false - - - name: "Documentation" - build: documentation - build_threads: 2 - test_threads: 2 - cmake: 3.16.9 - doxygen: 1.9.5 - requires_toolchain: false - requires_ccache: false - skip_build_tests: true - skip_run_tests: false steps: - name: Checkout @@ -95,92 +62,36 @@ jobs: fetch-depth: 1 submodules: true - # To reuse scripts - - name: Checkout SeqAn3 - uses: actions/checkout@v3 + - name: Setup toolchain + uses: seqan/actions/setup-toolchain@main with: - repository: seqan/seqan3 - ref: aa3df18a6df59679e07e9fe2de4e0998a94af7e7 - path: seqan3 - fetch-depth: 1 - submodules: false - - - name: Configure APT - continue-on-error: true - run: bash ./seqan3/.github/workflows/scripts/configure_apt.sh + compiler: ${{ matrix.compiler }} + ccache_size: 75M - name: Install CMake - env: - BUILD: ${{ matrix.build }} - CMAKE_VERSION: ${{ matrix.cmake }} - run: bash ./seqan3/.github/workflows/scripts/install_cmake.sh - - - name: Install Doxygen - if: matrix.build == 'documentation' - env: - DOXYGEN_VERSION: ${{ matrix.doxygen }} - run: bash ./seqan3/.github/workflows/scripts/install_doxygen.sh - - - name: Install ccache - if: matrix.requires_ccache - run: | - conda install --yes --override-channels --channel conda-forge ccache - sudo ln -s $CONDA/bin/ccache /usr/bin/ccache - - - name: Install compiler ${{ matrix.cxx }} - if: matrix.requires_toolchain - run: sudo apt-get install --yes ${{ matrix.cxx }} - - - name: Load ccache - if: matrix.requires_ccache - uses: actions/cache@v3 + uses: seqan/actions/setup-cmake@main with: - path: .ccache - key: ${{ matrix.name }}-ccache-${{ github.ref }}-${{ github.run_number }} - # Restoring: From current branch, otherwise from base branch, otherwise from any branch. - restore-keys: | - ${{ matrix.name }}-ccache-${{ github.ref }} - ${{ matrix.name }}-ccache-${{ github.base_ref }} - ${{ matrix.name }}-ccache- - - - name: Tool versions - run: | - env cmake --version - env doxygen --version || true - env ${{ matrix.cxx }} --version || true + cmake: 3.16.9 - name: Configure tests - env: - CXX: ${{ matrix.cxx }} - CC: ${{ matrix.cc }} run: | mkdir sharg-build cd sharg-build cmake ../sharg/test/${{ matrix.build }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" \ -DSHARG_VERBOSE_TESTS=OFF case "${{ matrix.build }}" in - snippet) make -j${{ matrix.build_threads }} gtest_build yaml-cpp;; - header) make -j${{ matrix.build_threads }} gtest_build gbenchmark_build yaml-cpp;; - documentation) make -j${{ matrix.build_threads }} download-cppreference-doxygen-web-tag;; + snippet) make -j2 gtest_build yaml-cpp;; + header) make -j2 gtest_build gbenchmark_build yaml-cpp;; esac - name: Build tests - if: ${{ !matrix.skip_build_tests }} - env: - CCACHE_BASEDIR: ${{ github.workspace }} - CCACHE_DIR: ${{ github.workspace }}/.ccache - CCACHE_COMPRESS: true - CCACHE_COMPRESSLEVEL: 12 - CCACHE_MAXSIZE: 75M run: | - ccache -z || true + ccache -z cd sharg-build - make -k -j${{ matrix.build_threads }} - ccache -sv || true + make -k -j2 + ccache -sv - name: Run tests - if: ${{ !matrix.skip_run_tests }} run: | cd sharg-build ctest . -j${{ matrix.test_threads }} --output-on-failure diff --git a/.github/workflows/clang_format.yml b/.github/workflows/clang_format.yml deleted file mode 100644 index 35b1d242..00000000 --- a/.github/workflows/clang_format.yml +++ /dev/null @@ -1,173 +0,0 @@ -name: Sharg lint - -on: - pull_request_target: - -env: - TZ: Europe/Berlin - -defaults: - run: - shell: bash -exo pipefail {0} - -jobs: - # Cancel other workflows that are dependent on this workflow by adding jobs that have the same concurrency group. - cancel_linux: - name: Cancel Linux - concurrency: - group: linux-${{ github.event.pull_request.number }} - cancel-in-progress: true - runs-on: ubuntu-22.04 - steps: - - name: "Cancel Linux" - run: echo "Cancelling Linux" - cancel_macos: - name: Cancel macOS - concurrency: - group: macos-${{ github.event.pull_request.number }} - cancel-in-progress: true - runs-on: ubuntu-22.04 - steps: - - name: "Cancel macOS" - run: echo "Cancelling macOS" - cancel_misc: - name: Cancel Misc - concurrency: - group: misc-${{ github.event.pull_request.number }} - cancel-in-progress: true - runs-on: ubuntu-22.04 - steps: - - name: "Cancel Misc" - run: echo "Cancelling Misc" - cancel_coverage: - name: Cancel Coverage - concurrency: - group: coverage-${{ github.event.pull_request.number }} - cancel-in-progress: true - runs-on: ubuntu-22.04 - steps: - - name: "Cancel Coverage" - run: echo "Cancelling Coverage" - lint: - name: clang-format - concurrency: - group: clang-format-${{ github.event.pull_request.number }} - cancel-in-progress: true - needs: [cancel_linux, cancel_macos, cancel_misc, cancel_coverage] - runs-on: ubuntu-22.04 - timeout-minutes: 15 - steps: - - name: Add label - env: - GITHUB_TOKEN: ${{ secrets.SEQAN_ACTIONS_PAT }} - PR_URL: ${{ github.event.pull_request.html_url }} - run: gh pr edit $PR_URL --add-label "clang-format" - - # How many commits need to be fetched such that the branch point of the PR branch is visible when fetching the - # upstream? - - name: Get fetch depth - id: fetch_depth - env: - GITHUB_TOKEN: ${{ secrets.SEQAN_ACTIONS_PAT }} - COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} - run: | - QUERY="/repos/${{ github.repository }}/compare/${COMMIT_RANGE}" - ANSWER=$(gh api -H "Accept: application/vnd.github.v3+json" ${QUERY}) - NBEHIND=$(jq '.behind_by' <<< "${ANSWER}") - echo "depth=$(( ${NBEHIND} + 1 ))" >> $GITHUB_OUTPUT - echo "pr_depth=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> $GITHUB_OUTPUT - - - name: Checkout Sharg - uses: actions/checkout@v3 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - path: sharg - fetch-depth: ${{ steps.fetch_depth.outputs.pr_depth }} - submodules: false - - # Comments on each git line: - # Checkout new branch that will be rebased. Actual PR branch remains untouched. - # Add the upstream repository. - # Disallow (accidental) pushes to upstream. - # Fetch the upstream. Fetch as many commits such that the branch point of the PR branch is visible. - # For rebasing, use last commit's user name. - # For rebasing, use last commit's user email. - # Rebase on upstream. - - name: Rebase on upstream - run: | - cd sharg - git checkout -b seqan_clang_format_rebase_${{ github.event.pull_request.head.ref }} - git remote add upstream ${{ github.event.pull_request.base.repo.html_url }} - git remote set-url --push upstream nopush - git fetch --depth ${{ steps.fetch_depth.outputs.depth }} upstream ${{ github.event.pull_request.base.ref }} - git config user.name "$(git log -1 --format='%cn' ${{ github.event.pull_request.head.sha }})" - git config user.email "$(git log -1 --format='%ce' ${{ github.event.pull_request.head.sha }})" - git rebase upstream/${{ github.event.pull_request.base.ref }} - - - name: Copy upstream .clang-format - run: | - cd sharg - git show upstream/${{ github.event.pull_request.base.ref }}:.clang-format | \ - tee ${{ github.workspace }}/.clang-format - - # Get filenames (--name-only) of added, copied, modified, renamed, changed (ACMRT) files relative to the base - # branch (github.event.pull_request.base.sha). - # Exclude contrib include folder, exclude submodules folder. - # Include only hpp and cpp files as well as files in the std include folder. - # { grep ... || test $? = 1; } ensures that grep exits with code 0 on empty output. - - name: Get changed files - id: changed_files - run: | - cd sharg - LIST=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} | \ - { grep -E "(.cpp|.hpp|include/sharg/std/)" || test $? = 1; } | xargs) - echo "list=$LIST" >> $GITHUB_OUTPUT - - - name: Install clang-format - if: ${{ steps.changed_files.outputs.list }} - run: | - echo 'APT::Acquire::Retries "5";' | sudo tee -a /etc/apt/apt.conf.d/80-retries > /dev/null - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo apt-add-repository --no-update --yes "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" - sudo apt-add-repository --no-update --yes "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main" - sudo apt-get update - sudo apt-get install --yes clang-format-15 - - - name: Run clang-format - if: ${{ steps.changed_files.outputs.list }} - run: | - cd sharg - git checkout ${{ github.event.pull_request.head.ref }} - echo "${{ steps.changed_files.outputs.list }}" | \ - xargs clang-format-15 --style=file:${{ github.workspace }}/.clang-format -i - - - name: Import GPG key - if: ${{ steps.changed_files.outputs.list }} - uses: crazy-max/ghaction-import-gpg@v5 - with: - workdir: sharg - gpg_private_key: ${{ secrets.SEQAN_ACTIONS_GPG_KEY }} - passphrase: ${{ secrets.SEQAN_ACTIONS_GPG_PASSPHRASE }} - git_user_signingkey: true - git_commit_gpgsign: true - - - name: Commit changes - if: ${{ steps.changed_files.outputs.list }} - uses: EndBug/add-and-commit@v9 - with: - author_name: seqan-actions[bot] - author_email: seqan-actions@users.noreply.github.com - message: '[MISC] clang-format' - cwd: './sharg' - - # Wait for 5 seconds such that workflows triggered by adding the label run on the newest commit. - - name: Defer workflow - if: ${{ steps.changed_files.outputs.list }} - run: sleep 5 - - - name: Remove label - env: - GITHUB_TOKEN: ${{ secrets.SEQAN_ACTIONS_PAT }} - PR_URL: ${{ github.event.pull_request.html_url }} - run: gh pr edit $PR_URL --remove-label "clang-format" diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yml similarity index 88% rename from .github/workflows/documentation.yaml rename to .github/workflows/documentation.yml index 91143211..c928e699 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yml @@ -12,8 +12,6 @@ concurrency: cancel-in-progress: false env: - CMAKE_VERSION: 3.16.9 - DOXYGEN_VERSION: 1.9.5 TZ: Europe/Berlin defaults: @@ -42,15 +40,15 @@ jobs: fetch-depth: 1 submodules: false - - name: Configure APT - continue-on-error: true - run: bash ./seqan3/.github/workflows/scripts/configure_apt.sh - - name: Install CMake - run: bash ./seqan3/.github/workflows/scripts/install_cmake.sh + uses: seqan/actions/setup-cmake@main + with: + cmake: 3.16.9 - name: Install Doxygen - run: bash ./seqan3/.github/workflows/scripts/install_doxygen.sh + uses: seqan/actions/setup-doxygen@main + with: + doxygen: 1.9.5 - name: Load cached documentation uses: actions/cache@v3 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..0befbe73 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,75 @@ +name: Lint + +on: + pull_request_target: + +env: + TZ: Europe/Berlin + +defaults: + run: + shell: bash -Eeuxo pipefail {0} + +jobs: + # Cancel other workflows that are dependent on this workflow by adding jobs that have the same concurrency group. + cancel_linux: + name: Cancel running Workflows + concurrency: + group: linux-${{ github.event.pull_request.number }} + cancel-in-progress: true + runs-on: ubuntu-22.04 + steps: + - name: "Cancel Linux" + run: echo "Cancelling Linux" + cancel_macos: + name: Cancel running Workflows + concurrency: + group: macos-${{ github.event.pull_request.number }} + cancel-in-progress: true + runs-on: ubuntu-22.04 + steps: + - name: "Cancel macOS" + run: echo "Cancelling macOS" + cancel_misc: + name: Cancel running Workflows + concurrency: + group: misc-${{ github.event.pull_request.number }} + cancel-in-progress: true + runs-on: ubuntu-22.04 + steps: + - name: "Cancel Misc" + run: echo "Cancelling Misc" + cancel_coverage: + name: Cancel running Workflows + concurrency: + group: coverage-${{ github.event.pull_request.number }} + cancel-in-progress: true + runs-on: ubuntu-22.04 + steps: + - name: "Cancel Coverage" + run: echo "Cancelling Coverage" + cancel_documentation: + name: Cancel running Workflows + concurrency: + group: documentation-${{ github.event.pull_request.number }} + cancel-in-progress: true + runs-on: ubuntu-22.04 + steps: + - name: "Cancel Coverage" + run: echo "Cancelling Coverage" + lint: + name: Lint + concurrency: + group: lint-${{ github.event.pull_request.number }} + cancel-in-progress: true + needs: [cancel_linux, cancel_macos, cancel_misc, cancel_coverage, cancel_documentation] + runs-on: ubuntu-22.04 + timeout-minutes: 15 + steps: + - name: Run lint + uses: seqan/actions/lint@main + with: + clang_format: 15 + token: ${{ secrets.SEQAN_ACTIONS_PAT }} + gpg_key: ${{ secrets.SEQAN_ACTIONS_GPG_KEY }} + gpg_passphrase: ${{ secrets.SEQAN_ACTIONS_GPG_PASSPHRASE }} diff --git a/.github/workflows/scripts/gcov.sh b/.github/workflows/scripts/gcov.sh new file mode 100755 index 00000000..9e38db66 --- /dev/null +++ b/.github/workflows/scripts/gcov.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +args=${@/--branch-counts/""} +args=${args/--branch-probabilities/""} + +exec gcov $args diff --git a/test/coverage/CMakeLists.txt b/test/coverage/CMakeLists.txt index 1676ae0c..a34e701e 100644 --- a/test/coverage/CMakeLists.txt +++ b/test/coverage/CMakeLists.txt @@ -27,37 +27,50 @@ set (SHARG_COVERAGE_PARALLEL_LEVEL "1" CACHE STRING "Number of threads to use for coverage report generation.") +set (SHARG_GCOVR_ARGUMENTS "") + +macro (sharg_append_gcovr_args) + set (key ${ARGV0}) + if (${ARGC} EQUAL 1) + list (APPEND SHARG_GCOVR_ARGUMENTS ${key}) + else () + string (REPLACE "'^" "\\''^" value "${ARGV1}") + string (REPLACE "$'" "$$'\\'" value "${value}") + string (REPLACE ";" "\\\\\\;" value "${value}") + list (APPEND SHARG_GCOVR_ARGUMENTS ${key} ${value}) + endif () +endmacro () + # Arguments for gcovr. # Each line is an argument, ';' will end up being a whitespace due to expansion by CMake. # Special characters like '"', '\', ')' need to be escaped by a number of '\', depending how often they are evaluated. # gcovr uses python regex expressions. # See https://gcovr.com/en/5.0/guide.html#the-gcovr-command for an overview of parameters. # See https://gcovr.com/en/5.0/faq.html#why-does-c-code-have-so-many-uncovered-branches for an explanation on branches. -set (SHARG_GCOVR_ARGUMENTS "") + # The directory of the CMakeLists.txt used for invoking cmake. -list (APPEND SHARG_GCOVR_ARGUMENTS "--root;${CMAKE_CURRENT_LIST_DIR}") +sharg_append_gcovr_args ("--root" "${CMAKE_CURRENT_LIST_DIR}") # The build directory. -list (APPEND SHARG_GCOVR_ARGUMENTS "${PROJECT_BINARY_DIR}") +sharg_append_gcovr_args ("${PROJECT_BINARY_DIR}") # Include all files whose path match '${SHARG_CLONE_DIR}/include/sharg/.*'. -list (APPEND SHARG_GCOVR_ARGUMENTS "--filter;\'${SHARG_CLONE_DIR}/include/sharg/.*\'") +sharg_append_gcovr_args ("--filter" "${SHARG_CLONE_DIR}/include/sharg") # Include all files whose path match '${SHARG_CLONE_DIR}/test/include/sharg/test/.*'. -list (APPEND SHARG_GCOVR_ARGUMENTS "--filter;\'${SHARG_CLONE_DIR}/test/include/sharg/test/.*\'") +sharg_append_gcovr_args ("--filter" "${SHARG_CLONE_DIR}/test/include/sharg/test") # Remove all files whose path match '${SHARG_CLONE_DIR}/include/sharg/contrib/.*'. -list (APPEND SHARG_GCOVR_ARGUMENTS "--exclude;\'${SHARG_CLONE_DIR}/include/sharg/contrib/.*\'") +sharg_append_gcovr_args ("--exclude" "${SHARG_CLONE_DIR}/include/sharg/contrib") # Remove all files whose path match '${SHARG_CLONE_DIR}/include/sharg/std/.*'. -list (APPEND SHARG_GCOVR_ARGUMENTS "--exclude;\'${SHARG_CLONE_DIR}/include/sharg/std/.*\'") +sharg_append_gcovr_args ("--exclude" "${SHARG_CLONE_DIR}/include/sharg/std") # Remove line coverage for all lines that match '^\s*$', i.e. empty lines. -list (APPEND SHARG_GCOVR_ARGUMENTS "--exclude-lines-by-pattern;\\\'^\\\\s*$$\\\'") +sharg_append_gcovr_args ("--exclude-lines-by-pattern" [['^\\s*$']]) # Remove line coverage for all lines that match "^\s*[\{\}]\s*\;*\s*(//.*)?$", i.e. lines with a single '{' or '}' which # might be followed by a semicolon or a comment '//'. -list (APPEND SHARG_GCOVR_ARGUMENTS - "--exclude-lines-by-pattern;\\\'^\\\\s*[\\{\\}]\\\\s*\\\\\\;*\\\\s*\\(//.*\\)?$$\\\'") +sharg_append_gcovr_args ("--exclude-lines-by-pattern" [['^\\s*[{}]{0,2}\\s*;*\\s*(//.*)?$']]) # Will exclude branches that are unreachable. -list (APPEND SHARG_GCOVR_ARGUMENTS "--exclude-unreachable-branches") +sharg_append_gcovr_args ("--exclude-unreachable-branches") # Will exclude branches that are only generated for exception handling. -list (APPEND SHARG_GCOVR_ARGUMENTS "--exclude-throw-branches") +sharg_append_gcovr_args ("--exclude-throw-branches") # Run up to this many gcov instances in parallel. -list (APPEND SHARG_GCOVR_ARGUMENTS "-j;${SHARG_COVERAGE_PARALLEL_LEVEL}") +sharg_append_gcovr_args ("-j" "${SHARG_COVERAGE_PARALLEL_LEVEL}") add_custom_command (OUTPUT ${PROJECT_BINARY_DIR}/sharg_coverage.xml # Run tests.