Skip to content

Commit 95acecb

Browse files
committed
Add actionlint checks for GitHub Actions
1 parent 3138e91 commit 95acecb

5 files changed

Lines changed: 80 additions & 29 deletions

File tree

.github/workflows/daily.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,28 @@ jobs:
8585
shell: bash
8686
run: |
8787
PACKAGES=$(python tests/get_stubtest_system_requirements.py)
88+
PACKAGE_ARGS=()
89+
while IFS= read -r package; do
90+
PACKAGE_ARGS+=("$package")
91+
done <<< "$PACKAGES"
8892
8993
if [ "${{ runner.os }}" = "Linux" ]; then
9094
if [ -n "$PACKAGES" ]; then
91-
printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
92-
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
95+
printf 'Installing APT packages:\n'
96+
printf ' %s\n' "${PACKAGE_ARGS[@]}"
97+
sudo apt-get update -q && sudo apt-get install -qy "${PACKAGE_ARGS[@]}"
9398
fi
9499
else
95100
if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then
96-
printf "Installing Homebrew packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
97-
brew install -q $PACKAGES
101+
printf 'Installing Homebrew packages:\n'
102+
printf ' %s\n' "${PACKAGE_ARGS[@]}"
103+
brew install -q "${PACKAGE_ARGS[@]}"
98104
fi
99105
100106
if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then
101-
printf "Installing Chocolatey packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
102-
choco install -y $PACKAGES
107+
printf 'Installing Chocolatey packages:\n'
108+
printf ' %s\n' "${PACKAGE_ARGS[@]}"
109+
choco install -y "${PACKAGE_ARGS[@]}"
103110
fi
104111
fi
105112
- name: Run stubtest

