Skip to content

Commit

Permalink
Merge pull request #433 from achauphan/actions-on-pull-request
Browse files Browse the repository at this point in the history
implemented Github Actions workflow to auto build & run lorenz_96 with mpi & lorenz_63 models upon new pull requests
  • Loading branch information
hkershaw-brown committed Dec 12, 2022
2 parents 3f3a4e0 + fd1d2bc commit 44ba83b
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 1 deletion.
64 changes: 64 additions & 0 deletions .github/actions/build_run_model/action.yml
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
46 changes: 46 additions & 0 deletions .github/workflows/action_on_pull_request.yml
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
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ individual files.

The changes are now listed with the most recent at the top.

**December 12 2022 :: Automated testing of pull requests**

- GitHub actions for pull requests which checkout, compile and run a
given model.
Current workflow: lorenz_96 (mpi) and lorenz_63 (no mpi)

*contributed by Anderson Chauphan*

**December 2 2022 :: Bug-fix cam-fv. Tag v10.5.6**

- Fix for assimilate.csh purge of restart files when the interval for restart
Expand Down
2 changes: 1 addition & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
author = 'Data Assimilation Research Section'

# The full version, including alpha/beta/rc tags
release = '10.5.6'
release = '10.6.0'
master_doc = 'README'

# -- General configuration ---------------------------------------------------
Expand Down

0 comments on commit 44ba83b

Please sign in to comment.