TEST: Testing out spack-config build-ci #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| outputs: | |
| # 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@v4 | |
| - name: PR - Get files changed | |
| id: files-changed | |
| if: github.event_name == 'pull_request' | |
| uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5 | |
| with: | |
| files_yaml: | | |
| v** | |
| !v0.** | |
| - name: PR - Get unique directories changed | |
| id: set-matrix-pr | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| echo "dirs=$(echo '${{ steps.files-changed.outputs.changed_files }}' | xargs -n1 dirname | sort -u)" >> $GITHUB_OUTPUT | |
| - 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: 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.symlinked-config-dirs || 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@v4 | |
| 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-path: ${{ matrix.manifest }} | |
| spack-manifest-data-path: .github/build-ci/data/standard.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 }} |