-
Notifications
You must be signed in to change notification settings - Fork 1
143 lines (130 loc) Β· 4.95 KB
/
CI.yaml
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: CI
# Concurrency group that uses the workflow name and PR number if available
# or commit SHA as a fallback. If a new build is triggered under that
# concurrency group while a previous build is running it will be canceled.
# Repeated pushes to a PR will cancel all previous builds, while multiple
# merges to main will not cancel.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
env:
FORCE_COLOR: "1" # Make tools pretty
DEFAULT_PYTHON_VERSION: "3.11" # keep in sync with tox.ini
PIP_DISABLE_PIP_VERSION_CHECK: "1" # Don't check for pip updates
permissions: {}
on:
push:
pull_request:
jobs:
# Run our test suite on various combinations of OS & Python versions
run-pytest:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: [ubuntu-22.04, ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
uses: abatilo/actions-poetry@v3
- name: Setup poetry
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('pyproject.toml') }}
- name: Install the project dependencies
run: poetry install --with test
- name: Run the test
run: COLUMNS=80 poetry run coverage run -m pytest
- name: "Upload coverage data to GH artifacts π€"
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: coverage-data
path: .coverage
if-no-files-found: ignore
include-hidden-files: true
build-site:
name: "build docs"
runs-on: ubuntu-latest
steps:
- name: "Checkout repository π"
uses: actions/checkout@v4
- name: Install poetry
uses: abatilo/actions-poetry@v3
- name: "Install pandoc π"
uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: "latest"
- name: Setup poetry
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('pyproject.toml') }}
- name: Install the project dependencies
run: poetry install --with test
- name: "Build docs and check for warnings π"
shell: bash
run: |
poetry run sphinx-build docs docs/_build -W
coverage:
name: "Check coverage"
needs: run-pytest
runs-on: ubuntu-latest
# avoid running this on schedule, releases, or workflow_call
if: github.event.workflow_run.event != 'schedule' && github.event.workflow_run.event != 'release' && github.event.workflow_run.event != 'workflow_call'
permissions:
contents: write
pull-requests: write
steps:
- name: "Checkout repository π"
uses: actions/checkout@v4
- name: "Setup CI environment π "
uses: ./.github/actions/set-dev-env
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
- run: python -Im pip install --upgrade coverage[toml]
- name: "Download coverage data π₯"
uses: actions/download-artifact@v4
with:
pattern: coverage-data
- name: "Get coverage data & fail if it's <80%"
run: |
# if we decide to check cov across versions and combine
# python -Im coverage combine
python -Im coverage html --skip-covered --skip-empty
# report and write to summary.
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
# report again and fail if under 80%.
python -Im coverage report --fail-under=80
- name: "Upload HTML report if check failed π€"
uses: actions/upload-artifact@v4
with:
name: html-report
path: htmlcov
if: ${{ failure() }}
# seems we need to call this from the main CI workflow first
- name: "Coverage comment π¬"
uses: py-cov-action/python-coverage-comment-action@v3
id: coverage_comment
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Store Pull Request comment to be posted π€"
uses: actions/upload-artifact@v4
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
# leave default names
name: python-coverage-comment-action
path: python-coverage-comment-action.txt