From b344f4107ef735605d76d3c97a4bbe8fc3c14ca9 Mon Sep 17 00:00:00 2001 From: Josh Thomas Date: Wed, 7 Feb 2024 00:54:55 -0600 Subject: [PATCH] Added GHA workflow for tests. (#38) --- .github/workflows/test.yml | 88 ++++++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..78db308 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,88 @@ +name: test + +on: + push: + branches: [main] + pull_request: + +concurrency: + group: test-${{ github.head_ref }} + cancel-in-progress: true + +env: + PYTHONUNBUFFERED: "1" + FORCE_COLOR: "1" + +jobs: + test: + name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }} + runs-on: "ubuntu-latest" + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11", "3.12"] + django-version: ["4.2", "5.0", "main"] + steps: + - uses: actions/checkout@v4 + + - uses: extractions/setup-just@v1 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: "pip" + allow-prereleases: true + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + if [[ "${{ matrix.django-version }}" == "main" ]]; then + python -m pip install https://github.com/django/django/archive/refs/heads/main.zip + else + python -m pip install django==${{ matrix.django-version }} + fi + python -m pip install '.[tests]' + + - name: Run tests + run: | + just test + + tests: + runs-on: ubuntu-latest + needs: test + if: always() + steps: + - name: OK + if: ${{ !(contains(needs.*.result, 'failure')) }} + run: exit 0 + - name: Fail + if: ${{ contains(needs.*.result, 'failure') }} + run: exit 1 + + coverage: + runs-on: ubuntu-latest + env: + PYTHON_MIN_VERSION: "3.10" + DJANGO_MIN_VERSION: "4.2" + steps: + - uses: actions/checkout@v4 + + - uses: extractions/setup-just@v1 + + - name: Set up Python ${{ env.PYTHON_MIN_VERSION }} + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_MIN_VERSION }} + cache: "pip" + allow-prereleases: true + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install django==${{ env.DJANGO_MIN_VERSION }} + python -m pip install '.[tests]' + + - name: Run coverage + run: | + just coverage diff --git a/pyproject.toml b/pyproject.toml index c4c427d..929d2b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ Docs = "https://noumenal.es/neapolitan/" [project.optional-dependencies] docs = ["Sphinx"] -tests = ["coverage", "django_coverage_plugin"] +tests = ["coverage[toml]", "django_coverage_plugin"] [tool.coverage.run] plugins = ["django_coverage_plugin"]