Skip to content

Commit 1f82392

Browse files
committed
Simplify intentional word splitting in workflows
1 parent df09499 commit 1f82392

3 files changed

Lines changed: 28 additions & 36 deletions

File tree

‎.github/workflows/daily.yml‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,28 +85,26 @@ 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"
9288
89+
# System package names contain no whitespace or glob characters, so word splitting is intentional.
90+
# shellcheck disable=SC2086
9391
if [ "${{ runner.os }}" = "Linux" ]; then
9492
if [ -n "$PACKAGES" ]; then
9593
printf 'Installing APT packages:\n'
96-
printf ' %s\n' "${PACKAGE_ARGS[@]}"
97-
sudo apt-get update -q && sudo apt-get install -qy "${PACKAGE_ARGS[@]}"
94+
printf ' %s\n' $PACKAGES
95+
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
9896
fi
9997
else
10098
if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then
10199
printf 'Installing Homebrew packages:\n'
102-
printf ' %s\n' "${PACKAGE_ARGS[@]}"
103-
brew install -q "${PACKAGE_ARGS[@]}"
100+
printf ' %s\n' $PACKAGES
101+
brew install -q $PACKAGES
104102
fi
105103
106104
if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then
107105
printf 'Installing Chocolatey packages:\n'
108-
printf ' %s\n' "${PACKAGE_ARGS[@]}"
109-
choco install -y "${PACKAGE_ARGS[@]}"
106+
printf ' %s\n' $PACKAGES
107+
choco install -y $PACKAGES
110108
fi
111109
fi
112110
- name: Run stubtest

‎.github/workflows/stubtest_third_party.yml‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,30 +65,27 @@ jobs:
6565
- name: Install required system packages
6666
shell: bash
6767
run: |
68+
# System package and stub directory names contain no whitespace or glob characters; split both lists into arguments.
69+
# shellcheck disable=SC2086
6870
if [ -n "$STUBS" ]; then
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"
71+
PACKAGES=$(python tests/get_stubtest_system_requirements.py $STUBS)
7572
if [ "${{ runner.os }}" = "Linux" ]; then
7673
if [ -n "$PACKAGES" ]; then
7774
printf 'Installing APT packages:\n'
78-
printf ' %s\n' "${PACKAGE_ARGS[@]}"
79-
sudo apt-get update -q && sudo apt-get install -qy "${PACKAGE_ARGS[@]}"
75+
printf ' %s\n' $PACKAGES
76+
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
8077
fi
8178
else
8279
if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then
8380
printf 'Installing Homebrew packages:\n'
84-
printf ' %s\n' "${PACKAGE_ARGS[@]}"
85-
brew install -q "${PACKAGE_ARGS[@]}"
81+
printf ' %s\n' $PACKAGES
82+
brew install -q $PACKAGES
8683
fi
8784
8885
if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then
8986
printf 'Installing Chocolatey packages:\n'
90-
printf ' %s\n' "${PACKAGE_ARGS[@]}"
91-
choco install -y "${PACKAGE_ARGS[@]}"
87+
printf ' %s\n' $PACKAGES
88+
choco install -y $PACKAGES
9289
fi
9390
fi
9491
fi
@@ -97,15 +94,16 @@ jobs:
9794
run: |
9895
if [ -n "$STUBS" ]; then
9996
echo "Testing $STUBS..."
100-
read -r -a STUB_ARGS <<< "$STUBS"
10197
10298
if [ "${{ runner.os }}" = "Linux" ]; then
10399
PYTHON_EXECUTABLE="xvfb-run python"
104100
else
105101
PYTHON_EXECUTABLE="python"
106102
fi
107103
108-
$PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only "${STUB_ARGS[@]}"
104+
# Stub directory names contain no whitespace or glob characters, so word splitting is intentional.
105+
# shellcheck disable=SC2086
106+
$PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only $STUBS
109107
else
110108
echo "Nothing to test"
111109
fi

‎.github/workflows/tests.yml‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,12 @@ jobs:
6363
- name: Install required APT packages
6464
run: |
6565
PACKAGES=$(python tests/get_stubtest_system_requirements.py)
66+
# System package names contain no whitespace or glob characters, so word splitting is intentional.
67+
# shellcheck disable=SC2086
6668
if [ -n "$PACKAGES" ]; then
67-
PACKAGE_ARGS=()
68-
while IFS= read -r package; do
69-
PACKAGE_ARGS+=("$package")
70-
done <<< "$PACKAGES"
7169
printf 'Installing APT packages:\n'
72-
printf ' %s\n' "${PACKAGE_ARGS[@]}"
73-
sudo apt-get update -q && sudo apt-get install -qy "${PACKAGE_ARGS[@]}"
70+
printf ' %s\n' $PACKAGES
71+
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
7472
fi
7573
- name: Run mypy_test.py
7674
run: python ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=${{ matrix.python-version }}
@@ -199,14 +197,12 @@ jobs:
199197
- name: Install required APT packages
200198
run: |
201199
PACKAGES=$(python tests/get_stubtest_system_requirements.py)
200+
# System package names contain no whitespace or glob characters, so word splitting is intentional.
201+
# shellcheck disable=SC2086
202202
if [ -n "$PACKAGES" ]; then
203-
PACKAGE_ARGS=()
204-
while IFS= read -r package; do
205-
PACKAGE_ARGS+=("$package")
206-
done <<< "$PACKAGES"
207203
printf 'Installing APT packages:\n'
208-
printf ' %s\n' "${PACKAGE_ARGS[@]}"
209-
sudo apt-get update -q && sudo apt-get install -qy "${PACKAGE_ARGS[@]}"
204+
printf ' %s\n' $PACKAGES
205+
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
210206
fi
211207
- name: Create an isolated venv for testing
212208
run: uv venv .venv

0 commit comments

Comments
 (0)