-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (142 loc) · 4.67 KB
/
test.yml
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
144
145
146
147
148
149
150
151
name: Run Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "0 7 * * 1"
workflow_dispatch:
jobs:
lint:
name: Linting (pre-commit)
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Run pre-commit action
uses: pre-commit/[email protected]
tests:
name: Test it!
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.8, "3.12"]
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout the repo
uses: actions/checkout@v3
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: Get pip cache dir
id: pip-cache
shell: bash
run: echo "DIR=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Get current week number
id: get-week
shell: bash
run: echo "WEEK=$(date +'%V')" >> $GITHUB_OUTPUT
- name: Pip cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.DIR }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ steps.get-week.outputs.WEEK }}-${{ hashFiles('setup.cfg') }}
- name: Install tox and tox-gh-actions
run: python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox
- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v3
with:
name: unit-test-results-python${{ matrix.python-version }}-${{ matrix.os }}
path: |
test-reports/junit-report.xml
test-reports/coverage.xml
publish-test-results:
name: "Publish Unit Tests Results"
needs: tests
runs-on: ubuntu-latest
if: always()
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
continue-on-error: true
with:
files: artifacts/*/junit-report.xml
- name: Publish Coverage Report for Ubuntu
uses: 5monkeys/cobertura-action@master
if: ${{ github.event_name == 'pull_request' }}
with:
path: artifacts/unit-test-results-python3.12-ubuntu-latest/coverage.xml
repo_token: ${{ secrets.GITHUB_TOKEN }}
pull_request_number: ${{ github.pull_request.number }}
minimum_coverage: 70
fail_below_threshold: false
only_changed_files: true
report_name: Code Coverage (Ubuntu)
- name: Publish Coverage Report for Windows
uses: 5monkeys/cobertura-action@master
if: ${{ github.event_name == 'pull_request' }}
with:
path: artifacts/unit-test-results-python3.12-windows-latest/coverage.xml
repo_token: ${{ secrets.GITHUB_TOKEN }}
pull_request_number: ${{ github.pull_request.number }}
minimum_coverage: 70
fail_below_threshold: false
only_changed_files: true
report_name: Code Coverage (Windows)
check-pypi:
name: Long description check for PyPI
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Update pip
run: python -m pip install --upgrade pip
- name: Get pip cache dir
id: pip-cache
shell: bash
run: echo "DIR=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Get current week number
id: get-week
shell: bash
run: echo "WEEK=$(date +'%V')" >> $GITHUB_OUTPUT
- name: Pip cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.DIR }}
key: ${{ runner.os }}-pip-${{ steps.get-week.outputs.WEEK }}-${{ hashFiles('setup.cfg') }}
- name: Install tox and sphinx (to have rst2html.py utility available)
run: |
python -m pip install tox sphinx
- name: Testing with tox
run: python -m tox -e pypi