-
Notifications
You must be signed in to change notification settings - Fork 134
272 lines (230 loc) · 9.45 KB
/
build-images.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
# Build all container images.
#
name: Build images
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
paths-ignore:
- '.circleci/**'
- 'docs/**'
- 'test/**'
env:
# Used to override BIOCONDA_UTILS_VERSION in images/versions.sh
BIOCONDA_UTILS_VERSION: ${{ github.event.release && github.event.release.tag_name || github.head_ref || github.ref_name }}
jobs:
# JOBS FOR BUILDING IMAGES
# ----------------------------------------------------------------------
# These jobs will build images for archs, put them into a manifest, and push
# that to GitHub Container Registry. Later, the testing jobs will test and
# push to quay.io.
build-base-debian:
name: Build base-debian
runs-on: ubuntu-22.04
outputs:
# A note on these TAG_EXISTS_* outputs: these allow subsequent jobs to
# change behavior (e.g., skip building or skip pushing to ghcr) depending
# on whether an image has already been created.
TAG_EXISTS_base-debian: ${{ steps.base-debian.outputs.TAG_EXISTS_base-debian }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install qemu dependency
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: base-debian
id: base-debian
run: |
source images/versions.sh
if [ $(tag_exists $BASE_DEBIAN_IMAGE_NAME $BASE_TAG) ]; then
echo "TAG_EXISTS_base-debian=true" >> $GITHUB_OUTPUT
else
cd images && bash build.sh base-glibc-debian-bash
fi
- name: push to ghcr
if: '${{ ! steps.base-debian.outputs.TAG_EXISTS_base-debian }}'
run: |
echo '${{ secrets.GITHUB_TOKEN }}' | podman login ghcr.io -u '${{ github.actor }}' --password-stdin
source images/versions.sh
push_to_ghcr $BASE_DEBIAN_IMAGE_NAME $BASE_TAG
build-base-busybox:
name: Build base-busybox
runs-on: ubuntu-22.04
outputs:
TAG_EXISTS_base-busybox: ${{ steps.base-busybox.outputs.TAG_EXISTS_base-busybox }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install qemu dependency
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: base-busybox
id: base-busybox
run: |
source images/versions.sh
if [ $(tag_exists $BASE_BUSYBOX_IMAGE_NAME $BASE_TAG) ]; then
echo "TAG_EXISTS_base-busybox=true" >> $GITHUB_OUTPUT
else
cd images && bash build.sh base-glibc-busybox-bash
fi
- name: push to ghcr
if: '${{ ! steps.base-busybox.outputs.TAG_EXISTS_base-busybox }}'
run: |
echo '${{ secrets.GITHUB_TOKEN }}' | podman login ghcr.io -u '${{ github.actor }}' --password-stdin
source images/versions.sh
push_to_ghcr $BASE_BUSYBOX_IMAGE_NAME $BASE_TAG
build-build-env:
name: Build build-env
outputs:
TAG_EXISTS_build-env: ${{ steps.build-env.outputs.TAG_EXISTS_build-env }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install qemu dependency
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: build-env
id: build-env
run: |
source images/versions.sh
if [ $(tag_exists $BUILD_ENV_IMAGE_NAME $BIOCONDA_IMAGE_TAG) ]; then
echo "TAG_EXISTS_build-env=true" >> $GITHUB_OUTPUT
else
cd images && bash build.sh bioconda-utils-build-env-cos7
fi
- name: push to ghcr
if: '${{ ! steps.build-env.outputs.TAG_EXISTS_build-env }}'
run: |
echo '${{ secrets.GITHUB_TOKEN }}' | podman login ghcr.io -u '${{ github.actor }}' --password-stdin
source images/versions.sh
push_to_ghcr $BUILD_ENV_IMAGE_NAME $BIOCONDA_IMAGE_TAG
build-create-env:
name: Build create-env
needs: [build-build-env, build-base-busybox]
outputs:
TAG_EXISTS_create-env: ${{ steps.create-env.outputs.TAG_EXISTS_create-env }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install qemu dependency
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Build create-env
id: create-env
run: |
source images/versions.sh
echo '${{ secrets.GITHUB_TOKEN }}' | podman login ghcr.io -u '${{ github.actor }}' --password-stdin
if [ $(tag_exists $CREATE_ENV_IMAGE_NAME $BIOCONDA_IMAGE_TAG) ]; then
echo "TAG_EXISTS_create-env=true" >> $GITHUB_OUTPUT
else
cd images && bash build.sh create-env
fi
- name: push to ghcr
if: '${{ ! steps.create-env.outputs.TAG_EXISTS_create-env }}'
run: |
echo '${{ secrets.GITHUB_TOKEN }}' | podman login ghcr.io -u '${{ github.actor }}' --password-stdin
source images/versions.sh
push_to_ghcr $CREATE_ENV_IMAGE_NAME $BIOCONDA_IMAGE_TAG
# END OF BUILDING IMAGES
# ----------------------------------------------------------------------
# START TESTING
# These testing jobs will run the respective Dockerfile.test in each image
# directory.
test:
name: test bioconda-utils with images
runs-on: ubuntu-20.04
needs: [build-base-debian, build-base-busybox, build-build-env, build-create-env]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Clone bioconda-recipes to use as part of the tests.
- uses: actions/checkout@v4
with:
fetch-depth: 0
repository: bioconda/bioconda-recipes
path: recipes
- name: set path
run: echo "/opt/mambaforge/bin" >> $GITHUB_PATH
- name: Install bioconda-utils
run: |
export BIOCONDA_DISABLE_BUILD_PREP=1
wget https://raw.githubusercontent.com/bioconda/bioconda-common/master/{common,install-and-set-up-conda,configure-conda}.sh
bash install-and-set-up-conda.sh
eval "$(conda shell.bash hook)"
mamba create -n bioconda -y --file test-requirements.txt --file bioconda_utils/bioconda_utils-requirements.txt
conda activate bioconda
python setup.py install
- name: test
run: |
eval "$(conda shell.bash hook)"
conda activate bioconda
source images/versions.sh
# Figure out which registry to use for each image, based on what was built.
[ ${{ needs.build-build-env.outputs.TAG_EXISTS_build-env }} ] && BUILD_ENV_REGISTRY='quay.io/bioconda' || BUILD_ENV_REGISTRY="ghcr.io/bioconda"
[ ${{ needs.build-create-env.outputs.TAG_EXISTS_create-env }} ] && CREATE_ENV_REGISTRY='quay.io/bioconda' || CREATE_ENV_REGISTRY="ghcr.io/bioconda"
[ ${{ needs.build-base-busybox.outputs.TAG_EXISTS_base_busybox }} ] && DEST_BASE_IMAGE_REGISTRY='quay.io/bioconda' || DEST_BASE_REGISTRY="ghcr.io/bioconda"
# Tell mulled-build which image to use
export DEST_BASE_IMAGE="${DEST_BASE_IMAGE_REGISTRY}/${BASE_BUSYBOX_IMAGE_NAME}:${BASE_TAG}"
# Build a package with containers.
cd recipes
bioconda-utils build \
--docker-base-image "${BUILD_ENV_REGISTRY}/${BUILD_ENV_IMAGE_NAME}:${BIOCONDA_IMAGE_TAG}" \
--mulled-conda-image "${CREATE_ENV_REGISTRY}/${CREATE_ENV_IMAGE_NAME}:${BIOCONDA_IMAGE_TAG}" \
--packages seqtk \
--docker \
--mulled-test \
--force
# END TESTING
# ------------------------------------------------------------------------
# START PUSHING IMAGES
# For these push steps, a repository must first exist on quay.io/bioconda
# AND that repository must also be configured to allow write access for the
# appropriate service account. This must be done by a user with admin
# access to quay.io/bioconda.
#
# This uses the TAG_EXISTS_* outputs from previous jobs to determine if
# a push to quay.io should happen.
push:
name: push images
runs-on: ubuntu-20.04
needs: [build-base-debian, build-base-busybox, build-build-env, build-create-env, test]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: push base-debian
if: ${{ ! needs.base-debian.outputs.TAG_EXISTS_base-debian }}
run: |
echo '${{ secrets.QUAY_BIOCONDA_TOKEN }}' | podman login quay.io -u '${{ secrets.QUAY_BIOCONDA_USERNAME }}' --password-stdin
source images/versions.sh
move_from_ghcr_to_quay ${BASE_DEBIAN_IMAGE_NAME} ${BASE_TAG}
- name: push base-busybox
if: ${{ ! needs.base-busybox.outputs.TAG_EXISTS_base-busybox }}
run: |
echo '${{ secrets.QUAY_BIOCONDA_TOKEN }}' | podman login quay.io -u '${{ secrets.QUAY_BIOCONDA_USERNAME }}' --password-stdin
source images/versions.sh
move_from_ghcr_to_quay ${BASE_BUSYBOX_IMAGE_NAME} ${BASE_TAG}
- name: push create-env
if: ${{ ! needs.create-env.outputs.TAG_EXISTS_create-env }}
run: |
echo '${{ secrets.QUAY_BIOCONDA_TOKEN }}' | podman login quay.io -u '${{ secrets.QUAY_BIOCONDA_USERNAME }}' --password-stdin
source images/versions.sh
move_from_ghcr_to_quay ${CREATE_ENV_IMAGE_NAME} ${BIOCONDA_IMAGE_TAG}
- name: push build-env
if: ${{ ! needs.build-env.outputs.TAG_EXISTS_build-env }}
run: |
echo '${{ secrets.QUAY_BIOCONDA_TOKEN }}' | podman login quay.io -u '${{ secrets.QUAY_BIOCONDA_USERNAME }}' --password-stdin
source images/versions.sh
move_from_ghcr_to_quay ${BUILD_ENV_IMAGE_NAME} ${BIOCONDA_IMAGE_TAG}