Skip to content

Commit

Permalink
ci: Add workflow for testing action
Browse files Browse the repository at this point in the history
Closes #10

Adds a workflow to run tests on GitHub Actions Continuous Integration.

It only runs `pull_request` for certain events and even more specifically on changes to specific files (see the `paths`
list under `pull_request`).

At the same time I've linked the `sudlab/IsoSLAM` repository to [codecov.io](https://codecov.io) so that the tests,
which generate code coverage reports (in XML) are uploaded and available for analysis automatically. Required adding a
Secret Token from Codecov to the repository.

May be tweaked in future but this is a good starting point.
  • Loading branch information
ns-rse committed Nov 1, 2024
1 parent 0a515c2 commit 5721da6
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Tests (pytest)

on:
pull_request:
types:
- opened
- ready_for_review
- reopened
- synchronize
paths:
- "**.csv"
- "**.npy"
- "**.out"
- "**.pkl"
- "**.png"
- "**.py"
- "**.toml"
- "**.yaml"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Ex1 (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip and install test dependencies
run: |
pip install --upgrade virtualenv
pip install --upgrade pip setuptools
virtualenv --upgrade-embed-wheels
pip install -e .[tests]
- name: Test with pytest
run: |
pytest --cov=isoslam --cov-report=xml --mpl -x
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 5

0 comments on commit 5721da6

Please sign in to comment.