Add actionlint checks for GitHub Actions #10964
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Stubtest: third-party" | |
| on: | |
| pull_request: | |
| paths: | |
| - "stubs/**" | |
| - ".github/workflows/stubtest_third_party.yml" | |
| - "tests/**" | |
| # When requirements.txt changes, we run `daily.yml`, which includes third-party stubtest | |
| permissions: | |
| contents: read | |
| env: | |
| # A few env vars to speedup brew install | |
| HOMEBREW_NO_ANALYTICS: 1 | |
| HOMEBREW_NO_AUTOUPDATE: 1 | |
| HOMEBREW_NO_INSTALL_CLEANUP: 1 # Environments are isolated, no need to cleanup old versions | |
| NONINTERACTIVE: 1 # Required for brew install on CI | |
| PIP_DISABLE_PIP_VERSION_CHECK: 1 | |
| FORCE_COLOR: 1 | |
| TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817 | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| stubtest-third-party: | |
| name: "stubtest: third party" | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: ["ubuntu-latest", "windows-latest", "macos-latest"] | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 | |
| with: | |
| python-version: "3.13" | |
| cache: pip | |
| cache-dependency-path: | | |
| requirements-tests.txt | |
| stubs/**/METADATA.toml | |
| - name: Install dependencies | |
| run: pip install -r requirements-tests.txt | |
| - name: Determine changed stubs | |
| shell: bash | |
| run: | | |
| # This only runs stubtest on changed stubs, because it is much faster. | |
| # 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 | \ | |
| 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" | |
| - name: Install required system packages | |
| shell: bash | |
| run: | | |
| # System package and stub directory names contain no whitespace or glob characters; split both lists into arguments. | |
| # shellcheck disable=SC2086 | |
| if [ -n "$STUBS" ]; then | |
| PACKAGES=$(python tests/get_stubtest_system_requirements.py $STUBS) | |
| if [ "${{ runner.os }}" = "Linux" ]; then | |
| if [ -n "$PACKAGES" ]; then | |
| printf 'Installing APT packages:\n' | |
| printf ' %s\n' $PACKAGES | |
| sudo apt-get update -q && sudo apt-get install -qy $PACKAGES | |
| fi | |
| else | |
| if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then | |
| printf 'Installing Homebrew packages:\n' | |
| printf ' %s\n' $PACKAGES | |
| brew install -q $PACKAGES | |
| fi | |
| if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then | |
| printf 'Installing Chocolatey packages:\n' | |
| printf ' %s\n' $PACKAGES | |
| choco install -y $PACKAGES | |
| fi | |
| fi | |
| fi | |
| - name: Run stubtest | |
| shell: bash | |
| run: | | |
| if [ -n "$STUBS" ]; then | |
| echo "Testing $STUBS..." | |
| if [ "${{ runner.os }}" = "Linux" ]; then | |
| PYTHON_EXECUTABLE="xvfb-run python" | |
| else | |
| PYTHON_EXECUTABLE="python" | |
| fi | |
| # Stub directory names contain no whitespace or glob characters, so word splitting is intentional. | |
| # shellcheck disable=SC2086 | |
| $PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only $STUBS | |
| else | |
| echo "Nothing to test" | |
| fi |