From 94d5ecfd246f9714c99e62a3b52280acad64e054 Mon Sep 17 00:00:00 2001 From: Joris Vincent Date: Thu, 29 Feb 2024 20:44:53 +0100 Subject: [PATCH] CI: GitHub Action for testing runs pytest on multiple platforms, python versions, through Nox only runs on PRs, push to main, and manual triggers --- .github/workflows/test.yml | 36 ++++++++++++++++++++++++++++++++++++ noxfile.py | 7 +++++++ requirements.txt | 1 + 3 files changed, 44 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 requirements.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..824f958 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,36 @@ +name: Test + +on: + push: + branches: [ main ] + # pull_request: + # workflow_dispatch: + +jobs: + test: + name: ${{ matrix.os}} / py${{ matrix.python_version }} + runs-on: ${{ matrix.os }}-latest + strategy: + fail-fast: false + matrix: + os: [Ubuntu, macOS] + python_version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + name: Install Python ${{ matrix.python_version }} + with: + python-version: ${{ matrix.python_version }} + architecture: x64 + + - name: Install (testing) requirements + run: | + python -m pip install --upgrade pip setuptools + pip install -r requirements.txt + - name: Install multyscale to be tested + run: | + pip install . + - name: Run tests for ${{ matrix.python_version }} through nox + run: | + pipx run nox --non-interactive --error-on-missing-interpreter --session "tests-${{ matrix.python_version }}" diff --git a/noxfile.py b/noxfile.py index 8afc6b2..eff4d73 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,6 +1,13 @@ import nox +@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"]) +def tests(session): + session.install("-r", "requirements.txt") + session.install(".") + session.run("pytest") + + @nox.session(python="3.12") def lint(session): # Run the linters (via pre-commit) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1d9b070 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +.[dev,docs] \ No newline at end of file