Skip to content

Commit 9882f05

Browse files
feat(workflows): add actionlint
1 parent 708c2a4 commit 9882f05

1 file changed

Lines changed: 40 additions & 13 deletions

File tree

.github/workflows/__call-common-lint.yml

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,30 @@ 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+
declare -A files=(
32+
[actionlint]="https://raw.githubusercontent.com/rhysd/actionlint/main/.github/actionlint-matcher.json"
33+
)
34+
35+
# TODO: add more problem matchers
36+
# clang-format: # https://github.com/jidicula/clang-format-action/issues/137#issuecomment-3043722359
37+
38+
for name in "${!files[@]}"; do
39+
url="${files[$name]}"
40+
curl -sSL "$url" -o "${name}.json"
41+
done
42+
2743
- name: Set up Python
2844
uses: actions/setup-python@v5
2945
with:
3046
python-version: '3.12'
3147

32-
- name: Install dependencies
48+
- name: Install Python dependencies
3349
run: |
50+
# shellcheck disable=SC2102 # this is triggered by the [toolchain] extra
3451
python -m pip install --upgrade \
3552
pip \
3653
setuptools \
@@ -40,6 +57,17 @@ jobs:
4057
nb-clean \
4158
nbqa[toolchain]
4259
60+
- name: Install actionlint
61+
id: get_actionlint
62+
shell: bash
63+
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
64+
65+
- name: actionlint
66+
shell: bash
67+
run: |
68+
echo "::add-matcher::.github/actionlint.json"
69+
${{ steps.get_actionlint.outputs.executable }} -color
70+
4371
- name: C++ - find files
4472
id: cpp_files
4573
run: |
@@ -72,8 +100,8 @@ jobs:
72100
73101
echo "found cpp files: ${found_files}"
74102
75-
# do not quote to keep this as a single line
76-
echo found_files=${found_files} >> $GITHUB_OUTPUT
103+
# shellcheck disable=SC2086 # do not quote to keep this as a single line
104+
echo found_files=${found_files} >> ${GITHUB_OUTPUT}
77105
78106
- name: C++ - Clang format lint
79107
if: always() && steps.cpp_files.outputs.found_files
@@ -111,8 +139,8 @@ jobs:
111139
112140
echo "found cmake files: ${found_files}"
113141
114-
# do not quote to keep this as a single line
115-
echo found_files=${found_files} >> $GITHUB_OUTPUT
142+
# shellcheck disable=SC2086 # do not quote to keep this as a single line
143+
echo found_files=${found_files} >> ${GITHUB_OUTPUT}
116144
117145
- name: CMake - cmake-lint
118146
if: always() && steps.cmake_files.outputs.found_files
@@ -127,8 +155,8 @@ jobs:
127155
128156
echo "found_files: ${found_files}"
129157
130-
# do not quote to keep this as a single line
131-
echo found_files=${found_files} >> $GITHUB_OUTPUT
158+
# shellcheck disable=SC2086 # do not quote to keep this as a single line
159+
echo found_files=${found_files} >> ${GITHUB_OUTPUT}
132160
133161
- name: Docker - hadolint
134162
if: always() && steps.docker_files.outputs.found_files
@@ -155,7 +183,7 @@ jobs:
155183
docker run --rm -i \
156184
-e "NO_COLOR=0" \
157185
-e "HADOLINT_VERBOSE=1" \
158-
-v $(pwd)/.hadolint.yaml:/.config/hadolint.yaml \
186+
-v "$(pwd)"/.hadolint.yaml:/.config/hadolint.yaml \
159187
hadolint/hadolint < $file || {
160188
failed=1
161189
failed_files="$failed_files $file"
@@ -239,15 +267,14 @@ jobs:
239267
run: |
240268
# check if Cargo.toml exists
241269
if [ -f "Cargo.toml" ]; then
242-
echo "found_cargo=true" >> $GITHUB_OUTPUT
270+
echo "found_cargo=true" >> ${GITHUB_OUTPUT}
243271
else
244-
echo "found_cargo=false" >> $GITHUB_OUTPUT
272+
echo "found_cargo=false" >> ${GITHUB_OUTPUT}
245273
fi
246274
247275
- name: Setup Rust
248276
uses: actions-rust-lang/setup-rust-toolchain@v1.13.0
249277
with:
250-
target: ${{ matrix.target }}
251278
components: 'rustfmt'
252279
cache: false
253280

@@ -272,7 +299,7 @@ jobs:
272299
fi
273300
done
274301
275-
echo "found_files=${found_files}" >> $GITHUB_OUTPUT
302+
echo "found_files=${found_files}" >> ${GITHUB_OUTPUT}
276303
277304
- name: YAML - yamllint
278305
id: yamllint
@@ -303,4 +330,4 @@ jobs:
303330

304331
- name: YAML - log
305332
if: always() && steps.yamllint.outcome == 'failure'
306-
run: cat "${{ steps.yamllint.outputs.logfile }}" >> $GITHUB_STEP_SUMMARY
333+
run: cat "${{ steps.yamllint.outputs.logfile }}" >> ${GITHUB_STEP_SUMMARY}

0 commit comments

Comments
 (0)