From 114b45cf43dbbfc3b422d6f0ddd7b5fd00e6c1be Mon Sep 17 00:00:00 2001 From: Leon Oostrum Date: Tue, 5 Sep 2023 13:21:11 +0200 Subject: [PATCH] Suggestion: improve CI runtime (#199) * Remove conda from ci * Install cuda with action; use CI runner compiler versions. TODO: ensure correct version of clang tools are used * Fix cuda install action version * Reduce size of cuda install as much as possible; set cuda version to 12.2 * Fix workflow syntax * Add required cuda subpackages * Move libcufft to other installer arg * Install dev versions of nvrtc and cufft * add cublas * Install precommit in CI * Temporarily force run all pre commit tools * Install cppcheck, run verison check * Don't let cppcheck complain about system includes it cannot find * Print more tool versions * Install cmake-{lint,format} in CI * Make sure versions are the same in CI and env; properly install cmakelang * Remove libcublas from CI; takes a while and seems like we don't actually need it * make cppcheck stop complain about unmatched suppression unreadVariable * Add tool names to version prints; revert to proper pre-commit run --- .github/workflows/pre-commit.yml | 45 +++++++++++++++++++++----------- .pre-commit-config.yaml | 4 ++- environment.yml | 10 +++---- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 25e0fec1..587f9612 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -1,5 +1,4 @@ name: pre-commit -# conda cache setup based on https://github.com/epassaro/cache-conda-envs on: push: @@ -9,6 +8,15 @@ jobs: linting: name: run runs-on: ubuntu-latest + env: + # set tools versions to latest supported by the CI runner, + # ubuntu 22.04 at the time of writing + # clang defaults to v14.0.0 + gcc-version: "12" # = 12.1.0 + # cuda version to install with separate action + cuda-version: "12.2.0" + # version for cmake-lint and cmake-format + cmakelang-version: "0.6.13" steps: - name: Show git version @@ -44,27 +52,34 @@ jobs: git checkout ${{ env.precommit_from_ref }} git checkout ${{ env.precommit_to_ref }} - - name: Setup environment with Mamba - uses: conda-incubator/setup-miniconda@v2 + - name: Install cuda + uses: Jimver/cuda-toolkit@v0.2.11 with: - mamba-version: "*" - channels: conda-forge - activate-environment: recruit + cuda: ${{ env.cuda-version }} + method: "network" + sub-packages: '["nvcc", "nvrtc-dev", "nvtx"]' + non-cuda-sub-packages: '["libcufft-dev"]' + linux-local-args: '["--toolkit"]' - - uses: actions/cache@v2 - with: - path: /usr/share/miniconda/envs/recruit - key: conda-${{ hashFiles('environment.yml') }} - id: cache + - name: Install pre-commit and related tools + run: | + pip install pre-commit cmakelang==${{ env.cmakelang-version}} + sudo apt install cppcheck -y - - name: Update mamba environment if cache is outdated - if: steps.cache.outputs.cache-hit != 'true' - run: mamba env update -n recruit -f environment.yml + - name: Show tool versions + run: | + echo "nvcc: $(nvcc --version)" + echo "g++: $(g++-${{ env.gcc-version}} --version)" + echo "clang-format: $(clang-format --version)" + echo "clang-tidy: $(clang-tidy --version)" + echo "cppcheck: $(cppcheck --version)" + echo "cmake-lint: $(cmake-lint --version)" + echo "cmake-format: $(cmake-format --version)" - name: Generate compilation database shell: bash -el {0} run: | - cmake -DCMAKE_CXX_COMPILER=clang++ -DCUDAWRAPPERS_BUILD_TESTING=True -DCUDAWRAPPERS_BUILD_EXAMPLES=True -S . -B build + cmake -DCMAKE_CXX_COMPILER=g++-${{ env.gcc-version }} -DCUDAWRAPPERS_BUILD_TESTING=True -DCUDAWRAPPERS_BUILD_EXAMPLES=True -S . -B build - name: Run pre-commit on all files changed in this branch using project standard configuration shell: bash -el {0} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 76fb311a..e61c584a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v16.0.6 + rev: v14.0.0 hooks: - id: clang-format - repo: https://github.com/pocc/pre-commit-hooks @@ -12,6 +12,8 @@ repos: - '--suppress=*:build/*' - '--suppress=unusedFunction:*/*' - '--suppress=unreadVariable:tests/*' + - '--suppress=missingIncludeSystem' + - '--suppress=unmatchedSuppression' - repo: https://github.com/cheshirekow/cmake-format-precommit rev: v0.6.13 hooks: diff --git a/environment.yml b/environment.yml index 0bf90d9e..e99c451b 100644 --- a/environment.yml +++ b/environment.yml @@ -3,11 +3,11 @@ channels: - conda-forge dependencies: - c-compiler - - clang==16.0.6 - - clang-tools==16.0.6 + - clang==14.0.0 + - clang-tools==14.0.0 - cmake>=3.17 - - cppcheck==2.10.3 - - cudatoolkit-dev>=10.0 + - cppcheck==2.7.5 + - cudatoolkit-dev==12.2.0 - cxx-compiler - doxygen - gcovr @@ -19,6 +19,6 @@ dependencies: - pip: - pre-commit - bump2version==1.0.1 - - clang-format==16.0.6 + - clang-format==14.0.0 - cmakelang==0.6.13 - flawfinder==2.0.19