Skip to content

Commit 7dcf192

Browse files
organize applications into matrix config
1 parent 98bfc0b commit 7dcf192

File tree

1 file changed

+102
-125
lines changed

1 file changed

+102
-125
lines changed

.github/workflows/build_all_application_deps.yaml

Lines changed: 102 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,16 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15+
application: [ufs-weather-model, gsi, nceplibs-develop, nceplibs-numbered]
1516
config:
16-
- {
17-
compiler: "gcc",
18-
compiler-version: "13",
19-
os: "ubuntu-24.04",
20-
mpi: "mpich",
21-
mpi-version: ":",
22-
applications: ["ufs-weather-model", "gsi", "nceplibs-develop", "nceplibs-numbered"],
23-
}
24-
- {
25-
compiler: "classic",
26-
compiler-version: "2023.2.1",
27-
os: "ubuntu-24.04",
28-
mpi: "intel-oneapi-mpi",
29-
mpi-version: "2021.14",
30-
applications: ["nceplibs-develop", "nceplibs-numbered"],
31-
}
32-
- {
33-
compiler: "oneapi",
34-
compiler-version: "2025.3",
35-
os: "ubuntu-24.04",
36-
mpi: "intel-oneapi-mpi",
37-
mpi-version: "2021.14",
38-
applications: ["ufs-weather-model", "nceplibs-develop", "nceplibs-numbered"],
39-
}
17+
- {compiler: gcc, compiler-version: "13", os: ubuntu-24.04, mpi: mpich, mpi-version: ":"}
18+
- {compiler: classic, compiler-version: "2023.2.1", os: ubuntu-24.04, mpi: intel-oneapi-mpi, mpi-version: "2021.14"}
19+
- {compiler: oneapi, compiler-version: "2025.3", os: ubuntu-24.04, mpi: intel-oneapi-mpi, mpi-version: "2021.14"}
20+
exclude:
21+
- application: gsi
22+
config: {compiler: classic}
23+
- application: gsi
24+
config: {compiler: oneapi}
4025
runs-on: ${{ matrix.config.os }}
4126
permissions:
4227
packages: write
@@ -75,8 +60,9 @@ jobs:
7560
7661
# Wrap spack command to echo before executing
7762
spack() {
78-
echo "Running: spack $@"
63+
echo "::group:: spack $@"
7964
_spack_shell_wrapper "$@";
65+
echo "::endgroup::"
8066
return $?
8167
}
8268
@@ -90,104 +76,95 @@ jobs:
9076
spack mirror add emc-common-build-cache oci://ghcr.io/$OCI_USERNAME/ci-common-build-cache
9177
spack mirror set --push --oci-username-variable OCI_USERNAME --oci-password-variable OCI_TOKEN emc-common-build-cache
9278
93-
# Loop through each application
94-
for app in ${{ join(matrix.config.applications, ' ') }}; do
95-
echo "::group:: Building application dependencies: ${app}"
96-
echo "Processing application: ${app}"
97-
98-
# Create and activate environment from manifest
99-
spack env create ${app}-env applications/${app}.yaml
100-
spack env activate ${app}-env
101-
spack config add 'config:install_tree:padded_length:200'
102-
spack repo add ${GITHUB_WORKSPACE}/custom_repo
103-
104-
# Set up compilers & MPI for this application
105-
COMPILER=${{ matrix.config.compiler }}@${{ matrix.config.compiler-version }}
106-
if [ ${{ matrix.config.compiler }} == 'gcc' ]; then
107-
sudo apt install gcc-${{ matrix.config.compiler-version }} g++-${{ matrix.config.compiler-version }} gfortran-${{ matrix.config.compiler-version }}
108-
spack config add "packages:gcc-runtime:require:'%gcc@${{ matrix.config.compiler-version }}'"
109-
else # set GCC backend for Intel to be the Ubuntu default version of GCC
110-
if [ ${{ matrix.config.os }} == ubuntu-22.04 ]; then gccver=11; fi
111-
if [ ${{ matrix.config.os }} == ubuntu-24.04 ]; then gccver=13; fi
112-
spack config add "packages:gcc-runtime:require:'%gcc@${gccver}'"
113-
fi
114-
if [ ${{ matrix.config.compiler }} == 'oneapi' ]; then
115-
spack compiler find /opt/intel/oneapi/compiler/${{ matrix.config.compiler-version }}
116-
spack compiler find /opt/intel/oneapi/compiler/${{ matrix.config.compiler-version }}/linux
117-
COMPILER=intel-oneapi-compilers
118-
elif [ ${{ matrix.config.compiler }} == 'classic' ]; then
119-
which icc
120-
spack external find intel-oneapi-compilers-classic
121-
COMPILER=intel-oneapi-compilers-classic
122-
CLASSIC_LD_PATH='/opt/intel/oneapi/compiler/${{ matrix.config.compiler-version }}/linux/compiler/lib/intel64_lin'
123-
fi
124-
compilerstoallow="'%${COMPILER}'"
125-
if [[ " oneapi classic " =~ " ${{ matrix.config.compiler }} " ]]; then
126-
compilerstoallow="${compilerstoallow},'%gcc@${gccver}'"
127-
# Fix libimf.so not found issue AND 2025.3.x mismatch issue
128-
spack fix-intel-config --consolidate
129-
fi
130-
allowedcompilerspecs=$(echo $compilerstoallow | sed "s:%::g;s:,: :;s:'::g")
131-
132-
spack config add "concretizer:reuse:include:[${compilerstoallow}]"
133-
spack config add "packages:all:prefer:['%$COMPILER']"
134-
spack config add "packages:all:require:'target=x86_64'"
135-
# The following is a problem for CRTM:
136-
spack config add "packages:fortran:require:['$COMPILER']"
137-
138-
spack config add "packages:mpi:require:'${{ matrix.config.mpi }}@${{ matrix.config.mpi-version }}'"
139-
if [ "${{ matrix.config.mpi }}" == intel-oneapi-mpi ]; then
140-
sed -i "s|^ packages:| packages:\n intel-oneapi-mpi:\n buildable: false\n externals:\n - spec: intel-oneapi-mpi@${{ matrix.config.mpi-version }}\n prefix: /opt/intel/oneapi|" $SPACK_ENV/spack.yaml
141-
spack config add "packages:mpi:buildable:false"
142-
fi
143-
144-
spack external find gcc git git-lfs
145-
# Avoid various C++-related Intel compiler bugs by building some packages with GCC:
146-
for pkg in diffutils sed grep libidn2 tar berkeley-db gettext findutils cmake libiconv; do
147-
spack config add "packages:${pkg}:require:'%gcc'"
148-
done
149-
spack filter-compilers $allowedcompilerspecs --keep-only
150-
cat $SPACK_ENV/spack.yaml
151-
152-
# Concretize environment
153-
spack concretize --fresh |& tee log.concretize.${app}
154-
155-
# Validate
156-
spack validate compilers $allowedcompilerspecs
157-
if [[ " oneapi classic " =~ " ${{ matrix.config.compiler }} " ]]; then
158-
spack validate allow-pkgs-for-compiler gcc cmake diffutils
159-
fi
160-
161-
# If running from the cron trigger, rebuild from scratch
162-
if [ ! -z '${{ github.event.schedule }}' ]; then NOCACHE="--no-cache"; fi
163-
spack config add 'config:build_stage:~/spack'
164-
165-
# Don't immediately exit job on failed 'spack install' so we can still cache whatever was built:
166-
set +e
167-
spack install --no-check-signature --show-log-on-error --fail-fast $NOCACHE
168-
app_rc=$?
169-
set -e
170-
171-
# Push to buildcache under GitHub Packages (OCI repo)
172-
spack buildcache push --update-index --unsigned --with-build-dependencies emc-common-build-cache
173-
174-
# Generate container image for this application
175-
label=${{ matrix.config.os }}-${{ matrix.config.compiler }}-${{ matrix.config.compiler-version }}-${{ matrix.config.mpi }}-${{ matrix.config.mpi-version }}
176-
label=${label//:/x}
177-
spack mirror add \
178-
--oci-username-variable OCI_USERNAME \
179-
--oci-password-variable OCI_TOKEN \
180-
${app}-env oci://ghcr.io/${OCI_USERNAME,,}/ci-common-build-cache/${app}-${label}
181-
image=$(echo ${{ matrix.config.os }} | sed 's|-|:|')
182-
echo "Creating consolidated container image ${image}"
183-
spack buildcache push --only dependencies --with-build-dependencies --update-index --unsigned \
184-
--base-image ${image} --tag latest ${app}-env |& perl -pe 's/.+(Fetching|Using cached)/::debug::\1/'
185-
186-
if [ $app_rc -ne 0 ]; then echo "install-time error!"; exit 1; fi
187-
188-
# Deactivate environment and clean up for next iteration
189-
spack env deactivate
190-
spack env rm -y ${app}-env
191-
192-
echo "::endgroup::"
79+
app=${{ matrix.application }}
80+
echo "Processing application: ${app}"
81+
82+
# Create and activate environment from manifest
83+
spack env create ${app}-env applications/${app}.yaml
84+
spack env activate ${app}-env
85+
spack config add 'config:install_tree:padded_length:200'
86+
spack repo add ${GITHUB_WORKSPACE}/custom_repo
87+
88+
# Set up compilers & MPI for this application
89+
COMPILER=${{ matrix.config.compiler }}@${{ matrix.config.compiler-version }}
90+
if [ ${{ matrix.config.compiler }} == 'gcc' ]; then
91+
sudo apt install gcc-${{ matrix.config.compiler-version }} g++-${{ matrix.config.compiler-version }} gfortran-${{ matrix.config.compiler-version }}
92+
spack config add "packages:gcc-runtime:require:'%gcc@${{ matrix.config.compiler-version }}'"
93+
else # set GCC backend for Intel to be the Ubuntu default version of GCC
94+
if [ ${{ matrix.config.os }} == ubuntu-22.04 ]; then gccver=11; fi
95+
if [ ${{ matrix.config.os }} == ubuntu-24.04 ]; then gccver=13; fi
96+
spack config add "packages:gcc-runtime:require:'%gcc@${gccver}'"
97+
fi
98+
if [ ${{ matrix.config.compiler }} == 'oneapi' ]; then
99+
spack compiler find /opt/intel/oneapi/compiler/${{ matrix.config.compiler-version }}
100+
spack compiler find /opt/intel/oneapi/compiler/${{ matrix.config.compiler-version }}/linux
101+
COMPILER=intel-oneapi-compilers
102+
elif [ ${{ matrix.config.compiler }} == 'classic' ]; then
103+
which icc
104+
spack external find intel-oneapi-compilers-classic
105+
COMPILER=intel-oneapi-compilers-classic
106+
CLASSIC_LD_PATH='/opt/intel/oneapi/compiler/${{ matrix.config.compiler-version }}/linux/compiler/lib/intel64_lin'
107+
fi
108+
compilerstoallow="'%${COMPILER}'"
109+
if [[ " oneapi classic " =~ " ${{ matrix.config.compiler }} " ]]; then
110+
compilerstoallow="${compilerstoallow},'%gcc@${gccver}'"
111+
# Fix libimf.so not found issue AND 2025.3.x mismatch issue
112+
spack fix-intel-config --consolidate
113+
fi
114+
allowedcompilerspecs=$(echo $compilerstoallow | sed "s:%::g;s:,: :;s:'::g")
115+
116+
spack config add "concretizer:reuse:include:[${compilerstoallow}]"
117+
spack config add "packages:all:prefer:['%$COMPILER']"
118+
spack config add "packages:all:require:'target=x86_64'"
119+
# The following is a problem for CRTM:
120+
spack config add "packages:fortran:require:['$COMPILER']"
121+
122+
spack config add "packages:mpi:require:'${{ matrix.config.mpi }}@${{ matrix.config.mpi-version }}'"
123+
if [ "${{ matrix.config.mpi }}" == intel-oneapi-mpi ]; then
124+
sed -i "s|^ packages:| packages:\n intel-oneapi-mpi:\n buildable: false\n externals:\n - spec: intel-oneapi-mpi@${{ matrix.config.mpi-version }}\n prefix: /opt/intel/oneapi|" $SPACK_ENV/spack.yaml
125+
spack config add "packages:mpi:buildable:false"
126+
fi
127+
128+
spack external find gcc git git-lfs
129+
# Avoid various C++-related Intel compiler bugs by building some packages with GCC:
130+
for pkg in diffutils sed grep libidn2 tar berkeley-db gettext findutils cmake libiconv; do
131+
spack config add "packages:${pkg}:require:'%gcc'"
193132
done
133+
spack filter-compilers $allowedcompilerspecs --keep-only
134+
cat $SPACK_ENV/spack.yaml
135+
136+
# Concretize environment
137+
spack concretize --fresh |& tee log.concretize.${app}
138+
139+
# Validate
140+
spack validate compilers $allowedcompilerspecs
141+
if [[ " oneapi classic " =~ " ${{ matrix.config.compiler }} " ]]; then
142+
spack validate allow-pkgs-for-compiler gcc cmake diffutils
143+
fi
144+
145+
# If running from the cron trigger, rebuild from scratch
146+
if [ ! -z '${{ github.event.schedule }}' ]; then NOCACHE="--no-cache"; fi
147+
spack config add 'config:build_stage:~/spack'
148+
149+
# Don't immediately exit job on failed 'spack install' so we can still cache whatever was built:
150+
set +e
151+
spack install --no-check-signature --show-log-on-error --fail-fast $NOCACHE
152+
app_rc=$?
153+
set -e
154+
155+
# Push individual packages to GitHub Packages build cache (OCI repo)
156+
spack buildcache push --update-index --unsigned --with-build-dependencies emc-common-build-cache |& perl -pe 's/.+(Fetching|Using cached)/::debug::\1/'
157+
158+
# Generate container image for this application
159+
label=${{ matrix.config.os }}-${{ matrix.config.compiler }}-${{ matrix.config.compiler-version }}-${{ matrix.config.mpi }}-${{ matrix.config.mpi-version }}
160+
label=${label//:/x}
161+
spack mirror add \
162+
--oci-username-variable OCI_USERNAME \
163+
--oci-password-variable OCI_TOKEN \
164+
${app}-env oci://ghcr.io/${OCI_USERNAME,,}/ci-common-build-cache/${app}-${label}
165+
image=$(echo ${{ matrix.config.os }} | sed 's|-|:|')
166+
echo "Creating consolidated container image for ${app}"
167+
spack buildcache push --only dependencies --with-build-dependencies --update-index --unsigned \
168+
--base-image ${image} --tag latest ${app}-env |& perl -pe 's/.+(Fetching|Using cached)/::debug::\1/'
169+
170+
if [ $app_rc -ne 0 ]; then echo "install-time error!"; exit 1; fi

0 commit comments

Comments
 (0)