-
Notifications
You must be signed in to change notification settings - Fork 5
91 lines (78 loc) · 3.17 KB
/
pre-commit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: pre-commit
on:
push:
workflow_dispatch:
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
clang-format-version: "v18.1.4"
cmake-format-version: "v0.6.13"
steps:
- name: Show git version
run: |
which git
git --version
- name: Check out a copy of the repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Show some relevant env vars
run: |
echo "GITHUB_BASE_REF = $GITHUB_BASE_REF"
echo "GITHUB_HEAD_REF = $GITHUB_HEAD_REF"
echo "GITHUB_REF_NAME = $GITHUB_REF_NAME"
- name: Set the target and source refs if the trigger was a pull request
if: ${{ github.event_name == 'pull_request' }}
run: |
echo "precommit_from_ref=$GITHUB_BASE_REF" >> $GITHUB_ENV
echo "precommit_to_ref=$GITHUB_HEAD_REF" >> $GITHUB_ENV
- name: Set the target and source refs if the trigger was not a pull request
if: ${{ github.event_name != 'pull_request' }}
run: |
echo "precommit_from_ref=main" >> $GITHUB_ENV
echo "precommit_to_ref=$GITHUB_REF_NAME" >> $GITHUB_ENV
- name: Avoid problems with missing refs later
run: |
git checkout ${{ env.precommit_from_ref }}
git checkout ${{ env.precommit_to_ref }}
- name: Install cuda
uses: Jimver/cuda-toolkit@v0.2.11
with:
cuda: ${{ env.cuda-version }}
method: "network"
sub-packages: '["nvcc", "nvml-dev", "nvrtc-dev", "nvtx"]'
non-cuda-sub-packages: '["libcufft-dev"]'
linux-local-args: '["--toolkit"]'
- name: Install pre-commit and related tools
run: |
pip install pre-commit
pip install clang-format==${{env.clang-format-version}}
pip install cmake-format==${{env.cmake-format-version}}
sudo apt install cppcheck -y
- 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=g++-${{ env.gcc-version }} -DCUDAWRAPPERS_BUILD_TESTING=True -S . -B build
- name: Run pre-commit on all files changed in this branch using project standard configuration
shell: bash -el {0}
run: |
git diff --name-only ${{ env.precommit_from_ref }}...${{ env.precommit_to_ref }}
pre-commit run --from-ref ${{ env.precommit_from_ref }} --to-ref ${{ env.precommit_to_ref }}