-
Notifications
You must be signed in to change notification settings - Fork 2
178 lines (153 loc) · 5.87 KB
/
spack_cpu_build.yaml
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
# https://spack.readthedocs.io/en/latest/binary_caches.html#spack-build-cache-for-github-actions
name: Spack Ubunutu x86_64 Buildcache
env:
SPACK_COLOR: always
REGISTRY: ghcr.io/ornl
# Our repo name contains upper case characters, so we can't use ${{ github.repository }}
IMAGE_NAME: resolve
USERNAME: resolve-bot
BASE_VERSION: ubuntu-22.04-fortran
# Until we remove the need to clone submodules to build, this should on be in PRs
on: [pull_request]
jobs:
checkout_code:
name: Checkout code
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Once we move submodule deps into spack, we can do some more builds
# Also need to change build script to use spack from base image
submodules: true
check_for_image:
name: Check for image
runs-on: docker.io/kfox1111/misc:skopeo
permissions:
packages: read
steps:
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images
# This isn't necessary for skopeo, but spack will need this to push later...
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
# Use skopeo to check for image for convenience
- name: Check for existing base images
run: |
set -e
CONTAINER_TAG=${{ env.BASE_VERSION }}
OCI_URL="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BASE_VERSION }}"
echo Checking for CONTAINER_TAG $CONTAINER_TAG
mkdir -p /etc/gitlab-runner/certs
skopeo inspect \
docker://$OCI_URL \
--raw \
--creds "${{ env.USERNAME }}:${{ secrets.GITHUB_TOKEN }}" \
> /dev/null && echo "Image already exists. Please bump version." && exit 0
echo "IMAGE_EXISTS=false" >> $GITHUB_ENV
base_image_build:
if: ${{ env.IMAGE_EXISTS == false }}
runs-on: ubuntu-22.04
permissions:
packages: write
contents: read
name: Build Custom Base Image
steps:
# Need to build custom base image with gfortran
- name: Create Dockerfile heredoc
run: |
cat << EOF > Dockerfile
FROM ubuntu:22.04
RUN apt-get update && \
apt-get install -y --no-install-recommends \
software-properties-common \
gpg-agent \
openssh-client \
openssh-server \
&& rm -rf /var/lib/apt/lists/*
RUN add-apt-repository ppa:ubuntu-toolchain-r/test && \
apt-get install -y --no-install-recommends \
gcc \
libstdc++6 \
&& rm -rf /var/lib/apt/lists/*
EOF
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
labels: org.opencontainers.image.version=${{ env.BASE_VERSION }}
- name: Build and push Docker base image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BASE_VERSION }}
labels: ${{ steps.meta.outputs.labels }}
resolve_spack_builds:
needs: base_image_build
runs-on: ubuntu-22.04
permissions:
packages: write
contents: read
strategy:
matrix:
# Minimal Build(s) - GHCR mirror speeds these up a lot!
spack_spec:
- resolve@develop~klu~lusol
- resolve@develop+klu~lusol
- resolve@develop+klu+lusol
name: Build ReSolve with Spack
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Once we move submodule deps into spack, we can do some more builds
# Also need to change build script to use spack from base image
submodules: true
- name: Setup Spack
run: echo "$PWD/buildsystem/spack/spack/bin" >> "$GITHUB_PATH"
- name: Create heredoc spack.yaml
run: |
cat << EOF > spack.yaml
spack:
specs:
- ${{ matrix.spack_spec }} target=x86_64_v2
concretizer:
reuse: dependencies
config:
install_tree:
root: /opt/spack
padded_length: 128
mirrors:
local-buildcache: oci://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
spack: https://binaries.spack.io/develop
EOF
- name: Configure GHCR mirror
run: spack -e . mirror set --oci-username ${{ env.USERNAME }} --oci-password "${{ secrets.GITHUB_TOKEN }}" local-buildcache
- name: Trust keys
run: spack -e . buildcache keys --install --trust
- name: Find external packages
run: spack -e . external find --all
- name: Spack develop ReSolve
run: spack -e . develop --path=$(pwd) resolve@develop
- name: Concretize
run: spack -e . concretize
- name: Install dependencies
run: spack -e . install --no-check-signature --only dependencies
- name: Install package
run: spack -e . install --keep-stage --no-check-signature --no-cache --fresh
- name: Test Build
run: cd $(spack -e . location --build-dir resolve@develop) && ctest -VV
- name: Test Installation
run: cd $(spack -e . location --build-dir resolve@develop) && make test_install
# Push with force to override existing binaries...
- name: Push to binaries to buildcache
run: |
spack -e . buildcache push --force --base-image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BASE_VERSION }} --unsigned --update-index local-buildcache
if: ${{ !cancelled() }}