-
Notifications
You must be signed in to change notification settings - Fork 4
124 lines (105 loc) · 4.16 KB
/
Copy pathtest.yml
File metadata and controls
124 lines (105 loc) · 4.16 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: tests.yml
permissions:
contents: read
actions: read # Required for setup-python and other actions to read action metadata
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
UV_VERSION: "0.11.21"
UV_PROJECT_ENVIRONMENT: venv
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
cancel-in-progress: true
on:
workflow_dispatch: {}
push:
branches:
- "*"
- "*/*"
- "**"
pull_request:
branches:
- master
jobs:
run_tests:
name: Run tests
runs-on: ubuntu-latest
environment: codecov
defaults:
run:
shell: bash
permissions:
issues: write # Required for actions/github-script to create issues on test failure
steps:
- name: Check out GitHub repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 1
ref: ${{ github.event_name == 'workflow_dispatch' && github.ref || github.sha }}
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version-file: '.python-version'
- name: Set up uv
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
with:
version: ${{ env.UV_VERSION }}
- name: Sync dependencies (locked)
run: uv sync --locked --extra dev
- name: Check and fix with Ruff
run: uv run ruff check ./tests/*.py ./openseries/*.py --fix --exit-non-zero-on-fix
- name: Format with Ruff
run: uv run ruff format
- name: Manage Mypy cache
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: mypy-cache
with:
path: .mypy_cache
key: mypy-cache-${{ hashFiles('**/*.py') }}
restore-keys: mypy-cache-
- name: Type check with Mypy
run: uv run mypy --cache-dir .mypy_cache .
- name: Tests with Pytest
id: pytest
continue-on-error: true
run: uv run pytest
env:
PYTHONPATH: ${{ github.workspace }}
- name: Create GitHub issue on failure
if: ${{ steps.pytest.outcome == 'failure' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
GH_OWNER: ${{ github.repository_owner }}
GH_REPO: ${{ github.event.repository.name }}
GH_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
with:
script: |
const owner = process.env.GH_OWNER;
const repo = process.env.GH_REPO;
const runUrl = process.env.GH_RUN_URL;
await github.rest.issues.create({
owner,
repo,
title: `Tests failed on ${new Date().toDateString()}`,
body: `See the full logs here: ${runUrl}`,
});
- name: Fail job if tests failed
if: ${{ steps.pytest.outcome == 'failure' }}
run: exit 1
- name: Upload test results to Codecov
if: ${{ github.ref_name == 'master' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: junit.xml
report_type: test_results
verbose: true
- name: Upload coverage to Codecov
if: ${{ github.ref_name == 'master' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: CaptorAB/openseries
files: coverage.xml
verbose: true