Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
sagemathgh-39286: Migrate pyright workflow to use conda
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Simplifies the setup a bit and one step closer to independence on sage-
the-distro. Also updates the pyright action

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#39286
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik
  • Loading branch information
Release Manager committed Mar 9, 2025
2 parents 960e238 + a2cc52f commit 882c2a8
Showing 1 changed file with 24 additions and 50 deletions.
74 changes: 24 additions & 50 deletions .github/workflows/pyright.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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

Expand All @@ -18,67 +18,41 @@ concurrency:
jobs:
pyright:
runs-on: ubuntu-latest
container: ghcr.io/sagemath/sage/sage-ubuntu-noble-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/[email protected]
with:
gh-cli-version: 2.32.0

- 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/[email protected]
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

0 comments on commit 882c2a8

Please sign in to comment.