54 lines
1.4 KiB
YAML
54 lines
1.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: ["**"]
|
|
pull_request:
|
|
branches: ["**"]
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: sagemath/sagemath:10.4
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install ruff
|
|
run: sage --pip install ruff
|
|
|
|
- name: Preparse .sage files
|
|
# Turns each *.sage file into real Python (*.sage.py) so ruff can
|
|
# parse it, and prepends the `from sage.all import *` that `sage`
|
|
# normally injects at runtime, so Sage's globals (ZZ, var, matrix, ...)
|
|
# resolve instead of looking like undefined names.
|
|
run: |
|
|
set -e
|
|
for f in $(find . -name "*.sage" -not -path "./playground/*"); do
|
|
sage --preparse "$f"
|
|
printf 'from sage.all import * # noqa: F401,F403\n%s\n' "$(cat "${f}.py")" > "${f}.py"
|
|
done
|
|
|
|
- name: ruff check
|
|
# --no-respect-gitignore: *.sage.py is gitignored (it's generated, see
|
|
# the previous step) but that's exactly what we need to lint here.
|
|
run: sage --python -m ruff check --no-respect-gitignore .
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
needs: lint
|
|
container:
|
|
image: sagemath/sagemath:10.4
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install pytest
|
|
run: sage --pip install pytest
|
|
|
|
- name: Run tests
|
|
run: sage --python -m pytest tests/
|