Skip to content

Commit 887d794

Browse files
authored
Run shellcheck on GitHub Actions run steps as part of pre-commit (#624)
1 parent 01c0bfd commit 887d794

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

.github/workflows/publish.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ jobs:
6363
path: dist/
6464
- name: Install wheel
6565
run: |
66-
export path_to_file=$(find dist -type f -name "typing_extensions-*.whl")
66+
path_to_file="$(find dist -type f -name "typing_extensions-*.whl")"
67+
export path_to_file
6768
echo "::notice::Installing wheel: $path_to_file"
68-
python -m pip install --user $path_to_file
69+
python -m pip install --user "$path_to_file"
6970
python -m pip list
7071
- name: Run typing_extensions tests against installed package
7172
run: rm src/typing_extensions.py && python src/test_typing_extensions.py
@@ -89,10 +90,11 @@ jobs:
8990
path: dist/
9091
- name: Unpack and test source distribution
9192
run: |
92-
export path_to_file=$(find dist -type f -name "typing_extensions-*.tar.gz")
93+
path_to_file="$(find dist -type f -name "typing_extensions-*.tar.gz")"
94+
export path_to_file
9395
echo "::notice::Unpacking source distribution: $path_to_file"
94-
tar xzf $path_to_file -C dist/
95-
cd ${path_to_file%.tar.gz}/src
96+
tar xzf "$path_to_file" -C dist/
97+
cd "${path_to_file%.tar.gz}/src"
9698
python test_typing_extensions.py
9799
98100
test-sdist-installed:
@@ -114,9 +116,10 @@ jobs:
114116
path: dist/
115117
- name: Install source distribution
116118
run: |
117-
export path_to_file=$(find dist -type f -name "typing_extensions-*.tar.gz")
119+
path_to_file="$(find dist -type f -name "typing_extensions-*.tar.gz")"
120+
export path_to_file
118121
echo "::notice::Installing source distribution: $path_to_file"
119-
python -m pip install --user $path_to_file
122+
python -m pip install --user "$path_to_file"
120123
python -m pip list
121124
- name: Run typing_extensions tests against installed package
122125
run: rm src/typing_extensions.py && python src/test_typing_extensions.py
@@ -144,6 +147,6 @@ jobs:
144147
name: python-package-distributions
145148
path: dist/
146149
- name: Ensure exactly one sdist and one wheel have been downloaded
147-
run: test $(ls dist/*.tar.gz | wc -l) = 1 && test $(ls dist/*.whl | wc -l) = 1
150+
run: test "$(find dist/*.tar.gz | wc -l | xargs)" = 1 && test "$(find dist/*.whl | wc -l | xargs)" = 1
148151
- name: Publish distribution to PyPI
149152
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/third_party.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ jobs:
9898
run: |
9999
set -x
100100
cd typing_inspect
101-
uv pip install --system -r test-requirements.txt --exclude-newer $(git show -s --date=format:'%Y-%m-%dT%H:%M:%SZ' --format=%cd HEAD)
101+
uv pip install --system -r test-requirements.txt --exclude-newer "$(git show -s --date=format:'%Y-%m-%dT%H:%M:%SZ' --format=%cd HEAD)"
102102
- name: Install typing_extensions latest
103103
run: uv pip install --system "typing-extensions @ ./typing-extensions-latest"
104104
- name: List all installed dependencies
@@ -135,7 +135,7 @@ jobs:
135135
run: |
136136
set -x
137137
cd pycroscope
138-
uv pip install --system 'pycroscope[tests] @ .' --exclude-newer $(git show -s --date=format:'%Y-%m-%dT%H:%M:%SZ' --format=%cd HEAD)
138+
uv pip install --system 'pycroscope[tests] @ .' --exclude-newer "$(git show -s --date=format:'%Y-%m-%dT%H:%M:%SZ' --format=%cd HEAD)"
139139
- name: Install typing_extensions latest
140140
run: uv pip install --system "typing-extensions @ ./typing-extensions-latest"
141141
- name: List all installed dependencies
@@ -172,7 +172,7 @@ jobs:
172172
run: |
173173
set -x
174174
cd typeguard
175-
uv pip install --system "typeguard @ ." --group test --exclude-newer $(git show -s --date=format:'%Y-%m-%dT%H:%M:%SZ' --format=%cd HEAD)
175+
uv pip install --system "typeguard @ ." --group test --exclude-newer "$(git show -s --date=format:'%Y-%m-%dT%H:%M:%SZ' --format=%cd HEAD)"
176176
- name: Install typing_extensions latest
177177
run: uv pip install --system "typing-extensions @ ./typing-extensions-latest"
178178
- name: List all installed dependencies
@@ -215,8 +215,8 @@ jobs:
215215
run: |
216216
set -x
217217
cd typed-argument-parser
218-
uv pip install --system "typed-argument-parser @ ." --exclude-newer $(git show -s --date=format:'%Y-%m-%dT%H:%M:%SZ' --format=%cd HEAD)
219-
uv pip install --system pytest --exclude-newer $(git show -s --date=format:'%Y-%m-%dT%H:%M:%SZ' --format=%cd HEAD)
218+
uv pip install --system "typed-argument-parser @ ." --exclude-newer "$(git show -s --date=format:'%Y-%m-%dT%H:%M:%SZ' --format=%cd HEAD)"
219+
uv pip install --system pytest --exclude-newer "$(git show -s --date=format:'%Y-%m-%dT%H:%M:%SZ' --format=%cd HEAD)"
220220
- name: Install typing_extensions latest
221221
run: uv pip install --system "typing-extensions @ ./typing-extensions-latest"
222222
- name: List all installed dependencies
@@ -253,7 +253,7 @@ jobs:
253253
run: |
254254
set -x
255255
cd mypy
256-
uv pip install --system -r test-requirements.txt --exclude-newer $(git show -s --date=format:'%Y-%m-%dT%H:%M:%SZ' --format=%cd HEAD)
256+
uv pip install --system -r test-requirements.txt --exclude-newer "$(git show -s --date=format:'%Y-%m-%dT%H:%M:%SZ' --format=%cd HEAD)"
257257
uv pip install --system -e .
258258
- name: Install typing_extensions latest
259259
run: uv pip install --system "typing-extensions @ ./typing-extensions-latest"

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ repos:
3232
rev: v1.7.7
3333
hooks:
3434
- id: actionlint
35+
additional_dependencies:
36+
# actionlint has a shellcheck integration which extracts shell scripts in `run:` steps from GitHub Actions
37+
# and checks these with shellcheck. This is arguably its most useful feature,
38+
# but the integration only works if shellcheck is installed
39+
- "github.com/wasilibs/go-shellcheck/cmd/[email protected]"
3540
- repo: meta
3641
hooks:
3742
- id: check-hooks-apply

0 commit comments

Comments
 (0)