Skip to content

Commit

Permalink
ci(release): make compiler toolchain/version configurable (#1325)
Browse files Browse the repository at this point in the history
* add compiler toolchain/version inputs to release workflows
* switch modflowpy/install-intelfortran-action to fortran-lang/setup-fortran
  • Loading branch information
wpbonelli authored Oct 20, 2023
1 parent 5a98a51 commit 625741a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 7 deletions.
31 changes: 25 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ on:
description: 'Branch to release from.'
required: true
type: string
compiler_toolchain:
description: 'Compiler toolchain to use. For supported options see https://github.com/MODFLOW-USGS/modflow6/blob/develop/DEVELOPER.md#compiler-compatibility.'
required: false
type: string
default: 'intel-classic'
compiler_version:
description: 'Compiler version to use. For supported options see https://github.com/MODFLOW-USGS/modflow6/blob/develop/DEVELOPER.md#compiler-compatibility.'
required: false
type: string
default: '2021.7'
developmode:
description: 'Build binaries in develop mode. If false, IDEVELOPMODE is set to 0.'
required: false
Expand Down Expand Up @@ -84,8 +94,11 @@ jobs:
bash
powershell
- name: Setup Intel Fortran
uses: modflowpy/install-intelfortran-action@v1
- name: Setup ${{ inputs.compiler_toolchain }} ${{ inputs.compiler_version }}
uses: fortran-lang/setup-fortran@v1
with:
compiler: ${{ inputs.compiler_toolchain }}
version: ${{ inputs.compiler_version }}

- name: Set version number
id: set_version
Expand Down Expand Up @@ -278,8 +291,11 @@ jobs:
cache-downloads: true
cache-environment: true

- name: Setup Intel Fortran
uses: modflowpy/install-intelfortran-action@v1
- name: Setup ${{ inputs.compiler_toolchain }} ${{ inputs.compiler_version }}
uses: fortran-lang/setup-fortran@v1
with:
compiler: ${{ inputs.compiler_toolchain }}
version: ${{ inputs.compiler_version }}

- name: Update version
id: update_version
Expand Down Expand Up @@ -429,8 +445,11 @@ jobs:
bash
powershell
- name: Setup Intel Fortran
uses: modflowpy/install-intelfortran-action@v1
- name: Setup ${{ inputs.compiler_toolchain }} ${{ inputs.compiler_version }}
uses: fortran-lang/setup-fortran@v1
with:
compiler: ${{ inputs.compiler_toolchain }}
version: ${{ inputs.compiler_version }}

- name: Update version
id: update_version
Expand Down
36 changes: 35 additions & 1 deletion .github/workflows/release_dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ on:
description: 'Branch to release from.'
required: true
type: string
compiler_toolchain:
description: 'Compiler toolchain to use. For supported options see https://github.com/MODFLOW-USGS/modflow6/blob/develop/DEVELOPER.md#compiler-compatibility.'
required: false
type: string
default: 'intel-classic'
compiler_version:
description: 'Compiler version to use. For supported options see https://github.com/MODFLOW-USGS/modflow6/blob/develop/DEVELOPER.md#compiler-compatibility.'
required: false
type: string
default: '2021.7'
commit_version:
description: 'Commit version numbers back to the develop branch. Not considered if reset is false.'
required: false
Expand All @@ -36,7 +46,7 @@ on:
default: false
run_tests:
description: 'Run tests after building binaries.'
required: true
required: false
type: boolean
default: true
version:
Expand All @@ -53,6 +63,8 @@ jobs:
shell: bash -l {0}
outputs:
branch: ${{ steps.set_branch.outputs.branch }}
compiler_toolchain: ${{ steps.set_compiler.outputs.compiler_toolchain }}
compiler_version: ${{ steps.set_compiler.outputs.compiler_version }}
version: ${{ steps.set_version.outputs.version }}
steps:
- name: Set branch
Expand All @@ -77,6 +89,26 @@ jobs:
exit 1
fi
echo "branch=$branch" >> $GITHUB_OUTPUT
- name: Set compiler
id: set_compiler
run: |
# if compiler toolchain was provided explicitly via workflow_dispatch, use it
if [[ ("${{ github.event_name }}" == "workflow_dispatch") && (-n "${{ inputs.compiler_toolchain }}") ]]; then
compiler_toolchain="${{ inputs.compiler_toolchain }}"
compiler_version="${{ inputs.compiler_version }}"
echo "using compiler toolchain $compiler_toolchain version $compiler_version from workflow_dispatch"
elif [[ ("${{ github.event_name }}" == "push") && ("${{ github.ref_name }}" != "master") ]]; then
# if release was triggered by pushing a release branch, use the default toolchain and version
compiler_toolchain="intel-classic"
compiler_version="2021.7"
echo "using default compiler toolchain $compiler_toolchain version $compiler_version"
else
# otherwise exit with an error
echo "error: this workflow should not have triggered for event ${{ github.event_name }} on branch ${{ github.ref_name }}"
exit 1
fi
echo "compiler_toolchain=$compiler_toolchain" >> $GITHUB_OUTPUT
echo "compiler_version=$compiler_version" >> $GITHUB_OUTPUT
- name: Set version
id: set_version
run: |
Expand All @@ -103,6 +135,8 @@ jobs:
# If the workflow is manually triggered, the maintainer must manually set approve=true to approve a release.
# If triggered by pushing a release branch, the release is approved if the branch name doesn't contain "rc".
approve: ${{ (github.event_name == 'workflow_dispatch' && inputs.approve == 'true') || (github.event_name != 'workflow_dispatch' && !contains(github.ref_name, 'rc')) }}
compiler_toolchain: ${{ needs.set_options.outputs.compiler_toolchain }}
compiler_version: ${{ needs.set_options.outputs.compiler_version }}
branch: ${{ needs.set_options.outputs.branch }}
developmode: false
full: true
Expand Down

0 comments on commit 625741a

Please sign in to comment.