Skip to content

Commit

Permalink
Merge pull request #3 from esmf-org/feature/v1.2
Browse files Browse the repository at this point in the history
bring new features
  • Loading branch information
uturuncoglu authored Jul 28, 2023
2 parents 89147e9 + 9e1200b commit adae2c2
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 24 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ The action mainly includes following features:

## What's New

### v1.1
### v1.2

* Artifacts name can be given as an argument. This is expecially useful for settin up GitHub Action matrix.
* Minor fix is applied to `get_input.py` script to find `botocore.exceptions`.
* The run step is modified to output ESMF PET logs in case of error in the component testing.
* Default `architecture` is changed from `x86_64_v4` to `x86_64` to make it more generic.
* The extra `mpirun` arguments now need to be passed with `mpirun_arg` input argument.
* A new `debug` argument is added to the action that allow to create ssh connection to the runner for debugging (uses mxschmitt/action-tmate@v3).
* Now uses authoritative [Spack repository](https://github.com/spack/spack.git).
* Spack now uses `curl` to download packages and timeout limit is increased to 60 s to prevent fetching issues
* Spack now could use system installed packages (`spack external find`).
* Fixed following issue/s: https://github.com/esmf-org/nuopc-comp-testing/issues/2

## Usage

Expand All @@ -52,8 +54,10 @@ Create components `.yml` file in your repositories under `.github/workflows/test
* `component_build` - The list of shell commands to build the component. This is required since the GitHub Action do not know anything about the component build system and requirements.
* `component_module_name` - The Fortran module name of the component that will be tested. This argument is currently required but it would be a part of the user provided YAML files.
* `data_component_name` - The optional name of data component that will be used to force the component. The valid values are `datm` (default), `dice`, `dlnd`, `docn`, `drof` and `dwav`. It would be a part of the user provided YAML files in the future.
* `debug` - The optional argument for debugging purpose. It triggers extra output and also create ssh connection to the runner for debugging (uses [mxschmitt/action-tmate@v3](https://github.com/mxschmitt/action-tmate)).
* `dependencies` - The list of dependencies that are used to build the application. Since Spack is used to install dependencies, the given packages need to be part of the Spack distribution. The list of packages can be seen in [here](https://packages.spack.io). The ESMF package (`[email protected]+parallelio`) needs to be added to the list.
* `dependencies_install_dir` - An optional path of installation directory for dependencies. The default value is set to `~/.spack-ci`.
* `mpirun_arg` - The required argument to be passed to `mpirun` command. For example `--oversubscribe -np 6 --mca btl_tcp_if_include eth0` can be passed to run test case on 6 processor (`--oversubscribe` is required for the jobs that needs to be run more then 2 processor and `--mca btl_tcp_if_include eth0` is required to overcome hanging issue of collective communication under GitHub runners).
* `test_definition` - The top level YAML file that describes the test. This is required.

#### Environment Variables
Expand Down Expand Up @@ -110,7 +114,7 @@ jobs:
steps:
# test component
- name: Test Component
uses: esmf-org/nuopc-comp-testing@v1.1.0
uses: esmf-org/nuopc-comp-testing@v1.2.0
with:
app_install_dir: ${{ env.APP_INSTALL_DIR }}
artifacts_name: artifacts for ${{ matrix.test }} ${{ matrix.os }} esmf@${{ matrix.esmf }}
Expand Down Expand Up @@ -138,10 +142,9 @@ jobs:
component_module_name: lnd_comp_nuopc
data_component_name: datm
dependencies: |
[email protected]
esmf@${{ matrix.esmf }}+parallelio~xerces~pnetcdf
[email protected]+pnetcdf
esmf@${{ matrix.esmf }}+external-parallelio
dependencies_install_dir: ${{ env.DEP_INSTALL_DIR }}
mpirun_args: --oversubscribe -np 6 --mca btl_tcp_if_include eth0
test_definition: ${{ env.APP_INSTALL_DIR }}/noahmp/.github/workflows/tests/${{ matrix.test }}.yaml
```
Expand Down
31 changes: 27 additions & 4 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ inputs:
cache_input_file_list:
description: list of input files that needs to be cached
required: false
compiler:
description: compiler that will be used
required: false
default: [email protected]
component_name:
description: component name
required: false
Expand All @@ -43,13 +47,20 @@ inputs:
description: data component name
required: false
default: datm
debug:
description: enable debug capability
required: false
default: OFF
dependencies:
description: list of packages to install
required: true
dependencies_install_dir:
description: spack dependency installation directory
required: false
default: ~/.spack-ci
mpirun_args:
description: atguments that will be used in mpirun command
required: true
test_definition:
description: YAML file that describes the test
required: true
Expand Down Expand Up @@ -77,9 +88,11 @@ runs:
# concretize dependencies
- name: Concretize Spack Environment Using YAML Specification
run: |
echo "${{ inputs.dependencies }}"
$GITHUB_ACTION_PATH/scripts/concretize_deps.sh \
-a ${{ inputs.architecture }} \
-d $(echo "${{ inputs.dependencies }}" | awk '$1=$1' RS= OFS=,) \
-c ${{ inputs.compiler }} \
-d "$(echo "${{ inputs.dependencies }}" | sed -z 's/\n/:/g' | sed 's/:$//')" \
-i ${{ inputs.dependencies_install_dir }} \
-r $GITHUB_WORKSPACE
shell: bash
Expand All @@ -97,7 +110,8 @@ runs:
- name: Install Dependencies with Spack
run: |
$GITHUB_ACTION_PATH/scripts/install_deps.sh \
-r $GITHUB_WORKSPACE
-i "${{ inputs.dependencies_install_dir }}" \
-r "$GITHUB_WORKSPACE"
shell: bash

# checkout data models
Expand Down Expand Up @@ -179,21 +193,30 @@ runs:
python3 $GITHUB_ACTION_PATH/scripts/gen_config.py --ifile ${{ inputs.test_definition }}
shell: bash

# used to debug run and allow ssh just before running the model
- name: Setup tmate session to allow ssh connection
if: ${{ inputs.debug == 'ON' }}
uses: mxschmitt/action-tmate@v3

# run application
- name: Run Application
run: |
export PATH=${{ inputs.dependencies_install_dir }}/view/bin:$PATH
cd ${{ inputs.app_install_dir }}/run
mpirun --oversubscribe -np 6 --allow-run-as-root ${{ inputs.app_install_dir }}/build/esmx 2>&1 | tee out_err.txt
if [ $? -ne 0 ]; then
mpirun ${{ inputs.mpirun_args }} ${{ inputs.app_install_dir }}/build/esmx >& out_err.txt
cat out_err.txt
exc=$?
if [ $exc -ne 0 ]; then
echo "Component did not run successfully! Partial output from PET log files: "
tail -n 50 PET*
exit $exc
fi
shell: bash {0}

# upload model artifacts to check it later
- name: Upload Artifacts
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: ${{ inputs.artifacts_name }}
path: ${{ inputs.artifacts_files }}
Expand Down
49 changes: 39 additions & 10 deletions scripts/concretize_deps.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/bash

# get arguments
while getopts a:d:i:r: flag
while getopts a:c:d:i:r: flag
do
case "${flag}" in
a) arch=${OPTARG};;
d) deps=${OPTARG};;
c) comp=${OPTARG};;
d) deps="${OPTARG}";;
i) install_dir=${OPTARG};;
r) run_dir=${OPTARG};;
esac
Expand All @@ -30,21 +31,32 @@ if [[ -z "$run_dir" || ! -z `echo $run_dir | grep '^-'` ]]; then
fi

