Skip to content

Commit 7a8bb84

Browse files
committed
Backport workflows from 3.22 to 3.21
1 parent 5d6faad commit 7a8bb84

File tree

5 files changed

+315
-47
lines changed

5 files changed

+315
-47
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Build Apptainer Images
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_run:
6+
workflows: ["Build container images for GHCR and Dockerhub"]
7+
types:
8+
- completed
9+
10+
jobs:
11+
build-apptainer:
12+
runs-on: ubuntu-latest
13+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
image:
18+
- r-ver
19+
- bioconductor
20+
- tidyverse
21+
- shiny
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Get branch and tag info
27+
id: vars
28+
run: |
29+
BRANCH_NAME=${GITHUB_REF#refs/heads/}
30+
echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT
31+
32+
# Convert repository owner to lowercase
33+
OWNER_LOWER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
34+
echo "owner=$OWNER_LOWER" >> $GITHUB_OUTPUT
35+
36+
- name: Install Apptainer
37+
run: |
38+
# Install Apptainer from official Ubuntu/Debian repository
39+
sudo add-apt-repository -y ppa:apptainer/ppa
40+
sudo apt-get update
41+
sudo apt-get install -y apptainer
42+
43+
- name: Verify Apptainer installation
44+
run: |
45+
apptainer version
46+
apptainer --version
47+
48+
- name: Build Apptainer image from Docker
49+
run: |
50+
DOCKER_IMAGE="ghcr.io/${{ steps.vars.outputs.owner }}/${{ matrix.image }}:${{ steps.vars.outputs.branch }}"
51+
SIF_FILE="${{ matrix.image }}-${{ steps.vars.outputs.branch }}.sif"
52+
53+
echo "Building Apptainer image from: $DOCKER_IMAGE"
54+
echo "Output file: $SIF_FILE"
55+
56+
apptainer build "$SIF_FILE" "docker://$DOCKER_IMAGE"
57+
58+
# Verify the image was created
59+
ls -lh "$SIF_FILE"
60+
apptainer inspect "$SIF_FILE"
61+
62+
- name: Login to GitHub Container Registry
63+
run: |
64+
echo "${{ secrets.GITHUB_TOKEN }}" | apptainer remote login -u ${{ github.actor }} --password-stdin oras://ghcr.io
65+
66+
- name: Push to GitHub Container Registry
67+
run: |
68+
SIF_FILE="${{ matrix.image }}-${{ steps.vars.outputs.branch }}.sif"
69+
DEST="oras://ghcr.io/${{ steps.vars.outputs.owner }}/${{ matrix.image }}-apptainer:${{ steps.vars.outputs.branch }}"
70+
71+
echo "Pushing to: $DEST"
72+
apptainer push "$SIF_FILE" "$DEST"
73+
74+
echo "Successfully pushed Apptainer image for ${{ matrix.image }}"

.github/workflows/build_containers.yaml

Lines changed: 80 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
branches:
55
- devel
66
- RELEASE_*
7+
paths-ignore:
8+
- 'extensions/**'
79
workflow_dispatch:
810
schedule:
911
- cron: '0 18 * * 5'
@@ -17,14 +19,15 @@ jobs:
1719
base:
1820
- {image: 'rocker/r-ver', amdtag: '4.5.2', outname: 'r-ver'}
1921
- {image: 'rocker/rstudio', amdtag: '4.5.2', outname: 'bioconductor_docker'}
22+
- {image: 'ghcr.io/bioconductor/rocker-cuda', amdtag: '4.5.2-amd64', outname: 'jupyterlab-ml'}
2023
- {image: 'rocker/tidyverse', amdtag: '4.5.2', outname: 'tidyverse'}
21-
#- {image: 'ghcr.io/bioconductor/rocker-cuda', amdtag: 'devel-amd64', outname: 'cuda'}
22-
#- {image: 'ghcr.io/bioconductor/rocker-ml', amdtag: 'devel-amd64', outname: 'ml'}
23-
#- {image: 'ghcr.io/bioconductor/rocker-ml-verse', amdtag: 'devel-amd64', outname: 'ml-verse'}
2424
- {image: 'rocker/shiny', amdtag: '4.5.2', outname: 'shiny'}
25+
# - {image: 'ghcr.io/bioconductor/rocker-cuda', amdtag: 'devel-amd64', outname: 'cuda'}
26+
# - {image: 'ghcr.io/bioconductor/rocker-ml', amdtag: 'devel-amd64', outname: 'ml'}
27+
# - {image: 'ghcr.io/bioconductor/rocker-ml-verse', amdtag: 'devel-amd64', outname: 'ml-verse'}
2528
steps:
2629
- uses: actions/checkout@v4
27-
30+
2831
- name: Free root space
2932
uses: almahmoud/free-root-space@main
3033
with:
@@ -96,6 +99,7 @@ jobs:
9699
base:
97100
- {image: 'rocker/r-ver', armtag: '4.5.2', outname: 'r-ver'}
98101
- {image: 'rocker/rstudio', armtag: '4.5.2', outname: 'bioconductor_docker'}
102+
- {image: 'ghcr.io/bioconductor/rocker-cuda', armtag: '4.5.2-arm64', outname: 'jupyterlab-ml'}
99103
steps:
100104
- uses: actions/checkout@v3
101105

@@ -170,13 +174,11 @@ jobs:
170174
fail-fast: false
171175
matrix:
172176
base:
173-
- {image: 'rocker/r-ver', amdtag: '4.5.2', outname: 'r-ver', platforms: 'amd64,arm64'}
174-
- {image: 'rocker/rstudio', amdtag: '4.5.2', outname: 'bioconductor_docker', platforms: 'amd64,arm64'}
175-
- {image: 'rocker/tidyverse', amdtag: '4.5.2', outname: 'tidyverse', platforms: 'amd64'}
176-
#- {image: 'ghcr.io/bioconductor/rocker-cuda', amdtag: 'devel-amd64', outname: 'cuda', platforms: 'amd64'}
177-
#- {image: 'ghcr.io/bioconductor/rocker-ml', amdtag: 'devel-amd64', outname: 'ml', platforms: 'amd64'}
178-
#- {image: 'ghcr.io/bioconductor/rocker-ml-verse', amdtag: 'devel-amd64', outname: 'ml-verse', platforms: 'amd64'}
179-
- {image: 'rocker/shiny', amdtag: '4.5.2', outname: 'shiny', platforms: 'amd64'}
177+
- {outname: 'r-ver', platforms: 'amd64,arm64'}
178+
- {outname: 'bioconductor_docker', platforms: 'amd64,arm64'}
179+
- {outname: 'tidyverse', platforms: 'amd64'}
180+
- {outname: 'shiny', platforms: 'amd64'}
181+
- {outname: 'jupyterlab-ml', platforms: 'amd64,arm64'}
180182
steps:
181183
- name: Set up Docker Buildx
182184
uses: docker/setup-buildx-action@v3
@@ -248,7 +250,7 @@ jobs:
248250
cat /tmp/tags | xargs -i bash -c 'printf "%s" "-t {} " >> /tmp/tagargs'
249251
TAG_ARGS="$(cat /tmp/tagargs)"
250252
TAGS="$(cat /tmp/tags)"
251-
253+
252254
# Add version tags for RELEASE branches (e.g., RELEASE_3_21 -> 3.21)
253255
for tag in $TAGS; do
254256
if [[ "$tag" == *"RELEASE_"* ]]; then
@@ -261,14 +263,45 @@ jobs:
261263
fi
262264
fi
263265
done
264-
265-
R_VER=$(docker pull ${{ matrix.base.image }}:${{ matrix.base.amdtag }} 2>&1 > /dev/null && \
266-
docker inspect ${{ matrix.base.image }}:${{ matrix.base.amdtag }} | \
267-
jq -r '.[].Config.Env[]|select(match("^R_VERSION"))|.[index("=")+1:]')
266+
267+
# Extract R version by running Rscript in containers from all architectures
268+
BASE_REGISTRY=$(echo '${{ steps.meta1.outputs.tags }}' | awk -F':' '{print $1}')
269+
BRANCH=$(echo '${{ steps.meta1.outputs.tags }}' | awk -F':' '{print $2}')
270+
271+
# Extract R version from each architecture
272+
R_VER=""
273+
for archdir in $(cd /tmp/digests && find . -type d -mindepth 1 -maxdepth 1 | sort); do
274+
ARCH_NAME=$(basename "$archdir")
275+
DIGEST_FILE=$(cd /tmp/digests/$archdir && ls | head -1)
276+
277+
if [ ! -z "$DIGEST_FILE" ]; then
278+
echo "Extracting R version from $ARCH_NAME architecture..."
279+
CONTAINER_ID=$(docker run -d "${BASE_REGISTRY}@sha256:${DIGEST_FILE}" sleep infinity 2>/dev/null || echo "")
280+
281+
if [ ! -z "$CONTAINER_ID" ]; then
282+
ARCH_R_VER=$(docker exec "$CONTAINER_ID" Rscript -e 'cat(as.character(getRversion()))' 2>/dev/null || echo "")
283+
docker stop "$CONTAINER_ID" >/dev/null 2>&1
284+
docker rm "$CONTAINER_ID" >/dev/null 2>&1
285+
286+
echo "R version for $ARCH_NAME: $ARCH_R_VER"
287+
288+
# Set R_VER from first successful extraction
289+
if [ -z "$R_VER" ]; then
290+
R_VER="$ARCH_R_VER"
291+
elif [ "$R_VER" != "$ARCH_R_VER" ]; then
292+
echo "ERROR: R version mismatch! $ARCH_NAME has $ARCH_R_VER but expected $R_VER"
293+
exit 1
294+
fi
295+
fi
296+
fi
297+
done
298+
299+
echo "Verified R version across all architectures: $R_VER"
300+
268301
if [ ! -z "$R_VER" ]; then
269302
for tag in $TAGS; do
270303
TAG_ARGS="$TAG_ARGS -t ${tag}-R-${R_VER} -t ${tag}-r-${R_VER}"
271-
304+
272305
# For RELEASE branches, also add version-R tags
273306
if [[ "$tag" == *"RELEASE_"* ]]; then
274307
VERSION=$(echo "$tag" | sed -E 's/.*RELEASE_([0-9]+)_([0-9]+).*/\1.\2/')
@@ -279,32 +312,32 @@ jobs:
279312
fi
280313
done
281314
fi
282-
315+
283316
# Add alternative tags without _docker in name
284317
if [[ "${{ matrix.base.outname }}" == *"_docker"* ]]; then
285318
for tag in $TAGS; do
286319
# Extract registry and branch/version from tag
287320
REGISTRY=$(echo "$tag" | cut -d':' -f1)
288321
VERSION=$(echo "$tag" | cut -d':' -f2)
289-
322+
290323
# Create new registry without _docker suffix
291324
NEW_REGISTRY=$(echo "$REGISTRY" | sed 's/_docker//g')
292-
325+
293326
# Add tag without _docker in name
294327
TAG_ARGS="$TAG_ARGS -t ${NEW_REGISTRY}:${VERSION}"
295-
328+
296329
# If it's a release branch, also add the numeric version tag
297330
if [[ "$VERSION" == RELEASE_* ]]; then
298331
NUM_VERSION=$(echo "$VERSION" | sed -E 's/RELEASE_([0-9]+)_([0-9]+).*/\1.\2/')
299332
if [ ! -z "$NUM_VERSION" ]; then
300333
TAG_ARGS="$TAG_ARGS -t ${NEW_REGISTRY}:${NUM_VERSION}"
301334
fi
302335
fi
303-
336+
304337
# If R_VER exists, add R version tags for the non-_docker version
305338
if [ ! -z "$R_VER" ]; then
306339
TAG_ARGS="$TAG_ARGS -t ${NEW_REGISTRY}:${VERSION}-R-${R_VER} -t ${NEW_REGISTRY}:${VERSION}-r-${R_VER}"
307-
340+
308341
# If it's a release branch, also add R version tags for numeric version
309342
if [[ "$VERSION" == RELEASE_* ]]; then
310343
NUM_VERSION=$(echo "$VERSION" | sed -E 's/RELEASE_([0-9]+)_([0-9]+).*/\1.\2/')
@@ -315,7 +348,7 @@ jobs:
315348
fi
316349
done
317350
fi
318-
351+
319352
# Create manifest list
320353
DIGESTS=""
321354
BASE_REGISTRY=$(echo '${{ steps.meta1.outputs.tags }}' | awk -F':' '{print $1}')
@@ -332,27 +365,27 @@ jobs:
332365
# Get registry prefixes
333366
REGISTRY_PREFIXES=$(cat /tmp/tags | awk -F':' '{print $1}' | sort -u)
334367
BRANCH=$(cat /tmp/tags | head -1 | awk -F':' '{print $2}')
335-
368+
336369
# Inspect all created tags
337370
for prefix in $REGISTRY_PREFIXES; do
338371
# Base tag
339372
echo "Inspecting: $prefix:$BRANCH"
340373
docker buildx imagetools inspect "$prefix:$BRANCH"
341-
374+
342375
# Without _docker suffix if applicable
343376
if [[ "${{ matrix.base.outname }}" == *"_docker"* ]]; then
344377
NO_DOCKER_PREFIX=$(echo "$prefix" | sed 's/_docker//g')
345378
echo "Inspecting: $NO_DOCKER_PREFIX:$BRANCH"
346379
docker buildx imagetools inspect "$NO_DOCKER_PREFIX:$BRANCH"
347380
fi
348-
381+
349382
# Version tag for release branches
350383
if [[ "$BRANCH" == RELEASE_* ]]; then
351384
VERSION=$(echo "$BRANCH" | sed -E 's/RELEASE_([0-9]+)_([0-9]+).*/\1.\2/')
352385
if [ ! -z "$VERSION" ]; then
353386
echo "Inspecting: $prefix:$VERSION"
354387
docker buildx imagetools inspect "$prefix:$VERSION"
355-
388+
356389
# Without _docker suffix if applicable
357390
if [[ "${{ matrix.base.outname }}" == *"_docker"* ]]; then
358391
echo "Inspecting: $NO_DOCKER_PREFIX:$VERSION"
@@ -361,3 +394,22 @@ jobs:
361394
fi
362395
fi
363396
done
397+
398+
trigger-extensions:
399+
needs: [merge]
400+
runs-on: ubuntu-latest
401+
if: success()
402+
steps:
403+
- name: Trigger extensions workflow
404+
uses: actions/github-script@v7
405+
with:
406+
github-token: ${{ secrets.GITHUB_TOKEN }}
407+
script: |
408+
const branch = context.ref.replace('refs/heads/', '');
409+
await github.rest.actions.createWorkflowDispatch({
410+
owner: context.repo.owner,
411+
repo: context.repo.repo,
412+
workflow_id: 'build_extensions.yaml',
413+
ref: branch
414+
});
415+
console.log(`Triggered build_extensions.yaml workflow on branch ${branch}`)

0 commit comments

Comments
 (0)