Skip to content

Commit b1401ec

Browse files
author
Cameron Rutherford
authored
Add check for existing base image to speedup pipelines. (#156)
* Add check for existing base image to speedup pipelines. * Add spack test to pipeline. * Update spack to attempt to bugfix issues. * Disable spack build cache to attempt to work around issue. * Add building with cache. * Fix missing EOF for heredoc. * Remove appendix concretizer config.
1 parent 7767511 commit b1401ec

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

.github/workflows/spack_cpu_build.yaml

+30-4
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,29 @@ jobs:
3232
# Also need to change build script to use spack from base image
3333
submodules: true
3434

35+
# No GHCR base image with skopeo, so this will do...
36+
- name: "Set up skopeo"
37+
uses: warjiang/[email protected]
38+
with:
39+
version: latest
40+
41+
# Use skopeo to check for image for convenience
42+
- name: Check for existing base images
43+
run: |
44+
set -e
45+
CONTAINER_TAG=${{ env.BASE_VERSION }}
46+
OCI_URL="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BASE_VERSION }}"
47+
echo Checking for CONTAINER_TAG $CONTAINER_TAG
48+
skopeo inspect \
49+
docker://$OCI_URL \
50+
--raw \
51+
--creds "${{ env.USERNAME }}:${{ secrets.GITHUB_TOKEN }}" \
52+
> /dev/null && echo "Image already exists. Please bump version." && exit 0
53+
echo "IMAGE_EXISTS=false" >> $GITHUB_ENV
54+
3555
# Need to build custom base image with gfortran
3656
- name: Create Dockerfile heredoc
57+
if: ${{ env.IMAGE_EXISTS == 'false' }}
3758
run: |
3859
cat << EOF > Dockerfile
3960
FROM ubuntu:24.04
@@ -61,13 +82,15 @@ jobs:
6182
password: ${{ secrets.GITHUB_TOKEN }}
6283

6384
- name: Extract metadata (tags, labels) for Docker
85+
if: ${{ env.IMAGE_EXISTS == 'false' }}
6486
id: meta
6587
uses: docker/metadata-action@v5
6688
with:
6789
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
6890
labels: org.opencontainers.image.version=${{ env.BASE_VERSION }}
6991

7092
- name: Build and push Docker base image
93+
if: ${{ env.IMAGE_EXISTS == 'false' }}
7194
uses: docker/build-push-action@v5
7295
with:
7396
context: .
@@ -120,7 +143,6 @@ jobs:
120143
concretizer:
121144
reuse: dependencies
122145
config:
123-
concretizer: clingo
124146
source_cache: $SPACK_CACHE/source_cache
125147
misc_cache: $SPACK_CACHE/misc_cache
126148
build_stage: $SPACK_CACHE/build_stage
@@ -129,10 +151,11 @@ jobs:
129151
padded_length: False
130152
mirrors:
131153
local-buildcache: oci://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
132-
spack: https://binaries.spack.io/develop
154+
# spack: https://binaries.spack.io/develop
133155
packages:
134156
all:
135157
require: "%gcc"
158+
EOF
136159
137160
- name: Configure GHCR mirror
138161
run: spack -e . mirror set --oci-username ${{ env.USERNAME }} --oci-password "${{ secrets.GITHUB_TOKEN }}" local-buildcache
@@ -147,10 +170,13 @@ jobs:
147170
run: spack -e . develop --path=$(pwd) exago@develop
148171

149172
- name: Concretize
150-
run: spack -e . concretize
173+
run: spack -e . concretize --fresh
151174

152175
- name: Install
153-
run: spack -e . install --no-check-signature --fail-fast
176+
run: spack -e . install --no-check-signature --fail-fast --keep-stage
177+
178+
- name: Test Build
179+
run: cd $(spack -e . location --build-dir exago@develop) && ctest -VV
154180

155181
# Push with force to override existing binaries...
156182
- name: Push to binaries to buildcache

tpl/spack

Submodule spack updated 4695 files

0 commit comments

Comments
 (0)