@@ -24,24 +24,74 @@ jobs:
2424 - name : Checkout
2525 uses : actions/checkout@v4
2626
27+ - name : Download problem matchers
28+ shell : bash
29+ working-directory : .github
30+ run : |
31+ mkdir -p problem-matchers
32+ cd problem-matchers
33+
34+ gh_base_url="https://raw.githubusercontent.com/LizardByte/.github/refs/heads"
35+ gh_branch="feat/workflows/add-actionlint"
36+ gh_path="${gh_base_url}/${gh_branch}/.github/problem-matchers"
37+
38+ declare -A files=(
39+ [actionlint]="https://raw.githubusercontent.com/rhysd/actionlint/main/.github/actionlint-matcher.json"
40+ [cargo-fmt]="${gh_path}/cargo-fmt.json"
41+ [clang-format]="${gh_path}/clang-format.json"
42+ [cmake-lint]="${gh_path}/cmake-lint.json"
43+ [gcc]="${gh_path}/gcc.json"
44+ [hadolint]="${gh_path}/hadolint.json"
45+ [pytest]="${gh_path}/pytest.json"
46+ [yamllint]="${gh_path}/yamllint.json"
47+ )
48+
49+ for name in "${!files[@]}"; do
50+ if [ ! -f "${name}.json" ]; then
51+ echo "Downloading ${name}.json"
52+ url="${files[$name]}"
53+ curl -sSL "$url" -o "${name}.json"
54+ else
55+ echo "Skipping download of ${name}.json, already exists"
56+ continue
57+ fi
58+ done
59+
2760 - name : Set up Python
2861 uses : actions/setup-python@v5
2962 with :
3063 python-version : ' 3.12'
3164
32- - name : Install dependencies
65+ - name : Install Python dependencies
3366 run : |
67+ # shellcheck disable=SC2102 # this is triggered by the [toolchain] extra
3468 python -m pip install --upgrade \
3569 pip \
3670 setuptools \
3771 wheel \
3872 cmakelang \
3973 flake8 \
74+ flake8-github-annotations \
4075 nb-clean \
41- nbqa[toolchain]
76+ nbqa[toolchain] \
77+ yamllint
78+
79+ - name : Install actionlint
80+ id : get_actionlint
81+ shell : bash
82+ run : bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
83+
84+ - name : actionlint
85+ shell : bash
86+ if : always()
87+ run : |
88+ echo "::add-matcher::.github/problem-matchers/actionlint.json"
89+ ${{ steps.get_actionlint.outputs.executable }} -color
90+ echo "::remove-matcher owner=actionlint::"
4291
4392 - name : C++ - find files
4493 id : cpp_files
94+ if : always()
4595 run : |
4696 # find files
4797 found_files=$(find . -type f \
@@ -72,9 +122,10 @@ jobs:
72122
73123 echo "found cpp files: ${found_files}"
74124
75- # do not quote to keep this as a single line
76- echo found_files=${found_files} >> $ GITHUB_OUTPUT
125+ # shellcheck disable=SC2086 # do not quote to keep this as a single line
126+ echo found_files=${found_files} >> "${ GITHUB_OUTPUT}"
77127
128+ - run : echo "::add-matcher::.github/problem-matchers/clang-format.json"
78129 - name : C++ - Clang format lint
79130 if : always() && steps.cpp_files.outputs.found_files
80131 uses : DoozyX/clang-format-lint-action@v0.20
84135 extensions : ' c,cpp,h,hpp,m,mm'
85136 style : file
86137 inplace : false
138+ - run : echo "::remove-matcher owner=clang-format::"
87139
88140 - name : CMake - find files
89141 id : cmake_files
@@ -111,13 +163,15 @@ jobs:
111163
112164 echo "found cmake files: ${found_files}"
113165
114- # do not quote to keep this as a single line
115- echo found_files=${found_files} >> $ GITHUB_OUTPUT
166+ # shellcheck disable=SC2086 # do not quote to keep this as a single line
167+ echo found_files=${found_files} >> "${ GITHUB_OUTPUT}"
116168
117169 - name : CMake - cmake-lint
118170 if : always() && steps.cmake_files.outputs.found_files
119171 run : |
172+ echo "::add-matcher::.github/problem-matchers/cmake-lint.json"
120173 cmake-lint --line-width 120 --tab-size 4 ${{ steps.cmake_files.outputs.found_files }}
174+ echo "::remove-matcher owner=cmake-lint::"
121175
122176 - name : Docker - find files
123177 id : docker_files
@@ -127,8 +181,8 @@ jobs:
127181
128182 echo "found_files: ${found_files}"
129183
130- # do not quote to keep this as a single line
131- echo found_files=${found_files} >> $ GITHUB_OUTPUT
184+ # shellcheck disable=SC2086 # do not quote to keep this as a single line
185+ echo found_files=${found_files} >> "${ GITHUB_OUTPUT}"
132186
133187 - name : Docker - hadolint
134188 if : always() && steps.docker_files.outputs.found_files
@@ -150,18 +204,20 @@ jobs:
150204 failed=0
151205 failed_files=""
152206
207+ echo "::add-matcher::.github/problem-matchers/hadolint.json"
153208 for file in ${{ steps.docker_files.outputs.found_files }}; do
154209 echo "::group::${file}"
155210 docker run --rm -i \
156211 -e "NO_COLOR=0" \
157212 -e "HADOLINT_VERBOSE=1" \
158- -v $(pwd)/.hadolint.yaml:/.config/hadolint.yaml \
213+ -v " $(pwd)" /.hadolint.yaml:/.config/hadolint.yaml \
159214 hadolint/hadolint < $file || {
160215 failed=1
161216 failed_files="$failed_files $file"
162217 }
163218 echo "::endgroup::"
164219 done
220+ echo "::remove-matcher owner=hadolint::"
165221
166222 if [ $failed -ne 0 ]; then
167223 echo "::error:: hadolint failed for the following files: $failed_files"
@@ -211,7 +267,7 @@ jobs:
211267 if : always()
212268 run : |
213269 python -m flake8 \
214- --color=always \
270+ --format github \
215271 --verbose
216272
217273 - name : Python - nbqa flake8
@@ -239,21 +295,23 @@ jobs:
239295 run : |
240296 # check if Cargo.toml exists
241297 if [ -f "Cargo.toml" ]; then
242- echo "found_cargo=true" >> $ GITHUB_OUTPUT
298+ echo "found_cargo=true" >> "${ GITHUB_OUTPUT}"
243299 else
244- echo "found_cargo=false" >> $ GITHUB_OUTPUT
300+ echo "found_cargo=false" >> "${ GITHUB_OUTPUT}"
245301 fi
246302
247303 - name : Setup Rust
248304 uses : actions-rust-lang/setup-rust-toolchain@v1.13.0
249305 with :
250- target : ${{ matrix.target }}
251306 components : ' rustfmt'
252307 cache : false
253308
254309 - name : Rust - cargo fmt
255310 if : always() && steps.run_cargo.outputs.found_cargo == 'true'
256- run : cargo fmt -- --check
311+ run : |
312+ echo "::add-matcher::.github/problem-matchers/cargo-fmt.json"
313+ cargo fmt -- --check
314+ echo "::remove-matcher owner=cargo-fmt::"
257315
258316 - name : YAML - find files
259317 id : yaml_files
@@ -272,35 +330,21 @@ jobs:
272330 fi
273331 done
274332
275- echo "found_files=${found_files}" >> $ GITHUB_OUTPUT
333+ echo "found_files=${found_files}" >> "${ GITHUB_OUTPUT}"
276334
277335 - name : YAML - yamllint
278336 id : yamllint
279337 if : always()
280- uses : ibiqlik/action-yamllint@v3
281- with :
282- # https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration
283- config_data : |
284- extends: default
285- rules:
286- comments:
287- level: error
288- document-start:
289- level: error
290- line-length:
291- max: 120
292- new-line-at-end-of-file:
293- level: error
294- new-lines:
295- type: unix
296- truthy:
297- # GitHub uses "on" for workflow event triggers
298- # .clang-format file has options of "Yes" "No" that will be caught by this, so changed to "warning"
299- allowed-values: ['true', 'false', 'on']
300- check-keys: true
301- level: warning
302- file_or_dir : . ${{ steps.yaml_files.outputs.found_files }}
303-
304- - name : YAML - log
305- if : always() && steps.yamllint.outcome == 'failure'
306- run : cat "${{ steps.yamllint.outputs.logfile }}" >> $GITHUB_STEP_SUMMARY
338+ run : |
339+ if [ ! -f .yamllint.yml ]; then
340+ curl -sSL https://raw.githubusercontent.com/LizardByte/.github/master/.yamllint.yml -o .yamllint.yml
341+ fi
342+
343+ echo "::add-matcher::.github/problem-matchers/yamllint.json"
344+ yamllint \
345+ --config-file .yamllint.yml \
346+ --format=standard \
347+ --strict \
348+ . ${{ steps.yaml_files.outputs.found_files }}
349+
350+ echo "::remove-matcher owner=yamllint::"
0 commit comments