-
Notifications
You must be signed in to change notification settings - Fork 16
187 lines (159 loc) · 5.89 KB
/
base.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# .github/workflows/base.yml
name: Build
on:
# this one is to trigger the workflow manually from the interface
workflow_dispatch:
push:
tags:
- '*'
branches:
- main
pull_request:
branches:
- main
defaults:
run:
shell: bash -l {0}
jobs:
# pre-job to read nox tests matrix - see https://stackoverflow.com/q/66747359/7262247
list_nox_test_sessions:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
architecture: x64
- name: Install noxfile requirements
run: pip install -r noxfile-requirements.txt
- name: List 'tests' nox sessions and required python versions
id: set-matrix
run: echo "matrix=$(nox -s gha_list -- -s tests -v)" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }} # save nox sessions list to outputs
run_all_tests:
needs: list_nox_test_sessions
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest ] # , macos-latest, windows-latest]
# all nox sessions: manually > dynamically from previous job
# nox_session: ["tests-2.7", "tests-3.7"]
nox_session: ${{ fromJson(needs.list_nox_test_sessions.outputs.matrix) }}
name: ${{ matrix.os }} ${{ matrix.nox_session.python }} ${{ matrix.nox_session.session }} # ${{ matrix.name_suffix }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install python ${{ matrix.nox_session.python }} for tests
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.nox_session.python }}
architecture: x64
- name: Install python 3.9 for nox
uses: actions/setup-python@v4
with:
python-version: 3.9
architecture: x64
- name: Install noxfile requirements
run: pip install -r noxfile-requirements.txt
- name: Run nox session ${{ matrix.nox_session.session }}
run: nox -s "${{ matrix.nox_session.session }}"
# Share ./docs/reports so that they can be deployed with doc in next job
- name: Share reports with other jobs
# if: matrix.nox_session == '...': not needed, if empty wont be shared
uses: actions/upload-artifact@master
with:
name: reports_dir
path: ./docs/reports
# build_doc: useless in our case since own doc is part of the tests session
# runs-on: ubuntu-latest
# if: github.event_name == 'pull_request'
# steps:
# - name: Checkout
# uses: actions/checkout@v2
#
# - name: Install python 3.9 for nox
# uses: actions/setup-python@v4
# with:
# python-version: 3.9
# architecture: x64
#
# - name: Install noxfile requirements
# run: pip install -r noxfile-requirements.txt
#
# - name: Build the doc including example gallery
# run: nox -s docs -- build
publish_release:
needs: run_all_tests
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: GitHub context to debug conditional steps
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Checkout with no depth
uses: actions/checkout@v2
with:
fetch-depth: 0 # so that gh-deploy works
- name: Install python 3.9 for nox
uses: actions/setup-python@v4
with:
python-version: 3.9
architecture: x64
# 1) retrieve the reports generated previously
- name: Retrieve reports
uses: actions/download-artifact@master
with:
name: reports_dir
path: ./docs/reports
# Nox install
- name: Install noxfile requirements
run: pip install -r noxfile-requirements.txt
# 5) Run the flake8 report and badge
- name: Run flake8 analysis and generate corresponding badge
run: nox -s flake8
# -------------- only on Ubuntu + MAIN PUSH (no pull request, no tag) -----------
# 5) Publish the doc and test reports
- name: \[not on TAG\] Publish documentation, tests and coverage reports
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads') # startsWith(matrix.os,'ubuntu')
run: nox -s publish
# 6) Publish coverage report
- name: \[not on TAG\] Create codecov.yaml with correct paths
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads')
shell: bash
run: |
cat << EOF > codecov.yml
# codecov.yml
fixes:
- "/home/runner/work/smarie/mkdocs-gallery/::" # Correct paths
EOF
- name: \[not on TAG\] Publish coverage report
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads')
uses: codecov/codecov-action@v1
with:
files: ./docs/reports/coverage/coverage.xml
# -------------- only on Ubuntu + TAG PUSH (no pull request) -----------
# 7) Create github release and build the wheel
- name: \[TAG only\] Build wheel and create github release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
run: nox -s release -- ${{ secrets.GITHUB_TOKEN }}
# 8) Publish the wheel on PyPi
- name: \[TAG only\] Deploy on PyPi
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
delete-artifacts:
needs: publish_release
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: kolpav/purge-artifacts-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
expire-in: 0 # Setting this to 0 will delete all artifacts