-
Notifications
You must be signed in to change notification settings - Fork 45
140 lines (119 loc) · 3.72 KB
/
pr.yml
File metadata and controls
140 lines (119 loc) · 3.72 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# TODO: In the future we ought to perform code coverage checks
name: Pull Request
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: read
env:
PYTHON_VERSION: "3.10"
jobs:
tests:
name: "Tests"
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
# For Pull Requests we run tests on Ubuntu with Python 3.10.
# In releases we will test on more configurations.
operating-system:
- ubuntu-latest
# - windows-latest
# - macos-latest
python-version:
- '3.10'
# - '3.11'
# - '3.12'
steps:
- uses: actions/checkout@v3
with:
# diff-cover needs more history to compute coverage diffs
fetch-depth: 10
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip' # caching pip dependencies
- name: Install dependencies
run: |
python -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
python -m pip install ".[dev]"
- name: Cache Test Datasets
id: cache-test-datasets
uses: actions/cache@v4
with:
path: data
key: "test-datasets"
- name: PyTest
run: invoke test.pytest --coverage
- name: Doctest
run: invoke test.doctest --coverage
- name: Check Notebooks
run: invoke test.nb
- name: Combine Test Coverages & Generate XML Report
run: |
invoke test.cov-combine
coverage xml -i
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
files: coverage.xml
lint:
name: "Code Style"
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Formatting
uses: astral-sh/ruff-action@v3
with:
args: "format --check"
- name: Linting
uses: astral-sh/ruff-action@v3
commit:
name: "Commit Style"
runs-on: ubuntu-latest
# Only report commit style issues on push to main, not on PRs as contributors seldom
# want to worry about fixing commit messages. The reviewer will `squash and merge`
# with a proper commit message.
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- uses: wagoid/commitlint-github-action@v6
documentation:
name: "Documentation"
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip' # caching pip dependencies
- name: Install Dependencies
run: |
sudo apt-get install -y pandoc
python -m pip install torch~=2.9.1 torchvision~=0.24.1 --index-url https://download.pytorch.org/whl/cpu
python -m pip install -U ".[dev,doc]"
# '-U' upgrades dependencies based on the pyproject.toml
- name: Build Documentation
run: invoke docs.build
- name: Artifact name
run: echo DOC_ARTIFACT_NAME=doc-${GITHUB_REF//\//-} >> $GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: ${{ env.DOC_ARTIFACT_NAME }}
retention-days: 14
path: docs/_build
overwrite: true