From df15dd3f8a2e8bb685f3783b2200288bc7e1f959 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Thu, 20 Jun 2024 12:46:30 -0400 Subject: [PATCH] Unit test on GitHub actions. --- .github/workflows/requirements-test.in | 5 +++ .github/workflows/requirements-test.txt | 24 ++++++++++++ .github/workflows/unit_test.yaml | 52 +++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 .github/workflows/requirements-test.in create mode 100644 .github/workflows/requirements-test.txt create mode 100644 .github/workflows/unit_test.yaml diff --git a/.github/workflows/requirements-test.in b/.github/workflows/requirements-test.in new file mode 100644 index 0000000..1c87dba --- /dev/null +++ b/.github/workflows/requirements-test.in @@ -0,0 +1,5 @@ +coverage +numpy +pytest +pytest-cov +scipy diff --git a/.github/workflows/requirements-test.txt b/.github/workflows/requirements-test.txt new file mode 100644 index 0000000..69ae80e --- /dev/null +++ b/.github/workflows/requirements-test.txt @@ -0,0 +1,24 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile requirements-test.in +coverage==7.5.3 + # via + # -r requirements-test.in + # pytest-cov +iniconfig==2.0.0 + # via pytest +numpy==2.0.0 + # via + # -r requirements-test.in + # scipy +packaging==24.1 + # via pytest +pluggy==1.5.0 + # via pytest +pytest==8.2.2 + # via + # -r requirements-test.in + # pytest-cov +pytest-cov==5.0.0 + # via -r requirements-test.in +scipy==1.13.1 + # via -r requirements-test.in diff --git a/.github/workflows/unit_test.yaml b/.github/workflows/unit_test.yaml new file mode 100644 index 0000000..d4052e2 --- /dev/null +++ b/.github/workflows/unit_test.yaml @@ -0,0 +1,52 @@ +name: Unit test + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + pull_request: + + push: + branches: + - "master" + + workflow_dispatch: + +defaults: + run: + shell: bash + +jobs: + unit_test: + name: Unit test [py${{ matrix.python }}] + runs-on: ubuntu-24.04 + strategy: + matrix: + python: ["3.9", "3.10", "3.11", "3.12"] + + steps: + - name: Checkout + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - name: Set up Python + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + with: + python-version: ${{ matrix.python }} + - name: Set up Python environment + uses: glotzerlab/workflows/setup-uv@5cfac9da9cb78e16ae97a9119b6fd13c1c2d6f5e # 0.1.0 + with: + lockfile: "code/.github/workflows/requirements-test.txt" + - name: Run tests + run: python3 -m pytest -v + + # This job is used to provide a single requirement for branch merge conditions. + tests_complete: + name: Unit test + if: always() + needs: [unit_test] + runs-on: ubuntu-latest + + steps: + - run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' + - name: Done + run: exit 0