Add default CICE5 builds when using CMake #289
Workflow file for this run
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: | |
| - spack_repo/access/nri/packages/** | |
| workflow_dispatch: | |
| inputs: | |
| packages-to-test: | |
| description: 'Packages to test (space-separated)' | |
| required: true | |
| type: string | |
| default: 'ALL' | |
| builtin-spack-packages-ref: | |
| description: 'spack/spack-packages ref to use' | |
| required: true | |
| type: string | |
| access-spack-packages-ref: | |
| description: 'access-nri/access-spack-packages ref to use' | |
| required: true | |
| type: string | |
| spack-config-ref: | |
| description: 'spack-config ref to use' | |
| required: true | |
| type: string | |
| spack-ref: | |
| description: 'spack ref to use' | |
| required: true | |
| type: string | |
| 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 | |
| PACKAGES_ROOT_DIR: spack_repo/access/nri/packages | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| builtin-spack-packages-ref: ${{ inputs.builtin-spack-packages-ref }} | |
| access-spack-packages-ref: ${{ inputs.access-spack-packages-ref || github.event.pull_request.head.sha }} | |
| spack-config-ref: ${{ inputs.spack-config-ref || steps.defaults.outputs.spack-config-ref }} | |
| spack-ref: ${{ inputs.spack-ref || steps.defaults.outputs.spack-ref }} | |
| steps: | |
| - name: Checkout spack-packages | |
| uses: actions/checkout@v4 | |
| - name: PR - Get packages | |
| id: set-matrix-pr | |
| if: github.event_name == 'pull_request' | |
| uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5 | |
| with: | |
| # We only care about the directory names under the env.PACKAGES_ROOT_DIR - since they are also the package names | |
| # and we want to find changes to the package.py files in those directories | |
| dir_names: true | |
| path: ./${{ env.PACKAGES_ROOT_DIR }} | |
| files: '*/package.py' | |
| - name: Dispatch - Get packages | |
| id: set-matrix-dispatch | |
| if: github.event_name == 'workflow_dispatch' | |
| # Either get all packages defined (all subfolders under packages/) or use the input | |
| run: | | |
| if [[ "${{ inputs.packages-to-test }}" == "ALL" ]]; then | |
| pkgs=$(find ${{ env.PACKAGES_ROOT_DIR }}/ -mindepth 1 -maxdepth 1 -type d -printf '%P ') | |
| else | |
| pkgs="${{ inputs.packages-to-test }}" | |
| fi | |
| # Validate that all packages exist | |
| error=false | |
| for pkg in $pkgs; do | |
| if [ ! -f "${{ env.PACKAGES_ROOT_DIR }}/$pkg/package.py" ]; then | |
| echo "::error::packages/$pkg/package.py does not exist. Check spelling or if the package is defined." | |
| error=true | |
| fi | |
| done | |
| if [ "$error" = true ]; then | |
| exit 1 | |
| fi | |
| echo "pkgs=$pkgs" >> $GITHUB_OUTPUT | |
| - name: Setup Matrix | |
| id: set-matrix | |
| # Get all packages that will be tested, then | |
| # Get file paths to manifests for each package, and a template, then finally | |
| # Convert into a JSON array for the matrix, one of the form: | |
| # [ | |
| # {"template_value": "mom5", "filepath": ".github/build-ci/manifests/mom5/intel.spack.yaml.j2"}, | |
| # {"template_value": "mom5", "filepath": ".github/build-ci/manifests/mom5/gcc.spack.yaml.j2"}, | |
| # {"template_value": "cice5", "filepath": ".github/build-ci/manifests/cice5/spack.yaml.j2"}, | |
| # ... | |
| # ] | |
| run: | | |
| pkgs="${{ steps.set-matrix-pr.outputs.all_changed_files || steps.set-matrix-dispatch.outputs.pkgs }}" | |
| for pkg in $pkgs; do | |
| # We want each manifest to have an associated injection of {{ package }} to $pkg | |
| # Replace underscores with hyphens for the template value, as spack converts directory underscores to package name hyphens | |
| template_value="${pkg//_/-}" | |
| if [ -d ".github/build-ci/manifests/$pkg" ]; then # Look for specific manifests for the package | |
| # We space-separate the paths as we later use them in a for loop | |
| manifest_paths=$(find .github/build-ci/manifests/$pkg -iname '*.j2' -type f -printf '%p ') | |
| fi | |
| if [[ -z "$manifest_paths" ]]; then # Use the default templates if no specific manifests exist for the package | |
| # Similarly, space-separate the paths for a later for loop. Default manifests are always directly under .github/build-ci/manifests | |
| manifest_paths=$(find .github/build-ci/manifests/ -maxdepth 1 -type f -iname '*.j2' -printf '%p ') | |
| fi | |
| for manifest_path in $manifest_paths; do | |
| json_entry=$(printf '{"template_value": "%s", "filepath": "%s"}' "$template_value" "$manifest_path") | |
| json_entries+="${json_entry}," | |
| done | |
| unset manifest_paths | |
| done | |
| echo "$json_entries" | |
| # Remove the trailing comma and wrap in square brackets | |
| 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 | |
| # builtin-spack-packages-ref does not need this as the input handles the empty string default. | |
| run: | | |
| default_spack_ref=$(yq '.on.workflow_call.inputs."spack-ref".default' .github/workflows/ci.yml) | |
| default_spack_config_ref=$(yq '.on.workflow_call.inputs."spack-config-ref".default' .github/workflows/ci.yml) | |
| echo "Default refs from ${{ env.BUILD_CI_WORKFLOW_VERSION }}: spack-ref=$default_spack_ref, spack-config=$default_spack_config_ref" | |
| echo "spack-ref=$default_spack_ref" >> $GITHUB_OUTPUT | |
| echo "spack-config-ref=$default_spack_config_ref" >> $GITHUB_OUTPUT | |
| ci: | |
| name: CI | |
| needs: | |
| - setup-ci | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 5 | |
| matrix: | |
| package: ${{ fromJson(needs.setup-ci.outputs.matrix) }} | |
| exclude: | |
| - package: {template_value: "access-om2"} | |
| - package: {template_value: "access-om2-bgc"} | |
| - package: {template_value: "access-om3"} | |
| - package: {template_value: "access-esm1p5"} | |
| - package: {template_value: "access-esm1p6"} | |
| - package: {template_value: "access-am3"} | |
| - package: {template_value: "access-ram3"} | |
| - package: {template_value: "access-issm"} | |
| - package: {template_value: "access-test"} | |
| - package: {template_value: "coastri-roms"} | |
| - package: {template_value: "gcom"} | |
| - package: {template_value: "gcom4"} | |
| - package: {template_value: "um"} | |
| uses: access-nri/build-ci/.github/workflows/ci.yml@v3 | |
| with: | |
| spack-manifest-path: ${{ matrix.package.filepath }} | |
| spack-manifest-data-path: .github/build-ci/data/standard_definitions.json | |
| spack-manifest-data-pairs: |- | |
| package ${{ matrix.package.template_value }} | |
| builtin-spack-packages-ref: ${{ needs.setup-ci.outputs.builtin-spack-packages-ref }} | |
| access-spack-packages-ref: ${{ needs.setup-ci.outputs.access-spack-packages-ref }} | |
| spack-config-ref: ${{ needs.setup-ci.outputs.spack-config-ref }} | |
| spack-ref: ${{ needs.setup-ci.outputs.spack-ref }} | |
| allow-ssh-into-spack-install: false | |
| # container-image-version: :rocky | |
| secrets: | |
| spack-install-command-pat: ${{ secrets.SPACK_INSTALL_COMMAND_PAT }} |