diff --git a/.github/workflows/pyright.yml b/.github/workflows/pyright.yml index eb84117cb3a..515765f257c 100644 --- a/.github/workflows/pyright.yml +++ b/.github/workflows/pyright.yml @@ -1,12 +1,11 @@ -name: Static check with Pyright +name: Static type check on: - pull_request: - merge_group: push: branches: - master - develop + pull_request: workflow_dispatch: # Allow to run manually @@ -18,67 +17,40 @@ concurrency: jobs: pyright: runs-on: ubuntu-latest - container: ghcr.io/sagemath/sage/sage-ubuntu-jammy-standard-with-targets:dev steps: - - name: Checkout - id: checkout - uses: actions/checkout@v4 - - - name: Update system packages - id: prepare - run: | - export PATH="build/bin:$PATH" - eval $(sage-print-system-package-command auto update) - eval $(sage-print-system-package-command auto --spkg --yes --no-install-recommends install git) - - - name: Install GH CLI - uses: dev-hanz-ops/install-gh-cli-action@v0.2.0 - with: - gh-cli-version: 2.32.0 + - uses: actions/checkout@v4 - name: Merge CI fixes from sagemath/sage run: | - git config --global --add safe.directory "$GITHUB_WORKSPACE" .ci/merge-fixes.sh - - - name: Add prebuilt tree as a worktree - id: worktree - run: | - set -ex - .ci/retrofit-worktree.sh worktree-image /sage - - - name: Incremental build (sagelib deps) - id: incremental - run: | - # Now re-bootstrap and build. The build is incremental because we were careful with the timestamps. - # pyright does not need a built sagelib; it only needs - # the libraries from which sagelib imports. - ./bootstrap && make sagelib-build-deps - working-directory: ./worktree-image env: - MAKE: make -j2 --output-sync=recurse - SAGE_NUM_THREADS: 2 + GH_TOKEN: ${{ github.token }} - - name: Static code check with pyright - uses: jakebailey/pyright-action@v1 + - name: Cache conda packages + uses: actions/cache@v4 with: - version: 1.1.332 - # Many warnings issued by pyright are not yet helpful because there is not yet enough type information. - no-comments: true - working-directory: ./worktree-image - env: - # To avoid out of memory errors - NODE_OPTIONS: --max-old-space-size=8192 + path: ~/conda_pkgs_dir + key: + ${{ runner.os }}-conda-${{ hashFiles('environment-3.11-linux.yml') }} - - name: Static code check with pyright (annotated) - if: (success() || failure()) && steps.incremental.outcome == 'success' - uses: jakebailey/pyright-action@v1 + - name: Setup Conda environment + uses: conda-incubator/setup-miniconda@v3 + with: + python-version: 3.11 + miniforge-version: latest + use-mamba: true + channels: conda-forge + channel-priority: true + activate-environment: sage-dev + environment-file: environment-3.11-linux.yml + + # No need to build sagelib; pyright only needs the libraries from which sagelib imports + + - name: Static code check with pyright + uses: jakebailey/pyright-action@v2.3.2 with: version: 1.1.332 - # Issue errors - no-comments: false - level: error - working-directory: ./worktree-image + annotate: "errors" env: # To avoid out of memory errors NODE_OPTIONS: --max-old-space-size=8192