-
Notifications
You must be signed in to change notification settings - Fork 49
205 lines (184 loc) · 5.66 KB
/
test.yml
File metadata and controls
205 lines (184 loc) · 5.66 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
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
name: Test
on:
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.x
cache: "pip"
- name: Install pip packages
run: |
python -m pip install --upgrade pip
- name: flake8
run: |
pip install flake8
flake8 .
- name: pydocstyle
run: |
pip install pydocstyle
pydocstyle .
action-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.x
cache: pip
- name: Run unit tests
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m unittest discover -s .github/actions -p 'test_*.py'
targets:
runs-on: ubuntu-latest
outputs:
amd64: ${{ steps.amd64.outputs.distros }}
arm64: ${{ steps.arm64.outputs.distros }}
has_changes: ${{ steps.filter.outputs.affected }}
steps:
- name: Checkout Repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Find changed files
uses: dorny/paths-filter@v3
id: filter
with:
list-files: csv
filters: |
docker:
- '*/*.Dockerfile'
action:
- '.github/actions/docker-*/*'
affected:
- '*/*.Dockerfile'
- '.github/actions/docker-*/*'
- name: amd64 targets
run: |
{
echo "## AMD64"
} >> "$GITHUB_STEP_SUMMARY"
- name: Generate list of amd64 targets (filtered)
id: amd64
uses: ./.github/actions/docker-targets
with:
changed: ${{ steps.filter.outputs.docker_files }}
all: ${{ steps.filter.outputs.action }}
- name: arm64 targets
run: |
{
echo "## ARM64"
} >> "$GITHUB_STEP_SUMMARY"
- name: Generate list of arm64 targets (filtered)
id: arm64
uses: ./.github/actions/docker-targets
with:
platform: "linux/arm64"
changed: ${{ steps.filter.outputs.docker_files }}
all: ${{ steps.filter.outputs.action }}
bake-build-amd64:
name: Build (${{ matrix.family }}:${{ matrix.distro }} @ amd64
needs: targets
if: ${{ needs.targets.outputs.has_changes == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.targets.outputs.amd64) }}
steps:
- uses: actions/checkout@v6
- name: Build via composite action
uses: ./.github/actions/docker-bake
with:
family: ${{ matrix.family }} # e.g. ros2
distro: ${{ matrix.distro }} # e.g. rolling
ghcr-username: ${{ github.actor }} # optional
ghcr-password: ${{ secrets.GITHUB_TOKEN }} # optional
push: "false"
bake-build-arm64:
name: Build (${{ matrix.family }}:${{ matrix.distro }} @ arm64)
needs: targets
if: ${{ needs.targets.outputs.has_changes == 'true' }}
runs-on: ubuntu-24.04-arm
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.targets.outputs.arm64) }}
steps:
- uses: actions/checkout@v6
- name: Build via composite action
uses: ./.github/actions/docker-bake
with:
family: ${{ matrix.family }} # e.g. ros2
distro: ${{ matrix.distro }} # e.g. rolling
ghcr-username: ${{ github.actor }} # optional
ghcr-password: ${{ secrets.GITHUB_TOKEN }} # optional
push: "false"
merge-manifests:
name: Merge manifests (${{ matrix.family }}:${{ matrix.distro }})
needs:
- bake-build-amd64
- bake-build-arm64
- targets
if: ${{ needs.targets.outputs.has_changes == 'true' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.targets.outputs.amd64) }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- name: Download bake metadata artifacts
uses: actions/download-artifact@v7
with:
pattern: bake-metadata-${{ matrix.family }}-${{ matrix.distro }}-*
path: bake-metadata
merge-multiple: true
- name: Merge manifests
uses: ./.github/actions/docker-merge
with:
family: ${{ matrix.family }}
distro: ${{ matrix.distro }}
metadata: |
bake-metadata
ghcr-username: ${{ github.repository_owner }}
ghcr-password: ${{ secrets.GITHUB_TOKEN }}
dry-run: "true"
complete:
needs:
- lint
- action-tests
- merge-manifests
if: ${{ always() && !cancelled() && needs.merge-manifests.result != 'cancelled' }}
runs-on: ubuntu-latest
steps:
- name: Check
run: |
if [ "${{ needs.lint.result }}" != 'success' ]; then
echo "Lint failed"
exit 1
fi
if [ "${{ needs.action-tests.result }}" != 'success' ]; then
echo "Action tests failed"
exit 1
fi
if [ "${{ needs.merge-manifests.result }}" != 'skipped' ] && \
[ "${{ needs.merge-manifests.result }}" != 'success' ]; then
echo "Docker failed"
exit 1
fi
echo "Completed successfully"