Skip to content

Adding testing to the CI. #157

Adding testing to the CI.

Adding testing to the CI. #157

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
Lint:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
# Run Ruff
- name: Run Ruff
run: |
pip install uv
uv pip install --system ruff
ruff check
# Run Codespell
- name: Run Codespell
run: |
pip install codespell
codespell codespell src/**/*.py
Test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
os:
- ubuntu-latest
- macos-latest # arm64 (Apple Silicon)
- macos-13 # latest Intel release
- windows-latest
steps:
- uses: actions/checkout@v4
# requires npm because JS needs to be built
- uses: actions/setup-node@v4
with:
node-version: "18.x"
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: |
pip install pytest-notebook
pip install pre-commit
pre-commit run --all
pre-commit install
# pipx install hatch
# hatch run test --cover --nb-test-files
- name: Install IPyNiiVue & Deps
run: pip install -e .
- name: Test import
run: |
python -c "import ipyniivue"
- name: Test IPyNiiVue
run: |
pip install pytest-cov
pip install --upgrade pip ipython ipykernel
ipython kernel install --name "python3" --user
mkdir -p ./reports
pytest --cov --cov-report=json:./reports/coverage.json --cov-report=xml:./reports/coverage.xml
- name: Upload ipyniivue test coverage report
uses: actions/upload-artifact@v4
with:
name: coverage_ipyniivue
path: ./reports/coverage.json
- name: Generate Markdown summary of code coverage
uses: irongut/[email protected]
with:
filename: ./reports/coverage.xml
format: markdown
output: both
thresholds: "10 10"
- name: Add test results to job summary
run: |
cat ./code-coverage-results.md >> $GITHUB_STEP_SUMMARY
- name: Test example notebooks
run: |
pip install nbmake
rm -rf ./reports
mkdir -p ./reports
pytest --nbmake examples/*ipynb --cov --cov-report=json:./reports/coverage.json --cov-report=xml:./reports/coverage.xml
- name: Upload ipyniivue example notbooks coverage report
uses: actions/upload-artifact@v4
with:
name: coverage_ipyniivue_notebooks
path: ./reports/coverage.json
- name: Generate Markdown summary of code coverage
uses: irongut/[email protected]
with:
filename: ./reports/coverage.xml
format: markdown
output: both
thresholds: "10 10"
- name: Add test results to job summary
run: |
cat ./code-coverage-results.md >> $GITHUB_STEP_SUMMARY
# coverage run -m pytest --nb-test-files
# nbt-test-files check for changes in the output of the notebook.
# This does not work for our purpose since we wipe the output
# before committing changes to facilitate integration with git.
# - name: Upload coverage to codecov (Only do this for the ubuntu-latest job)
# if: matrix.os == 'ubuntu-latest'
# uses: codecov/codecov-action@v5
# with:
# token: ${{secrets.CODECOV_TOKEN}}
#
LintJavaScript:
name: JavaScript / Lint
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: biomejs/setup-biome@v2
with:
version: latest
- run: biome ci .
TypecheckJavaScript:
name: JavaScript / Typecheck
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22.x"
- run: |
npm install
npm run typecheck