forked from pyne/pyne
-
Notifications
You must be signed in to change notification settings - Fork 0
327 lines (292 loc) · 9.89 KB
/
docker_publish.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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
name: Build & Publish docker image for PyNE-CI
on:
# allows us to run workflows manually
workflow_dispatch:
push:
paths:
- 'docker/*'
- '.github/workflows/docker_publish.yml'
jobs:
# builds and pushes two docker images to ghcr.
# These docker images are also cached locally so that they can be efficiently
# accessed by the subsequent stage (build_and_push_dagmc).
build_and_push_python3_pymoab:
runs-on: ubuntu-latest
strategy:
matrix:
ubuntu_versions : [
20.04,
]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Python3
uses: docker/build-push-action@v2
with:
file: docker/ubuntu_20.04-dev.dockerfile
context: .
push: true
build-args: |
py_version=3.8
build_pyne=NO
tags: ghcr.io/${{ github.repository_owner }}/ubuntu_20.04_py3_pyne-deps:ci_testing
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
with:
install: true
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache-${{ github.sha }}
# Key is named differently to avoid collision
key: ${{ runner.os }}-multi-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-multi-buildx
- name: Build and push moab/pymoab
uses: docker/build-push-action@v2
with:
file: docker/ubuntu_20.04-dev.dockerfile
context: .
push: true
build-args: |
py_version=3.8
build_pyne=NO
build_moab=YES
enable_pymoab=YES
tags: ghcr.io/${{ github.repository_owner }}/ubuntu_20.04_py3_pymoab_pyne-deps:ci_testing
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-${{ github.sha }}
# builds on the previous cached images adding extra layers to the base docker
# images created in the previous step. The resulting images include various
# combinations of pymoab dagmc, openmc and hdf5.
build_and_push_dagmc:
needs: build_and_push_python3_pymoab
runs-on: ubuntu-latest
strategy:
matrix:
hdf5 : [
'',
]
dagmc : [
_dagmc
]
pymoab : [
_pymoab,
]
openmc : [
'',
]
include:
- hdf5: _hdf5-1_12_0
dagmc: _dagmc
pymoab: _pymoab
openmc: ''
- hdf5: ''
dagmc: _dagmc
pymoab: _pymoab
openmc: _openmc
fail-fast: false
steps:
- name: setup
shell: bash -l {0}
run: |
if [[ "${{ matrix.pymoab }}" == "_pymoab" || "${{ matrix.dagmc }}" == "_dagmc" ]]; then
echo "PYMOAB=YES" >> $GITHUB_ENV
else
echo "PYMOAB=NO" >> $GITHUB_ENV
fi
if [[ "${{ matrix.dagmc }}" == "_dagmc" ]]; then
echo "DAGMC=YES" >> $GITHUB_ENV
else
echo "DAGMC=NO" >> $GITHUB_ENV
fi
if [[ "${{ matrix.hdf5 }}" == "_hdf5-1_12_0" ]]; then
echo "HDF5=hdf5-1_12_0" >> $GITHUB_ENV
else
echo "HDF5=NO" >> $GITHUB_ENV
fi
if [[ "${{ matrix.openmc }}" == "_openmc" ]]; then
echo "OPENMC=YES" >> $GITHUB_ENV
else
echo "OPENMC=NO" >> $GITHUB_ENV
fi
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
with:
install: true
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache-${{ github.sha }}
# Key is named differently to avoid collision
key: ${{ runner.os }}-multi-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-multi-buildx
- name: Build and push moab/dagmc
uses: docker/build-push-action@v2
with:
file: docker/ubuntu_20.04-dev.dockerfile
context: .
push: true
build-args: |
py_version=3.8
build_pyne=NO
build_moab=YES
enable_pymoab=${{ env.PYMOAB }}
build_dagmc=${{ env.DAGMC }}
build_hdf5=${{ env.HDF5 }}
install_openmc=${{ env.HDF5 }}
cache-from: type=local,src=/tmp/.buildx-cache-${{ github.sha }}
tags: ghcr.io/${{ github.repository_owner }}/ubuntu_20.04_py3${{ matrix.hdf5 }}${{ matrix.dagmc }}${{ matrix.pymoab }}${{ matrix.openmc }}_pyne-deps:ci_testing
# Once the previous two steps have finished the docker images are uploaded
# to ghcr and therefore the local cached images are removed.
cleanup_cache:
if: always()
needs: [build_and_push_python3_pymoab, build_and_push_dagmc]
runs-on: ubuntu-latest
steps:
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache-${{ github.sha }}
# Downloads the images uploaded to ghcr in previous stages and runs pyne
# tests to check that they work.
BuildTest:
needs: [build_and_push_python3_pymoab, build_and_push_dagmc]
runs-on: ubuntu-latest
strategy:
matrix:
hdf5 : [
'',
]
dagmc : [
'',
_dagmc
]
pymoab : [
_pymoab,
]
openmc : [
'',
]
include:
- hdf5: _hdf5-1_12_0
dagmc: _dagmc
pymoab: _pymoab
openmc: ''
- hdf5: ''
dagmc: _dagmc
pymoab: _pymoab
openmc: _openmc
- hdf5: ''
dagmc: ''
pymoab: ''
openmc: ''
fail-fast: false
container:
image: ghcr.io/${{ github.repository_owner }}/ubuntu_20.04_py3${{ matrix.hdf5 }}${{ matrix.dagmc }}${{ matrix.pymoab }}${{ matrix.openmc }}_pyne-deps:ci_testing
steps:
- name: setup
shell: bash -l {0}
run: |
export ADD_FLAG=" "
if [[ "${{ matrix.pymoab }}" == "_pymoab" || "${{ matrix.dagmc }}" == "_dagmc" ]]; then
export ADD_FLAG="${ADD_FLAG} --moab /root/opt/moab"
fi
if [[ "${{ matrix.dagmc }}" == "_dagmc" ]]; then
export ADD_FLAG="${ADD_FLAG} --dagmc /root/opt/dagmc"
fi
if [[ "${{ matrix.hdf5 }}" == "_hdf5-1_12_0" ]]; then
export ADD_FLAG="${ADD_FLAG} --hdf5 /root/opt/hdf5/hdf5-1_12_0"
fi
export ADD_FLAG="${ADD_FLAG} "
echo "ADD_FLAG=${ADD_FLAG}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v2
- name: Building PyNE
shell: bash -l {0}
run: |
cd $GITHUB_WORKSPACE
python setup.py install --user --clean ${{ env.ADD_FLAG}}
export PATH="$PATH:/github/home/.local/bin"
export PYTHONPATH="$PYTHONPATH:/github/home/.local/lib/python3.8/site-packages/"
cd ../
nuc_data_make
- name: Testing PyNE
shell: bash -l {0}
run: |
cd $GITHUB_WORKSPACE/tests
./travis-run-tests.sh python3
# if the previous step that tests the docker images passes then the images
# can be copied from the ghcr where they are saved using :ci_testing tags to
# :latest and :stable tags.
pushing_test_stable_img:
if: ${{ github.repository_owner == 'pyne' }}
needs: [BuildTest]
runs-on: ubuntu-latest
strategy:
matrix:
hdf5 : [
'',
]
dagmc : [
'',
_dagmc
]
pymoab : [
_pymoab,
]
openmc : [
'',
]
include:
- hdf5: _hdf5-1_12_0
dagmc: _dagmc
pymoab: _pymoab
openmc: ''
- hdf5: ''
dagmc: _dagmc
pymoab: _pymoab
openmc: _openmc
- hdf5: ''
dagmc: ''
pymoab: ''
openmc: ''
name: "${{ github.repository_owner }}/ubuntu_20.04_py3${{ matrix.hdf5 }}${{ matrix.dagmc }}${{ matrix.pymoab }}${{ matrix.openmc }}: latest -> stable"
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Image to stable img
uses: akhilerm/[email protected]
with:
src: ghcr.io/${{ github.repository_owner }}/ubuntu_20.04_py3${{ matrix.hdf5 }}${{ matrix.dagmc }}${{ matrix.pymoab }}${{ matrix.openmc }}_pyne-deps:ci_testing
dst: ghcr.io/${{ github.repository_owner }}/ubuntu_20.04_py3${{ matrix.hdf5 }}${{ matrix.dagmc }}${{ matrix.pymoab }}${{ matrix.openmc }}_pyne-deps:stable
- name: Push Image to latest img
uses: akhilerm/[email protected]
with:
src: ghcr.io/${{ github.repository_owner }}/ubuntu_20.04_py3${{ matrix.hdf5 }}${{ matrix.dagmc }}${{ matrix.pymoab }}${{ matrix.openmc }}_pyne-deps:ci_testing
dst: ghcr.io/${{ github.repository_owner }}/ubuntu_20.04_py3${{ matrix.hdf5 }}${{ matrix.dagmc }}${{ matrix.pymoab }}${{ matrix.openmc }}_pyne-deps:latest