-
Notifications
You must be signed in to change notification settings - Fork 1
220 lines (212 loc) · 7.08 KB
/
build-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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# SPDX-FileCopyrightText: 2023 Ross Patterson <me@rpatterson.net>
#
# SPDX-License-Identifier: MIT
name: "Build and Test"
# TEMPLATE: If the project uses GitHub Actions, then add the following secrets to the
# project:
#
# - `CODECOV_TOKEN`:
# Add your project to https://app.codecov.io/gl and use the generated token
#
# - `DOCKER_PASS`:
# A Docker Hub Personal Access Token
#
# - `GPG_PASSPHRASE`:
# See the comments towards the bottom of the `./Makefile`
#
# - `GPG_SIGNING_PRIVATE_KEY`:
# See the comments towards the bottom of the `./Makefile`
#
# - `PROJECT_GITHUB_PAT`:
# A GitHub "Classic" Personal Access Token with scopes: `repo`, `workflow`,
# `packages`, and `project`
#
# - `PYPI_PASSWORD`:
# A PyPI API token
#
# - `TEST_PYPI_PASSWORD`:
# A PyPI API token
#
# - Add the project logo to the GitHub Social Preview:
# https://github.com/rpatterson/project-structure/settings
#
# Add them through the web UI or use the GitHub command-line tool:
# https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository
#
# You can also add the `ACTIONS_STEP_DEBUG` and `DEBUG` Actions variables and set them
# to `true` to increase debugging output.
env:
PUID: "1001"
PGID: "1001"
# Project specific values:
PROJECT_NAMESPACE: "rpatterson"
GPG_PASSPHRASE: "${{ secrets.GPG_PASSPHRASE }}"
GPG_SIGNING_PRIVATE_KEY: "${{ secrets.GPG_SIGNING_PRIVATE_KEY }}"
DOCKER_PASS: "${{ secrets.DOCKER_PASS }}"
# Enable the GitHub command-line:
PROJECT_GITHUB_PAT: "${{ secrets.PROJECT_GITHUB_PAT }}"
# Tell the `./Makefile` about GitHub specific environment details:
CI_IS_FORK: >-
${{
(
(
(github.repository_owner != '${PROJECT_NAMESPACE}')
|| (github.event.pull_request.head.repo.owner.login != '${PROJECT_NAMESPACE}')
) && 'true'
) || 'false'
}}
DEBUG: "${{ vars.DEBUG }}"
on:
# Run only on branches, not tags:
# https://github.com/orgs/community/discussions/25615#discussioncomment-3397691
push:
branches:
- "**"
tags:
- "!**"
# Also run for open pull requests, including when pushed to:
pull_request: {}
jobs:
build-test-default:
runs-on: "ubuntu-latest"
container:
# TEMPLATE: Only change these if you customize the `./build-host/Dockerfile` image.
# Otherwise use the version of this image from the project template in your CI/CD.
image: "ghcr.io/rpatterson/project-structure:build-host"
env:
CHECKOUT_DIR: "${{ github.workspace }}"
permissions:
packages: "write"
checks: "write"
strategy:
matrix:
DOCKER_OSES:
- "debian"
DOCKER_LANGUAGES:
- "py311"
env:
DOCKER_OSES: "${{ matrix.DOCKER_OSES }}"
DOCKER_LANGUAGES: "${{ matrix.DOCKER_LANGUAGES }}"
steps:
# Shared or common set up:
- name: "Checkout source from VCS"
uses: "actions/checkout@master"
# TODO: Debug stale venv issues and restore cache after fixing.
# Delegate steps agnostic of the CI/CD platform to the `./Makefile`:
- name: "Build image and run tests and checks in a container"
run: >-
git config --global --add safe.directory
/__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}
&&
init-job.sh entrypoint.sh make -j -O release-all
# Upload build artifacts:
# https://github.com/actions/upload-artifact#usage
- name: "Upload built packages"
uses: "actions/upload-artifact@master"
with:
name: "built-pkgs"
path: |
./dist/project?structure-*
- name: "Archive test, coverage, and lint reports"
uses: "actions/upload-artifact@master"
with:
name: "test-coverage-lint-reports"
path: |
./build/reports/
- name: "Publish test suite report"
uses: "dorny/test-reporter@main"
# run this step even if preceding step failed
if: >-
(success() || failure())
&& (
(! github.event.pull_request)
|| ! (
(github.repository_owner == '${PROJECT_NAMESPACE}')
&& (
github.event.pull_request.head.repo.owner.login
!= '${PROJECT_NAMESPACE}'
)
)
)
with:
name: >-
Test Suite Reports
(${{ matrix.DOCKER_OSES }}-${{ matrix.DOCKER_LANGUAGES }})
path: >-
./build/reports/*/*unit.xml
reporter: "java-junit"
build-test-others:
needs: ["build-test-default"]
runs-on: "ubuntu-latest"
container:
# TEMPLATE: Only change these if you customize the `./build-host/Dockerfile` image.
# Otherwise use the version of this image from the project template in your CI/CD.
image: "ghcr.io/rpatterson/project-structure:build-host"
env:
CHECKOUT_DIR: "${{ github.workspace }}"
permissions:
packages: "write"
checks: "write"
strategy:
matrix:
DOCKER_OSES:
- "debian"
DOCKER_LANGUAGES:
- "py312"
- "py310"
- "py39"
- "py38"
env:
DOCKER_OSES: "${{ matrix.DOCKER_OSES }}"
DOCKER_LANGUAGES: "${{ matrix.DOCKER_LANGUAGES }}"
PYTHON_PKG_EXISTING: "true"
steps:
# Shared or common set up:
- name: "Checkout source from VCS"
uses: "actions/checkout@master"
- name: "Download built packages"
uses: "actions/download-artifact@master"
with:
name: "built-pkgs"
path: |
./dist/
# TODO: Debug stale venv issues and restore cache after fixing.
# Delegate steps agnostic of the CI/CD platform to the `./Makefile`:
- name: "Build image and run tests and checks in a container"
run: >-
git config --global --add safe.directory
/__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}
&&
init-job.sh entrypoint.sh make -j -O release-all
# Upload build artifacts:
# https://github.com/actions/upload-artifact#usage
- name: "Archive test, coverage, and lint reports"
uses: "actions/upload-artifact@master"
with:
name: "\
test-coverage-lint-reports\
-${{ matrix.DOCKER_OSES }}-${{ matrix.DOCKER_LANGUAGES }}"
path: |
./build/reports/
- name: "Publish test suite report"
uses: "dorny/test-reporter@main"
# run this step even if preceding step failed
if: >-
(success() || failure())
&& (
(! github.event.pull_request)
|| ! (
(github.repository_owner == '${PROJECT_NAMESPACE}')
&& (
github.event.pull_request.head.repo.owner.login
!= '${PROJECT_NAMESPACE}'
)
)
)
with:
name: >-
Test Suite Reports
(${{ matrix.DOCKER_OSES }}-${{ matrix.DOCKER_LANGUAGES }})
path: >-
./build/reports/*/*unit.xml
reporter: "java-junit"