if [[ -z "$arch" || ! -z `echo $arch | grep '^-'` ]]; then
arch="x86_64_v4"
arch="x86_64"
fi

if [[ -z "$comp" || ! -z `echo $comp | grep '^-'` ]]; then
comp="[email protected]"
fi

# print out arguments
echo "Target Architecture: $arch"
echo "Compiler: $comp"
echo "Dependencies: $deps";
echo "Install Directory: $install_dir";
echo "Run Directory: $run_dir";

# go to directory
cd $run_dir

# checkout spack
# checkout spack and setup to use it
echo "::group::Checkout Spack"
git clone -b jcsda_emc_spack_stack https://github.com/NOAA-EMC/spack.git
git clone https://github.com/spack/spack.git
. spack/share/spack/setup-env.sh
echo "::endgroup::"

# find compilers
spack compiler find
cat ~/.spack/linux/compilers.yaml
echo "::endgroup::"

# create spack.yaml
Expand All @@ -56,30 +68,47 @@ echo " granularity: generic" >> spack.yaml
echo " host_compatible: false" >> spack.yaml
echo " unify: when_possible" >> spack.yaml
echo " specs:" >> spack.yaml
IFS=', ' read -r -a array <<< "$deps"
IFS=':' read -r -a array <<< "$deps"
for d in "${array[@]}"
do
echo " - $d target=$arch" >> spack.yaml
echo " - $d %$comp target=$arch" >> spack.yaml
done
echo " packages:" >> spack.yaml
echo " all:" >> spack.yaml
# following is required to build same optimized spack for different github action runners
# spack arch --known-targets command can be used to list known targets
echo " target: ['$arch']" >> spack.yaml
# following fixes compiler version
echo " compiler: [[email protected]]" >> spack.yaml
echo " compiler: [$comp]" >> spack.yaml
echo " view: $install_dir/view" >> spack.yaml
echo " config:" >> spack.yaml
echo " source_cache: $install_dir/source_cache" >> spack.yaml
echo " misc_cache: $install_dir/misc_cache" >> spack.yaml
echo " test_cache: $install_dir/test_cache" >> spack.yaml
echo " install_tree:" >> spack.yaml
echo " root: $install_dir/opt" >> spack.yaml
echo " install_missing_compilers: true" >> spack.yaml
cat spack.yaml
echo "::endgroup::"

