-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #433 from achauphan/actions-on-pull-request
implemented Github Actions workflow to auto build & run lorenz_96 with mpi & lorenz_63 models upon new pull requests
- Loading branch information
Showing
4 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: 'Build and run model' | ||
description: 'Build and run given model' | ||
|
||
# All possible input parameters that can be specified when using this composite action | ||
inputs: | ||
models-directory: | ||
description: 'path to top-level directory containing the model to build and run' | ||
type: string | ||
required: false | ||
default: 'models/' | ||
model: | ||
description: 'name of existing DART model' | ||
type: string | ||
required: true | ||
default: 'lorenz_96' | ||
run-program: | ||
description: 'name of program to run in model /work directory after compile' | ||
required: true | ||
default: './filter' | ||
run-program-args: | ||
type: string | ||
description: 'arguments to use when running specified program' | ||
required: false | ||
default: '' | ||
use-mpi: | ||
description: 'specify whether to run program with MPI or not' | ||
type: boolean | ||
required: true | ||
default: true | ||
mpi-n-tasks: | ||
description: 'specify number of mpi tasks to run with program if mpi is used' | ||
type: number | ||
required: false | ||
default: 2 | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
# Steps to create Makefile template | ||
- name: Creating Makefile template :) | ||
run: | | ||
cd build_templates | ||
cp mkmf.template.gfortran mkmf.template | ||
echo 'FFLAGS = -g -Wuninitialized -Wunused -ffree-line-length-none -fbounds-check -fbacktrace -ffpe-trap=invalid,zero,overflow $(INCS)' >> mkmf.template | ||
shell: bash | ||
# Steps to compile and build model | ||
- name: Building ${{ inputs.model }} model | ||
run: | | ||
cd ${{ inputs.models-directory }}/${{ inputs.model }}/work | ||
./quickbuild.sh | ||
shell: bash | ||
# Steps to run the specified run-program with mpi options | ||
- name: Running ${{ inputs.model }} ${{ inputs.run-program }} program (use-mpi=true) | ||
if: ${{ inputs.use-mpi }} | ||
run: | | ||
cd ${{ inputs.models-directory }}/${{ inputs.model }}/work/ | ||
mpirun -n ${{ inputs.mpi-n-tasks }} --allow-run-as-root ./${{ inputs.run-program }} ${{ inputs.run-program-args }} | ||
shell: bash | ||
- name: Running ${{ inputs.model }} ${{ inputs.run-program }} program (use-mpi=false) | ||
if: ${{ !inputs.use-mpi }} | ||
run: | | ||
cd ${{ inputs.models-directory }}/${{ inputs.model }}/work/ | ||
./${{ inputs.run-program }} ${{ inputs.run-program-args }} | ||
shell: bash |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Action on Pull Request | ||
run-name: ${{ github.actor }} triggered workflow by a pull request update | ||
|
||
on: | ||
pull_request: | ||
types: [ opened, reopened, synchronize, ready_for_review ] | ||
|
||
jobs: | ||
# Job 1 | ||
build-run-lorenz_96: | ||
# Runner instance OS | ||
runs-on: ubuntu-latest | ||
# Deploy container on top of runner instance | ||
container: | ||
image: hkershaw/dart-dep:1.0 | ||
options: "--cap-add=SYS_PTRACE" | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
- name: Set checked out repo as a safe git directory | ||
run: git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }} | ||
- name: Build and run lorenz_96 | ||
uses: ./.github/actions/build_run_model | ||
with: | ||
model: lorenz_96 | ||
run-program: ./filter | ||
use-mpi: true | ||
mpi-n-tasks: 2 | ||
|
||
# Job 2 | ||
build-run-lorenz_63: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: hkershaw/dart-dep:1.0 | ||
options: '--cap-add=SYS_PTRACE' | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
- name: Set checked out repo as a safe git directory | ||
run: git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }} | ||
- name: Build and run lorenz_63 with no mpi | ||
uses: ./.github/actions/build_run_model | ||
with: | ||
model: lorenz_63 | ||
run-program: ./filter | ||
use-mpi: false |
This file contains 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
This file contains 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