Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint GitHub Actions workflows

on:
workflow_dispatch:
push:
branches:
- main
paths:
- ".github/workflows/**"
pull_request:
paths:
- ".github/workflows/**"

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
with:
persist-credentials: false
- name: Run actionlint
# The official image includes ShellCheck and Pyflakes.
Comment thread
AlexWaygood marked this conversation as resolved.
Resolved
uses: docker://rhysd/actionlint:1.7.12@sha256:b1934ee5f1c509618f2508e6eb47ee0d3520686341fec936f3b79331f9315667
with:
args: -color -verbose
19 changes: 13 additions & 6 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,28 @@ jobs:
shell: bash
run: |
PACKAGES=$(python tests/get_stubtest_system_requirements.py)
PACKAGE_ARGS=()
while IFS= read -r package; do
PACKAGE_ARGS+=("$package")
done <<< "$PACKAGES"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? I assume this was flagged due to white space handling. But since package names can not contain white space, I think this only complicates the action unnecessarily and makes it harder to understand and verify its correctness.

(Same pattern a few times below.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there were a huge number of SC2086 errors reported on our workflows:

Details
.github/workflows/tests.yml:64:9: shellcheck reported issue in this script: SC2086:info:3:46: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/tests.yml:64:9: shellcheck reported issue in this script: SC2086:info:4:54: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/tests.yml:117:9: shellcheck reported issue in this script: SC2086:info:3:64: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/tests.yml:152:9: shellcheck reported issue in this script: SC2086:info:3:64: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/tests.yml:187:9: shellcheck reported issue in this script: SC2086:info:3:46: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/tests.yml:187:9: shellcheck reported issue in this script: SC2086:info:4:54: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/tests.yml:196:9: shellcheck reported issue in this script: SC2086:info:3:51: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/tests.yml:196:9: shellcheck reported issue in this script: SC2086:info:4:66: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/tests.yml:203:9: shellcheck reported issue in this script: SC2086:info:1:26: Double quote to prevent globbing and word splitting [shellcheck]

.github/workflows/stubtest_third_party.yml:54:9: shellcheck reported issue in this script: SC2086:info:10:24: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/stubtest_third_party.yml:67:9: shellcheck reported issue in this script: SC2086:info:10:55: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/stubtest_third_party.yml:67:9: shellcheck reported issue in this script: SC2086:info:11:23: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/stubtest_third_party.yml:67:9: shellcheck reported issue in this script: SC2086:info:15:57: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/stubtest_third_party.yml:67:9: shellcheck reported issue in this script: SC2086:info:16:24: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/stubtest_third_party.yml:67:9: shellcheck reported issue in this script: SC2086:info:2:63: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/stubtest_third_party.yml:67:9: shellcheck reported issue in this script: SC2086:info:5:50: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/stubtest_third_party.yml:67:9: shellcheck reported issue in this script: SC2086:info:6:58: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/stubtest_third_party.yml:89:9: shellcheck reported issue in this script: SC2086:info:10:72: Double quote to prevent globbing and word splitting [shellcheck]

.github/workflows/mypy_primer.yml:40:9: shellcheck reported issue in this script: SC2086:info:13:10: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/mypy_primer.yml:40:9: shellcheck reported issue in this script: SC2086:info:13:33: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/mypy_primer.yml:40:9: shellcheck reported issue in this script: SC2086:info:15:18: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/mypy_primer.yml:40:9: shellcheck reported issue in this script: SC2086:info:4:40: Double quote to prevent globbing and word splitting [shellcheck]

.github/workflows/daily.yml:86:9: shellcheck reported issue in this script: SC2086:info:10:53: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/daily.yml:86:9: shellcheck reported issue in this script: SC2086:info:11:21: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/daily.yml:86:9: shellcheck reported issue in this script: SC2086:info:15:55: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/daily.yml:86:9: shellcheck reported issue in this script: SC2086:info:16:22: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/daily.yml:86:9: shellcheck reported issue in this script: SC2086:info:5:48: Double quote to prevent globbing and word splitting [shellcheck]
.github/workflows/daily.yml:86:9: shellcheck reported issue in this script: SC2086:info:6:56: Double quote to prevent globbing and word splitting [shellcheck]

I'm reverting most of the changes you're talking about; I agree they made things less readable for a purely theoretical problem. Sorry about that.


if [ "${{ runner.os }}" = "Linux" ]; then
if [ -n "$PACKAGES" ]; then
printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
printf 'Installing APT packages:\n'
printf ' %s\n' "${PACKAGE_ARGS[@]}"
sudo apt-get update -q && sudo apt-get install -qy "${PACKAGE_ARGS[@]}"
fi
else
if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then
printf "Installing Homebrew packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
brew install -q $PACKAGES
printf 'Installing Homebrew packages:\n'
printf ' %s\n' "${PACKAGE_ARGS[@]}"
brew install -q "${PACKAGE_ARGS[@]}"
fi

if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then
printf "Installing Chocolatey packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
choco install -y $PACKAGES
printf 'Installing Chocolatey packages:\n'
printf ' %s\n' "${PACKAGE_ARGS[@]}"
choco install -y "${PACKAGE_ARGS[@]}"
fi
fi
- name: Run stubtest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/mypy_primer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
cd typeshed_to_test
MYPY_VERSION=$(grep mypy== requirements-tests.txt | cut -d = -f 3)
echo "new commit"
git rev-list --format=%s --max-count=1 $GITHUB_SHA
git rev-list --format=%s --max-count=1 "$GITHUB_SHA"
git checkout -b upstream_main origin/main
echo "base commit"
git rev-list --format=%s --max-count=1 upstream_main
Expand All @@ -50,9 +50,9 @@ jobs:
# fail action if exit code isn't zero or one
(
mypy_primer \
--new v${MYPY_VERSION} --old v${MYPY_VERSION} \
--new "v${MYPY_VERSION}" --old "v${MYPY_VERSION}" \
--custom-typeshed-repo typeshed_to_test \
--new-typeshed $GITHUB_SHA --old-typeshed upstream_main \
--new-typeshed "$GITHUB_SHA" --old-typeshed upstream_main \
--num-shards 6 --shard-index ${{ matrix.shard-index }} \
--debug \
--output concise \
Expand Down
31 changes: 20 additions & 11 deletions .github/workflows/stubtest_third_party.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,39 @@ jobs:
# Use the daily.yml workflow to run stubtest on all third party stubs.
function find_stubs {
git diff --name-only "origin/${GITHUB_BASE_REF}" HEAD | \
egrep ^stubs/ | cut -d "/" -f 2 | sort -u | \
(while read stub; do [ -d "stubs/$stub" ] && echo -n "$stub " || true; done)
grep -E ^stubs/ | cut -d "/" -f 2 | sort -u | \
(while IFS= read -r stub; do [ -d "stubs/$stub" ] && echo -n "$stub " || true; done)
}
STUBS=$(find_stubs || echo '')
echo "Changed stubs: $STUBS"
echo "STUBS=$STUBS" >> $GITHUB_ENV
echo "STUBS=$STUBS" >> "$GITHUB_ENV"
- name: Install required system packages
shell: bash
run: |
if [ -n "$STUBS" ]; then
PACKAGES=$(python tests/get_stubtest_system_requirements.py $STUBS)
read -r -a STUB_ARGS <<< "$STUBS"
PACKAGES=$(python tests/get_stubtest_system_requirements.py "${STUB_ARGS[@]}")
PACKAGE_ARGS=()
while IFS= read -r package; do
PACKAGE_ARGS+=("$package")
done <<< "$PACKAGES"
if [ "${{ runner.os }}" = "Linux" ]; then
if [ -n "$PACKAGES" ]; then
printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
printf 'Installing APT packages:\n'
printf ' %s\n' "${PACKAGE_ARGS[@]}"
sudo apt-get update -q && sudo apt-get install -qy "${PACKAGE_ARGS[@]}"
fi
else
if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then
printf "Installing Homebrew packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
brew install -q $PACKAGES
printf 'Installing Homebrew packages:\n'
printf ' %s\n' "${PACKAGE_ARGS[@]}"
brew install -q "${PACKAGE_ARGS[@]}"
fi

if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then
printf "Installing Chocolatey packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
choco install -y $PACKAGES
printf 'Installing Chocolatey packages:\n'
printf ' %s\n' "${PACKAGE_ARGS[@]}"
choco install -y "${PACKAGE_ARGS[@]}"
fi
fi
fi
Expand All @@ -89,14 +97,15 @@ jobs:
run: |
if [ -n "$STUBS" ]; then
echo "Testing $STUBS..."
read -r -a STUB_ARGS <<< "$STUBS"

if [ "${{ runner.os }}" = "Linux" ]; then
PYTHON_EXECUTABLE="xvfb-run python"
else
PYTHON_EXECUTABLE="python"
fi

$PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only $STUBS
$PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only "${STUB_ARGS[@]}"
else
echo "Nothing to test"
fi
41 changes: 32 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@ jobs:
run: |
PACKAGES=$(python tests/get_stubtest_system_requirements.py)
if [ -n "$PACKAGES" ]; then
printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
PACKAGE_ARGS=()
while IFS= read -r package; do
PACKAGE_ARGS+=("$package")
done <<< "$PACKAGES"
printf 'Installing APT packages:\n'
printf ' %s\n' "${PACKAGE_ARGS[@]}"
sudo apt-get update -q && sudo apt-get install -qy "${PACKAGE_ARGS[@]}"
fi
- name: Run mypy_test.py
run: python ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=${{ matrix.python-version }}
Expand Down Expand Up @@ -117,7 +122,11 @@ jobs:
run: |
PACKAGES=$(python tests/get_external_stub_requirements.py)
if [ -n "$PACKAGES" ]; then
uv pip install --python-version ${{ matrix.python-version }} $PACKAGES
PACKAGE_ARGS=()
while IFS= read -r package; do
PACKAGE_ARGS+=("$package")
done <<< "$PACKAGES"
uv pip install --python-version ${{ matrix.python-version }} "${PACKAGE_ARGS[@]}"
fi
# Published stub packages can shadow the checked-in stubs when ty
# resolves their relative imports.
Comment on lines 120 to 130

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srittau -- codex reckons that the shellcheck diagnostic here (and for other places where we use get_external_stub_requirements.py in our workflows) was not a false positive, and I think codex/shellcheck have a point here. Here's codex's reasoning:

get_external_stub_requirements.py returns complete requirement specifiers, not just package names. A valid requirement can contain whitespace, such as example>=1; python_version < "3.14", or characters with special meaning to shell globbing, such as the brackets in example[extra]. Expanding $PACKAGES without quotes would split the first example into multiple arguments and could interpret the second as a filename pattern. Quoting "$PACKAGES" as a whole would not solve this: it would pass the entire list of requirements as one argument.

Those steps therefore still read the helper's output into an array, one requirement per line, and pass "${PACKAGE_ARGS[@]}" to uv. This preserves each requirement as exactly one argument. It protects the requirement syntax the helper supports; it isn't a claim that one of our current requirements is already causing an installation failure.

Expand Down Expand Up @@ -152,7 +161,11 @@ jobs:
run: |
PACKAGES=$(python tests/get_external_stub_requirements.py)
if [ -n "$PACKAGES" ]; then
uv pip install --python-version ${{ matrix.python-version }} $PACKAGES
PACKAGE_ARGS=()
while IFS= read -r package; do
PACKAGE_ARGS+=("$package")
done <<< "$PACKAGES"
uv pip install --python-version ${{ matrix.python-version }} "${PACKAGE_ARGS[@]}"
fi
# Published stub packages can shadow the checked-in stubs when pyrefly
# resolves their relative imports.
Expand Down Expand Up @@ -187,20 +200,30 @@ jobs:
run: |
PACKAGES=$(python tests/get_stubtest_system_requirements.py)
if [ -n "$PACKAGES" ]; then
printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
sudo apt-get update -q && sudo apt-get install -qy $PACKAGES
PACKAGE_ARGS=()
while IFS= read -r package; do
PACKAGE_ARGS+=("$package")
done <<< "$PACKAGES"
printf 'Installing APT packages:\n'
printf ' %s\n' "${PACKAGE_ARGS[@]}"
sudo apt-get update -q && sudo apt-get install -qy "${PACKAGE_ARGS[@]}"
fi
- name: Create an isolated venv for testing
run: uv venv .venv
- name: Install 3rd-party stub dependencies
run: |
PACKAGES=$(python tests/get_external_stub_requirements.py)
if [ -n "$PACKAGES" ]; then
printf "Installing python packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n"
uv pip install --python-version ${{ matrix.python-version }} $PACKAGES
PACKAGE_ARGS=()
while IFS= read -r package; do
PACKAGE_ARGS+=("$package")
done <<< "$PACKAGES"
printf 'Installing python packages:\n'
printf ' %s\n' "${PACKAGE_ARGS[@]}"
uv pip install --python-version ${{ matrix.python-version }} "${PACKAGE_ARGS[@]}"
fi
- name: Activate the isolated venv for the rest of the job
run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
run: echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
- name: List 3rd-party stub dependencies installed
run: uv pip freeze
- name: Run pyright with basic settings on all the stubs
Expand Down
Loading