# find external tools
echo "::group::Find Externals"
spack external find
echo "::endgroup::"

# create config file (to fix FetchError issue)
echo "::group::Create config.yaml"
echo "config:" > ~/.spack/config.yaml
echo " url_fetch_method: curl" >> ~/.spack/config.yaml
echo " connect_timeout: 60" >> ~/.spack/config.yaml
cat ~/.spack/config.yaml
echo "::endgroup::"

# concretize spack environment
echo "::group::Concretize Spack Environment Using YAML Specification"
. spack/share/spack/setup-env.sh
spack --color always -e $run_dir/. concretize -f
exc=$?
if [ $exc -ne 0 ]; then
echo "Error in concretizing dependencies! exit code is $exc ..."
exit $exc
fi
echo "::endgroup::"
5 changes: 5 additions & 0 deletions scripts/create_exe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ cat esmxBuild.yaml

# create build directory
cmake -H$ESMF_ESMXDIR -Bbuild
exc=$?
if [ $exc -ne 0 ]; then
echo "Error when creating executable! exit code is $exc ..."
exit $exc
fi

# compile and create executable
cd $app_install_dir/build
Expand Down
10 changes: 10 additions & 0 deletions scripts/get_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ def recv_files(_dict, fhash, force_download):
else:
sys.exit('Files are not listed for component {} and section {}!'.format(k1, k2))

if 'force' in v2:
force = v2['force']
else:
force = False

# overwrite force download using YAML
if force:
force_download = True
print('Force download of {}!'.format(files))

# save current directory
current_dir = os.getcwd()

Expand Down
17 changes: 16 additions & 1 deletion scripts/install_deps.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#!/bin/bash

# get arguments
while getopts r: flag
while getopts i:r: flag
do
case "${flag}" in
i) install_dir=${OPTARG};;
r) run_dir=${OPTARG};;
esac
done

# check for default values
if [[ -z "$install_dir" || ! -z `echo $install_dir | grep '^-'` ]]; then
install_dir="$HOME/.spack-ci"
fi

if [[ -z "$run_dir" || ! -z `echo $run_dir | grep '^-'` ]]; then
run_dir=`pwd`
fi
Expand All @@ -23,4 +28,14 @@ cd $run_dir
echo "::group::Install Spack Packages"
. spack/share/spack/setup-env.sh
spack --color always -e $run_dir/. install -j3 --deprecated --no-checksum
exc=$?
if [ $exc -ne 0 ]; then
echo "Error in installing dependencies! exit code is $exc ..."
exit $exc
fi
echo "::endgroup::"

# output esmf.mk file for debugging
echo "::group::Content of esmf.mk"
cat $install_dir/view/lib/esmf.mk
echo "::endgroup::"

0 comments on commit adae2c2

Please sign in to comment.