-
Notifications
You must be signed in to change notification settings - Fork 6
201 lines (194 loc) · 7 KB
/
pipeline.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: Pipeline
on: push
jobs:
code-quality:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
- name: Run pylint and black
run: |
source .venv/bin/activate
pylint build tests
black --check .
run-build-image-tests:
needs: code-quality
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python_version: ["3.10.13", "3.11.6", "3.12.0"]
os_variant: ["bookworm", "slim-bookworm"]
poetry_version: ["1.4.2", "1.5.1", "1.6.1"]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
- name: Run tests for image builds with pytest
env:
PYTHON_VERSION: ${{ matrix.python_version }}
OS_VARIANT: ${{ matrix.os_variant }}
POETRY_VERSION: ${{ matrix.poetry_version }}
run: |
source .venv/bin/activate
pytest tests/build_image --cov --cov-report=xml:build_image_coverage_report.xml
- name: Upload coverage report to artifactory
uses: actions/upload-artifact@v3
with:
name: build-image-coverage-report-${{ matrix.python_version }}-${{ matrix.os_variant }}-${{ matrix.poetry_version }}
path: build_image_coverage_report.xml
if-no-files-found: error
retention-days: 1
run-publish-image-tests:
needs: code-quality
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python_version: ["3.10.13", "3.11.6", "3.12.0"]
os_variant: ["bookworm", "slim-bookworm"]
poetry_version: ["1.4.2", "1.5.1", "1.6.1"]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
- name: Run tests for image publishing with pytest
env:
PYTHON_VERSION: ${{ matrix.python_version }}
OS_VARIANT: ${{ matrix.os_variant }}
POETRY_VERSION: ${{ matrix.poetry_version }}
run: |
source .venv/bin/activate
pytest tests/publish_image --cov --cov-report=xml:publish_image_coverage_report.xml
- name: Upload coverage report to artifactory
uses: actions/upload-artifact@v3
with:
name: publish-image-coverage-report-${{ matrix.python_version }}-${{ matrix.os_variant }}-${{ matrix.poetry_version }}
path: publish_image_coverage_report.xml
if-no-files-found: error
retention-days: 1
upload-test-coverage-reports:
needs:
- run-build-image-tests
- run-publish-image-tests
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download coverage reports from artifactory
uses: actions/download-artifact@v3
- name: Compile the relevant reports
run: |
find . -name "*.xml" -exec cp {} . \;
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./build_image_coverage_report.xml,./publish_image_coverage_report.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
publish-all-images:
needs:
- upload-test-coverage-reports
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python_version: ["3.10.13", "3.11.6", "3.12.0"]
os_variant: ["bookworm", "slim-bookworm"]
poetry_version: ["1.4.2", "1.5.1", "1.6.1"]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Get Git Commit Tag Name
uses: olegtarasov/[email protected]
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
- name: Publish Images to Docker Hub
env:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
PYTHON_VERSION: ${{ matrix.python_version }}
OS_VARIANT: ${{ matrix.os_variant }}
POETRY_VERSION: ${{ matrix.poetry_version }}
run: |
source .venv/bin/activate
python -m build.publish