5 pipeline with unit tests #10
Executable
+15
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Reproduces the CI "Preparse .sage files" step locally, so `ruff check` sees
|
||||||
|
# the same generated *.sage.py files that the pipeline lints. Run this before
|
||||||
|
# `sage --python -m ruff check --no-respect-gitignore .` to catch issues that
|
||||||
|
# only show up in the generated output (e.g. missing trailing newlines).
|
||||||
|
#
|
||||||
|
# The generated files are gitignored; clean them up afterwards with:
|
||||||
|
# git clean -x sage/ playground/
|
||||||
|
|
||||||
|
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
|
||||||
@@ -24,12 +24,7 @@ jobs:
|
|||||||
# parse it, and prepends the `from sage.all import *` that `sage`
|
# parse it, and prepends the `from sage.all import *` that `sage`
|
||||||
# normally injects at runtime, so Sage's globals (ZZ, var, matrix, ...)
|
# normally injects at runtime, so Sage's globals (ZZ, var, matrix, ...)
|
||||||
# resolve instead of looking like undefined names.
|
# resolve instead of looking like undefined names.
|
||||||
run: |
|
run: .gitea/preparse.sh
|
||||||
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
|
- name: ruff check
|
||||||
# --no-respect-gitignore: *.sage.py is gitignored (it's generated, see
|
# --no-respect-gitignore: *.sage.py is gitignored (it's generated, see
|
||||||
|
|||||||
+4
-1
@@ -23,7 +23,10 @@ ignore = [
|
|||||||
# so trailing-whitespace warnings fire mechanically on almost every line
|
# so trailing-whitespace warnings fire mechanically on almost every line
|
||||||
# with a number in it -- not something `ruff format` could fix anyway,
|
# with a number in it -- not something `ruff format` could fix anyway,
|
||||||
# since it wouldn't change the .sage source that generated it.
|
# since it wouldn't change the .sage source that generated it.
|
||||||
"*.sage.py" = ["F403", "F405", "F821", "E741", "E402", "E702", "I001", "W291", "W293"]
|
# - W292: whether the reconstructed file ends in a real trailing newline
|
||||||
|
# depends on how many blank lines the preparser appends, which varies by
|
||||||
|
# Sage version -- not something worth pinning tool versions over.
|
||||||
|
"*.sage.py" = ["F403", "F405", "F821", "E741", "E402", "E702", "I001", "W291", "W293", "W292"]
|
||||||
|
|
||||||
# tests/test_smoke.py does `from sage.all import *` and `load(...)` a .sage
|
# tests/test_smoke.py does `from sage.all import *` and `load(...)` a .sage
|
||||||
# file to get at its classes -- the same dynamic-namespace situation as
|
# file to get at its classes -- the same dynamic-namespace situation as
|
||||||
|
|||||||
Reference in New Issue
Block a user