| name: pyrefly |
| on: |
| push: |
| branches: [ main ] |
| paths: |
| - '**/*' |
| - '!.*' |
| - '.github/workflows/pyrefly.yml' |
| pull_request: |
| schedule: |
| - cron: '0 12 * * 1' # 12pm Monday |
| workflow_call: |
| |
| # GitHub sets `head_ref` only for a pull request. A new push to a pull request |
| # cancels the previous run. All other events use the unique `run_id`. Each of |
| # these runs gets its own group, and no run cancels a different run. This is |
| # important for publish_to_pypi.yml and deploy_extension.yml, which call this |
| # workflow to make a release. |
| concurrency: |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| cancel-in-progress: true |
| |
| jobs: |
| test: |
| runs-on: ${{ matrix.os }} |
| |
| strategy: |
| fail-fast: false |
| matrix: |
| os: [ubuntu-latest, windows-latest, macOS-latest] |
| include: |
| - os: windows-latest |
| github_env: $env:GITHUB_ENV |
| steps: |
| - uses: actions/checkout@v6 |
| - uses: actions/setup-python@v6 |
| with: |
| python-version: '3.12' |
| - name: Install uv |
| uses: astral-sh/setup-uv@v5 |
| with: |
| enable-cache: true |
| if: ${{ matrix.os == 'ubuntu-latest' }} |
| - name: Check Python formatting (ruff) |
| run: | |
| uv tool run --from ruff==0.14.3 ruff format --check --config ruff.toml . |
| uv tool run --from ruff==0.14.3 ruff check --select I --config ruff.toml . |
| if: ${{ matrix.os == 'ubuntu-latest' }} |
| - name: set windows cargo home |
| # we need to set CARGO_HOME to a high-up directory on Windows machines, since some dependencies cloned |
| # by Cargo have long paths and will cause builds/tests to fail |
| if: ${{ matrix.os == 'windows-latest' }} |
| run: echo "CARGO_HOME=C:\\cargo" >> ${{ matrix.github_env }} |
| - name: set up rust cache |
| uses: Swatinem/rust-cache@v2 |
| with: |
| prefix-key: pyrefly |
| - uses: dtolnay/rust-toolchain@master |
| with: |
| toolchain: stable |
| components: clippy, rustfmt |
| # The cache step runs first, and the Scrut binary goes into the cached |
| # ~/.cargo/bin. Later runs get Scrut from the cache and do not compile it |
| # again. |
| - name: install Scrut |
| run: cargo install scrut --locked |
| # Scrut doesn't support Windows yet |
| if: ${{ matrix.os != 'windows-latest' }} |
| - run: cargo fmt -- --check |
| - run: cargo clippy --release |
| - run: cargo build --release |
| - run: cargo test --release |
| - name: Check conformance output is up to date |
| # The generated output is platform-independent, so one OS is enough. It must not |
| # be Windows: the check keys results by splitting paths on "/". |
| if: ${{ matrix.os == 'ubuntu-latest' }} |
| run: python conformance/conformance_output.py conformance/third_party --mode check --executable target/release/pyrefly |
| - name: Run Scrut tests |
| env: |
| PYREFLY: ${{ github.workspace }}/target/release/pyrefly |
| TYPESHED_ROOT: ${{ github.workspace }}/crates/pyrefly_bundled/third_party |
| JQ: jq |
| TEST_PY: ${{ github.workspace }}/test.py |
| PYREFLY_PY: ${{ github.workspace }}/pyrefly/python |
| run: env -u GITHUB_ACTIONS scrut test test |
| if: ${{ matrix.os != 'windows-latest' }} |
| # Every library's stub tests run in one step rather than one job per |
| # library. Type checking runs on the whole matrix: it needs no virtualenv, |
| # and the runners carry Windows-specific interpreter and `.exe` path |
| # handling that nothing else would exercise. Only the runtime half is |
| # Ubuntu-only, so that torch and jax are not installed three times to run |
| # platform-independent assertions. |
| - name: Run tensor-shape type checks |
| run: python tensor-shapes/run_tests.py --release --static-only |
| - name: Bootstrap tensor-shapes virtualenv |
| run: python tensor-shapes/bootstrap_venv.py |
| if: ${{ matrix.os == 'ubuntu-latest' }} |
| - name: Run tensor-shape runtime tests |
| run: python tensor-shapes/run_tests.py --runtime-only |
| if: ${{ matrix.os == 'ubuntu-latest' }} |