.github/workflows/mypy_primer.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
cd typeshed_to_test
4242
MYPY_VERSION=$(grep mypy== requirements-tests.txt | cut -d = -f 3)
4343
echo "new commit"
44-
git rev-list --format=%s --max-count=1 $GITHUB_SHA
44+
git rev-list --format=%s --max-count=1 "$GITHUB_SHA"
4545
git checkout -b upstream_main origin/main
4646
echo "base commit"
4747
git rev-list --format=%s --max-count=1 upstream_main
@@ -50,9 +50,9 @@ jobs:
5050
# fail action if exit code isn't zero or one
5151
(
5252
mypy_primer \
53-
--new v${MYPY_VERSION} --old v${MYPY_VERSION} \
53+
--new "v${MYPY_VERSION}" --old "v${MYPY_VERSION}" \
5454
--custom-typeshed-repo typeshed_to_test \
55-
--new-typeshed $GITHUB_SHA --old-typeshed upstream_main \
55+
--new-typeshed "$GITHUB_SHA" --old-typeshed upstream_main \
5656
--num-shards 6 --shard-index ${{ matrix.shard-index }} \
5757
--debug \
5858
--output concise \

.github/workflows/stubtest_third_party.yml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,39 @@ jobs:
5656
# Use the daily.yml workflow to run stubtest on all third party stubs.
5757
function find_stubs {
5858
git diff --name-only "origin/${GITHUB_BASE_REF}" HEAD | \
59-
egrep ^stubs/ | cut -d "/" -f 2 | sort -u | \
60-
(while read stub; do [ -d "stubs/$stub" ] && echo -n "$stub " || true; done)
59+
grep -E ^stubs/ | cut -d "/" -f 2 | sort -u | \
60+
(while IFS= read -r stub; do [ -d "stubs/$stub" ] && echo -n "$stub " || true; done)
6161
}
6262
STUBS=$(find_stubs || echo '')
6363
echo "Changed stubs: $STUBS"
64-
echo "STUBS=$STUBS" >> $GITHUB_ENV
64+
echo "STUBS=$STUBS" >> "$GITHUB_ENV"
6565
- name: Install required system packages
6666
shell: bash
6767
run: |
6868
if [ -n "$STUBS" ]; then
69-
PACKAGES=$(python tests/get_stubtest_system_requirements.py $STUBS)
69+
read -r -a STUB_ARGS <<< "$STUBS"
70+
PACKAGES=$(python tests/get_stubtest_system_requirements.py "${STUB_ARGS[@]}")
71+
PACKAGE_ARGS=()
72+
while IFS= read -r package; do
73+
PACKAGE_ARGS+=("$package")
74+
done <<< "$PACKAGES"
7075
if [ "${{ runner.os }}" = "Linux" ]; then
7176
if [ -n "$PACKAGES" ]; then
72-
printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
73-
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
77+
printf 'Installing APT packages:\n'
78+
printf ' %s\n' "${PACKAGE_ARGS[@]}"
79+
sudo apt-get update -q && sudo apt-get install -qy "${PACKAGE_ARGS[@]}"
7480
fi
7581
else
7682
if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then
77-
printf "Installing Homebrew packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
78-
brew install -q $PACKAGES
83+
printf 'Installing Homebrew packages:\n'
84+
printf ' %s\n' "${PACKAGE_ARGS[@]}"
85+
brew install -q "${PACKAGE_ARGS[@]}"
7986
fi
8087
8188
if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then
82-
printf "Installing Chocolatey packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
83-
choco install -y $PACKAGES
89+
printf 'Installing Chocolatey packages:\n'
90+
printf ' %s\n' "${PACKAGE_ARGS[@]}"
91+
choco install -y "${PACKAGE_ARGS[@]}"
8492
fi
8593
fi
8694
fi
@@ -89,14 +97,15 @@ jobs:
8997
run: |
9098
if [ -n "$STUBS" ]; then
9199
echo "Testing $STUBS..."
100+
read -r -a STUB_ARGS <<< "$STUBS"
92101
93102
if [ "${{ runner.os }}" = "Linux" ]; then
94103
PYTHON_EXECUTABLE="xvfb-run python"
95104
else
96105
PYTHON_EXECUTABLE="python"
97106
fi
98107
99-
$PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only $STUBS
108+
$PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only "${STUB_ARGS[@]}"
100109
else
101110
echo "Nothing to test"
102111
fi

.github/workflows/tests.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,13 @@ jobs:
6464
run: |
6565
PACKAGES=$(python tests/get_stubtest_system_requirements.py)
6666
if [ -n "$PACKAGES" ]; then
67-
printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
68-
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
67+
PACKAGE_ARGS=()
68+
while IFS= read -r package; do
69+
PACKAGE_ARGS+=("$package")
70+
done <<< "$PACKAGES"
71+
printf 'Installing APT packages:\n'
72+
printf ' %s\n' "${PACKAGE_ARGS[@]}"
73+
sudo apt-get update -q && sudo apt-get install -qy "${PACKAGE_ARGS[@]}"
6974
fi
7075
- name: Run mypy_test.py
7176
run: python ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=${{ matrix.python-version }}
@@ -117,7 +122,11 @@ jobs:
117122
run: |
118123
PACKAGES=$(python tests/get_external_stub_requirements.py)
119124
if [ -n "$PACKAGES" ]; then
120-
uv pip install --python-version ${{ matrix.python-version }} $PACKAGES
125+
PACKAGE_ARGS=()
126+
while IFS= read -r package; do
127+
PACKAGE_ARGS+=("$package")
128+
done <<< "$PACKAGES"
129+
uv pip install --python-version ${{ matrix.python-version }} "${PACKAGE_ARGS[@]}"
121130
fi
122131
# Published stub packages can shadow the checked-in stubs when ty
123132
# resolves their relative imports.
@@ -152,7 +161,11 @@ jobs:
152161
run: |
153162
PACKAGES=$(python tests/get_external_stub_requirements.py)
154163
if [ -n "$PACKAGES" ]; then
155-
uv pip install --python-version ${{ matrix.python-version }} $PACKAGES
164+
PACKAGE_ARGS=()
165+
while IFS= read -r package; do
166+
PACKAGE_ARGS+=("$package")
167+
done <<< "$PACKAGES"
168+
uv pip install --python-version ${{ matrix.python-version }} "${PACKAGE_ARGS[@]}"
156169
fi
157170
# Published stub packages can shadow the checked-in stubs when pyrefly
158171
# resolves their relative imports.
@@ -187,20 +200,30 @@ jobs:
187200
run: |
188201
PACKAGES=$(python tests/get_stubtest_system_requirements.py)
189202
if [ -n "$PACKAGES" ]; then
190-
printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
191-
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
203+
PACKAGE_ARGS=()
204+
while IFS= read -r package; do
205+
PACKAGE_ARGS+=("$package")
206+
done <<< "$PACKAGES"
207+
printf 'Installing APT packages:\n'
208+
printf ' %s\n' "${PACKAGE_ARGS[@]}"
209+
sudo apt-get update -q && sudo apt-get install -qy "${PACKAGE_ARGS[@]}"
192210
fi
193211
- name: Create an isolated venv for testing
194212
run: uv venv .venv
195213
- name: Install 3rd-party stub dependencies
196214
run: |
197215
PACKAGES=$(python tests/get_external_stub_requirements.py)
198216
if [ -n "$PACKAGES" ]; then
199-
printf "Installing python packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
200-
uv pip install --python-version ${{ matrix.python-version }} $PACKAGES
217+
PACKAGE_ARGS=()
218+
while IFS= read -r package; do
219+
PACKAGE_ARGS+=("$package")
220+
done <<< "$PACKAGES"
221+
printf 'Installing python packages:\n'
222+
printf ' %s\n' "${PACKAGE_ARGS[@]}"
223+
uv pip install --python-version ${{ matrix.python-version }} "${PACKAGE_ARGS[@]}"
201224
fi
202225
- name: Activate the isolated venv for the rest of the job
203-
run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
226+
run: echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
204227
- name: List 3rd-party stub dependencies installed
205228
run: uv pip freeze
206229
- name: Run pyright with basic settings on all the stubs

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ repos:
4848
rev: 451b56af716f9f0d0c2b816503a3fd0cf8b036fa # frozen: v1.29.0
4949
hooks:
5050
- id: zizmor
51+
# `actionlint` hook, for verifying correct syntax in GitHub Actions workflows.
52+
- repo: https://github.com/rhysd/actionlint
53+
rev: 914e7df21a07ef503a81201c76d2b11c789d3fca # frozen: v1.7.12
54+
hooks:
55+
- id: actionlint
56+
# specifying this means renovate will also update `additional_dependencies`
57+
language: golang
58+
additional_dependencies:
59+
# actionlint has a shellcheck integration which extracts shell scripts in `run:` steps from GitHub Actions
60+
# and checks these with shellcheck. This is arguably its most useful feature,
61+
# but the integration only works if shellcheck is installed
62+
- "github.com/wasilibs/go-shellcheck/cmd/shellcheck@v0.11.1"
5163

5264
ci:
5365
autofix_commit_msg: "[pre-commit.ci] auto fixes from pre-commit.com hooks"

0 commit comments

Comments
 (0)