-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (80 loc) · 2.6 KB
/
tests.yaml
File metadata and controls
91 lines (80 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: tests
on:
push:
branches: [main]
workflow_dispatch:
inputs:
operating_systems:
description: 'Operating systems to test on'
type: choice
default: 'all'
options:
- all
- ubuntu-latest
- windows-latest
- macos-latest
jobs:
# Generate matrix based on input
setup-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set matrix
id: set-matrix
run: |
if [[ "${{ inputs.operating_systems }}" == "all" || "${{ github.event_name }}" == "push" ]]; then
echo 'matrix=["ubuntu-latest", "windows-latest", "macos-latest"]' >> $GITHUB_OUTPUT
else
echo 'matrix=["${{ inputs.operating_systems }}"]' >> $GITHUB_OUTPUT
fi
# Run tests using matrix strategy
tests:
permissions:
contents: write
needs: setup-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ${{ fromJSON(needs.setup-matrix.outputs.matrix) }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install python and dependencies
uses: actions/setup-python@v4
with:
python-version: '3.13'
cache: 'pip'
- name: Install requirements (Windows)
if: runner.os == 'Windows'
run: python -m pip install -r requirements.txt
- name: Install requirements (Unix)
if: runner.os != 'Windows'
run: pip install -r requirements.txt
- name: Run tests (with coverage for linux)
run: |
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
pytest --cov --cov-report=xml
else
pytest
fi
shell: bash
- name: Generate coverage badge (for-the-badge style)
if: matrix.os == 'ubuntu-latest'
run: genbadge coverage -i coverage.xml -o images/coverage-badge.svg
- name: Upload coverage badge
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: coverage-badge
path: images/coverage-badge.svg
- name: Commit coverage badge
if: matrix.os == 'ubuntu-latest'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add images/coverage-badge.svg
git commit -m "ci(tests): update coverage badge" || echo "No changes to commit"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}