Skip to content

Commit

Permalink
Unit test on GitHub actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaander committed Jun 20, 2024
1 parent 3dc9653 commit 971366c
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/requirements-test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coverage
numpy
pytest
pytest-cov
scipy
24 changes: 24 additions & 0 deletions .github/workflows/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -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
57 changes: 57 additions & 0 deletions .github/workflows/unit_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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
with:
path: code
- 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: ".github/workflows/requirements-test.txt"
- name: Install
run: uv pip install . --no-deps --no-build-isolation
working-directory: code
- name: Run tests
run: python3 -m pytest -v code

# 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

0 comments on commit 971366c

Please sign in to comment.