Repository navigation
79 lines (66 loc) · 2.35 KB
/
Copy pathtesting.yml
File metadata and controls
79 lines (66 loc) · 2.35 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
name: Testing
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: testing-${{ github.event_name }}-${{ github.event.pull_request.number ||
github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
# Run tests and generate code coverage report.
run-tests:
name: Unit tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.11', '3.x']
steps:
- uses: actions/checkout@v7
- name: Set Up Python
id: setup-python
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
# Unlike the code-check workflow, this job requires the dev dependencies to be
# installed to make sure we have the necessary, tools, stub files, etc.
- name: Install Poetry
uses: abatilo/actions-poetry@v4
- name: Cache Virtual Environment
uses: actions/cache@v6
with:
path: ./.venv
key: ${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-venv-${{
hashFiles('poetry.lock') }}
- name: Install Dependencies
env:
POETRY_INSTALLER_ONLY_BINARY: ':all:'
run: poetry install
- name: Pin pandas 3.x for Python 3.11+
if: matrix.python-version != '3.9'
run: |
poetry env use "${{ matrix.python-version }}"
. "$(poetry env info --path)/bin/activate"
python -m pip install --upgrade --only-binary=:all: "pandas==3.0.6"
# Run pytest and generate coverage report data.
- name: Run Tests
run: poetry run pytest tests/mock/ --doctest-modules --cov --cov-report=xml:out/coverage.xml
# Run mypy with strict mode enabled. Only the main source code is type checked (test
# and example code is excluded).
- name: Check Types
run: poetry run mypy --strict cwms/
- name: Generate Coverage Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: out/coverage.xml
format: markdown
output: both
badge: true
- name: Generate Job Summary
uses: x-color/github-actions-job-summary@v0.1.1
with:
file: ./code-coverage-results.md
vars: |-
empty: empty