5 pipeline with unit tests (#10)
--------- Co-authored-by: Julian Piribauer <julian.piribauer@gmail.com> Co-authored-by: julian <julian.piribauer@gmail.com> Reviewed-on: #10
This commit was merged in pull request #10.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# Custom CI image for the arm64 (Raspberry Pi) Gitea Actions runner,
|
||||
# since the official sagemath/sagemath image is amd64-only.
|
||||
#
|
||||
# Build & push commands:
|
||||
# docker build -t gitea.piribauer.ch/julian/sage-ci:latest -f .gitea/ci-image/Dockerfile .
|
||||
# docker login gitea.piribauer.ch -u julian
|
||||
# docker push gitea.piribauer.ch/julian/sage-ci:latest
|
||||
|
||||
FROM condaforge/miniforge3:latest
|
||||
|
||||
RUN mamba install -y -c conda-forge sage ruff pytest \
|
||||
&& mamba clean -afy
|
||||
|
||||
RUN mamba install -y -c conda-forge nodejs \
|
||||
&& mamba clean -afy
|
||||
|
||||
WORKDIR /workspace
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script is run in the CI container to preparse all .sage files into .sage.py files
|
||||
# and can also be run locally for local linting/testing.
|
||||
|
||||
set -e
|
||||
|
||||
if command -v python >/dev/null 2>&1 && python -c "import sage.repl" >/dev/null 2>&1; then
|
||||
run_python() { python "$@"; }
|
||||
else
|
||||
run_python() { sage --python "$@"; }
|
||||
fi
|
||||
|
||||
for f in $(find . -name "*.sage" -not -path "./playground/*"); do
|
||||
run_python -c "
|
||||
import sys
|
||||
from sage.repl.preparse import preparse_file
|
||||
|
||||
path = sys.argv[1]
|
||||
with open(path) as fh:
|
||||
src = fh.read()
|
||||
with open(path + '.py', 'w') as fh:
|
||||
fh.write('from sage.all import * # noqa: F401,F403\n')
|
||||
fh.write(preparse_file(src))
|
||||
" "$f"
|
||||
done
|
||||
@@ -0,0 +1,37 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["**"]
|
||||
pull_request:
|
||||
branches: ["**"]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
# Custom image (see .gitea/ci-image/Dockerfile)
|
||||
container:
|
||||
image: gitea.piribauer.ch/julian/sage-ci:latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Preparse .sage files
|
||||
run: .gitea/preparse.sh
|
||||
|
||||
- name: ruff check
|
||||
run: python -m ruff check --no-respect-gitignore .
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
needs: lint
|
||||
container:
|
||||
image: gitea.piribauer.ch/julian/sage-ci:latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Run tests
|
||||
run: python -m pytest tests/
|
||||
Reference in New Issue
Block a user