-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (133 loc) · 5.9 KB
/
ci.yml
File metadata and controls
146 lines (133 loc) · 5.9 KB
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
name: CI
on:
pull_request:
paths:
# We only want to run CI on spack versions that don't utilise symlinks (AKA pre-v1.1),
# in order to keep the CI simple. This means that the below pattern is essentially
# everthing in the v* directories, excluding the symlinked v0.* spack versions.
- 'v**'
- '!v0.**'
workflow_dispatch:
inputs:
spack-config-directories-to-test:
description: 'Space-separated list of version-based spack-config directories to test against'
required: true
type: string
default: v1.1
spack-config-ref:
description: 'spack-config ref to use'
required: true
type: string
spack-ref:
description: 'spack ref to use'
required: true
type: string
run-self-hosted:
description: 'Use self-hosted runners for the test'
required: true
default: true
type: boolean
jobs:
setup-ci:
name: Setup CI
runs-on: ubuntu-latest
env:
# Note, this needs to be updated in line with refs in the CI job below
BUILD_CI_WORKFLOW_VERSION: v3
# Which repository we get the manifest-to-test from
SPACK_MANIFEST_REPOSITORY: ACCESS-NRI/access-spack-packages
outputs:
spack-manifest-repository: ${{ env.SPACK_MANIFEST_REPOSITORY }}
# Matrices used in CI job
manifest-matrix: ${{ steps.setup-manifests.outputs.matrix }}
config-matrix: ${{ steps.setup-config.outputs.matrix }}
# Global defaults for CI job
spack-config-ref: ${{ inputs.spack-config-ref || github.event.pull_request.head.sha }}
spack-ref: ${{ inputs.spack-ref || steps.defaults.outputs.spack-ref }}
steps:
- name: Checkout spack-config
uses: actions/checkout@v6
- name: PR - Get dirs changed
id: set-matrix-pr
if: github.event_name == 'pull_request'
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
dir_names: true # we want a list of spack configuration directories (eg. v1.1, v1.2)
dir_names_max_depth: 1 # and don't care about subdirectories
dir_names_exclude_current_dir: true # or files changed in the root directory
# Below is an equivalent condition to on.pull_request.paths
files: |
v*/**
!v0.*/**
- name: Dispatch - Get config directory to test
id: set-matrix-dispatch
if: github.event_name == 'workflow_dispatch'
run: |
echo "dirs=${{ inputs.spack-config-directories-to-test }}" >> $GITHUB_OUTPUT
- name: Get Manifests from ${{ env.SPACK_MANIFEST_REPOSITORY }}
uses: actions/checkout@v6
with:
repository: ${{ env.SPACK_MANIFEST_REPOSITORY }}
- name: Setup Manifest Matrix
id: setup-manifests
# To simplify the matrix creation logic later on, we are splitting the matrices into a manifest file name one,
# and a configuration one - they will be applied in combination in the CI job.
run: |
manifests=$(find .github/build-ci/manifests -type f -printf '"%p",')
echo "$manifests"
echo "matrix=[${manifests%,}]" >> $GITHUB_OUTPUT
- name: Setup Spack Version Branch Matrix
id: setup-config
# Create a matrix of configuration directories (eg. v1.1)
run: |
json_entries=""
for config_dir in ${{ steps.set-matrix-pr.outputs.all_changed_files || steps.set-matrix-dispatch.outputs.dirs }}; do
# For directories of the form 'v1.1/blah', this will give `v1.1`
spack_branch_version=$(cut -d'/' -f1 <<< "$config_dir")
json_entry=$(printf '{"spack-version-branch": "%s"}' "$spack_branch_version")
json_entries+="${json_entry},"
done
echo "$json_entries"
echo "matrix=[${json_entries%,}]" >> $GITHUB_OUTPUT
- name: Checkout build-ci
uses: actions/checkout@v6
with:
repository: access-nri/build-ci
ref: ${{ env.BUILD_CI_WORKFLOW_VERSION }}
- name: Get default refs from build-ci workflow
id: defaults
# GitHub does not treat empty-string inputs as eligible for substitution with a default
# Since we are supporting both workflow_dispatch and pull_request triggers, the entrypoint inputs need to be filled in
# So we are getting the default values from the workflow file itself, and passing them back into the workflow
run: |
default_spack_ref=$(yq '.on.workflow_call.inputs."spack-ref".default' .github/workflows/ci.yml)
echo "Default refs from ${{ env.BUILD_CI_WORKFLOW_VERSION }}: spack-ref=$default_spack_ref"
echo "spack-ref=$default_spack_ref" >> $GITHUB_OUTPUT
ci:
name: CI
needs:
- setup-ci
strategy:
fail-fast: false
max-parallel: 5
matrix:
manifest: ${{ fromJson(needs.setup-ci.outputs.manifest-matrix) }}
config: ${{ fromJson(needs.setup-ci.outputs.config-matrix) }}
# Respectively of the form:
# [ .github/build-ci/manifests/some.spack.yaml, ...]
# And:
# [{
# spack-version-branch: v1.1
# }, ...]
uses: access-nri/build-ci/.github/workflows/ci.yml@v3
with:
spack-manifest-repository: ${{ needs.setup-ci.outputs.spack-manifest-repository }}
spack-manifest-path: ${{ matrix.manifest }}
spack-manifest-data-path: .github/build-ci/data/standard_definitions.json
spack-config-ref: ${{ needs.setup-ci.outputs.spack-config-ref }}
spack-ref: ${{ needs.setup-ci.outputs.spack-ref }}
container-image-version: :rocky-${{ matrix.config.spack-version-branch }}
# Workflow dispatch can switch depending on cluster/GitHub resourcing, otherwise run self-hosted
run-self-hosted: ${{ inputs.run-self-hosted || true }}
secrets:
spack-install-command-pat: ${{ secrets.SPACK_INSTALL_COMMAND_PAT }}