-
Notifications
You must be signed in to change notification settings - Fork 4
225 lines (198 loc) · 8.3 KB
/
Copy pathbuild-pull-request.yaml
File metadata and controls
225 lines (198 loc) · 8.3 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
name: Build Pull Request
on:
pull_request:
branches:
- '**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
actions: write
packages: read
jobs:
cpp-linter:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: cpp-linter/cpp-linter-action@main
id: linter
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
style: file
ignore: third_party
lines-changed-only: true
thread-comments: update
format-review: false
tidy-checks: '-*'
tidy-review: false
step-summary: true
file-annotations: true
- name: Fail fast?!
if: steps.linter.outputs.checks-failed != 0
run: |
echo "some linter checks failed. ${{ steps.linter.outputs.checks-failed }}"
exit 1
build-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
target: [release, develop]
config: &build_configs
- os: ubuntu24.04
cuda_version: 13.2.0
optix_version: 9.1.0
geant4_version: 11.4.1
cmake_version: 4.3.1
- os: ubuntu24.04
cuda_version: 13.0.2
optix_version: 9.0.0
geant4_version: 11.4.1
cmake_version: 4.2.1
- os: ubuntu24.04
cuda_version: 12.5.1
optix_version: 9.0.0
geant4_version: 11.4.1
cmake_version: 3.28.3
- os: ubuntu22.04
cuda_version: 12.1.1
optix_version: 8.0.0
geant4_version: 11.3.2
cmake_version: 3.22.1
steps:
- name: Define environment variables
run: |
IMAGE_NAME=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')-buildcache
REF_SANITIZED=PR-${{ github.event.pull_request.number }}
BASE_VARIANT=cuda${{ matrix.config.cuda_version }}-base-${{ matrix.config.os }}-optix${{ matrix.config.optix_version }}-geant4${{ matrix.config.geant4_version }}-cmake${{ matrix.config.cmake_version }}
BUILD_VARIANT=cuda${{ matrix.config.cuda_version }}-${{ matrix.target }}-${{ matrix.config.os }}-optix${{ matrix.config.optix_version }}-geant4${{ matrix.config.geant4_version }}-cmake${{ matrix.config.cmake_version }}
echo IMAGE_NAME=${IMAGE_NAME} >> $GITHUB_ENV
echo IMAGE_TAG=${REF_SANITIZED}-${BUILD_VARIANT} >> $GITHUB_ENV
echo BASE_CACHE_REF=${IMAGE_NAME}:${BASE_VARIANT} >> $GITHUB_ENV
echo CACHE_REF=${IMAGE_NAME}:${BUILD_VARIANT} >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build PR image
uses: docker/build-push-action@v6
with:
context: .
tags: |
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
target: ${{ matrix.target }}
build-args: |
OS=${{ matrix.config.os }}
CUDA_VERSION=${{ matrix.config.cuda_version }}
OPTIX_VERSION=${{ matrix.config.optix_version }}
GEANT4_VERSION=${{ matrix.config.geant4_version }}
CMAKE_VERSION=${{ matrix.config.cmake_version }}
cache-from: |
type=registry,ref=${{ env.BASE_CACHE_REF }}
type=registry,ref=${{ env.CACHE_REF }}
push: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
test-image:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
needs: build-image
runs-on: [gpu]
permissions:
contents: read
packages: read
strategy:
fail-fast: false
matrix:
target: [release, develop]
config: *build_configs
exclude:
# The gpu runner driver does not support OptiX 9.1.0 yet
- config:
os: ubuntu24.04
cuda_version: 13.2.0
optix_version: 9.1.0
geant4_version: 11.4.1
cmake_version: 4.3.1
steps:
- name: Define environment variables
run: |
IMAGE_NAME=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')-buildcache
REF_SANITIZED=PR-${{ github.event.pull_request.number }}
BUILD_VARIANT=cuda${{ matrix.config.cuda_version }}-${{ matrix.target }}-${{ matrix.config.os }}-optix${{ matrix.config.optix_version }}-geant4${{ matrix.config.geant4_version }}-cmake${{ matrix.config.cmake_version }}
echo IMAGE_NAME=${IMAGE_NAME} >> $GITHUB_ENV
echo IMAGE_TAG=${REF_SANITIZED}-${BUILD_VARIANT} >> $GITHUB_ENV
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull PR image
run: |
docker pull ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
- name: Run tests
run: |
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} bash -lc 'ctest --test-dir "$SIMPHONY_BUILD"'
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tests/test_GPURaytrace.sh
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tests/test_triangulated.sh
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tests/test_triangulated_multi.sh
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tests/test_GPUPhotonFileSource.sh
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tests/test_GPUPhotonSource_8x8SiPM.sh
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tests/test_wavelength_shifting.sh
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tests/g4trap_validation.sh
- name: Build and run external example
run: |
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} bash -lc examples/simphox/run.sh
- name: Cleanup local test image
if: ${{ success() }}
run: |
docker image rm -f ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} || true
cleanup-pr-images:
if: ${{ success() && github.event.pull_request.head.repo.full_name == github.repository }}
needs: test-image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
target: [release, develop]
config: *build_configs
steps:
- name: Define environment variables
run: |
PACKAGE_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')-buildcache
REF_SANITIZED=PR-${{ github.event.pull_request.number }}
BUILD_VARIANT=cuda${{ matrix.config.cuda_version }}-${{ matrix.target }}-${{ matrix.config.os }}-optix${{ matrix.config.optix_version }}-geant4${{ matrix.config.geant4_version }}-cmake${{ matrix.config.cmake_version }}
echo PACKAGE_NAME=${PACKAGE_NAME} >> $GITHUB_ENV
echo IMAGE_TAG=${REF_SANITIZED}-${BUILD_VARIANT} >> $GITHUB_ENV
- name: Delete successful PR image from GHCR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
run: |
VERSION_ID=$(
gh api --paginate "/orgs/$OWNER/packages/container/$PACKAGE_NAME/versions?per_page=100" \
--jq ".[] | select((.metadata.container.tags // []) | index(\"$IMAGE_TAG\")) | .id" \
| head -n 1
)
if [ -z "$VERSION_ID" ]; then
echo "No GHCR version found with tag $IMAGE_TAG"
exit 0
fi
echo "Deleting GHCR version $VERSION_ID for tag $IMAGE_TAG"
gh api -X DELETE "/orgs/$OWNER/packages/container/$PACKAGE_NAME/versions/$VERSION_ID"