Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update CI image and add mkmf for fre make testing #245

Merged
merged 13 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/build_conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ jobs:
build:
runs-on: ubuntu-latest
container:
image: continuumio/miniconda3:latest
image: ghcr.io/noaa-gfdl/fre-cli:miniconda24.7.1_gcc14.2.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarifying question for myself, is this a version/image we'll have to update every once in a while?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think anything will break anytime soon if we used this image for a while, but it'd be good to get a new image with newer software every year or so, that's what I've typically done with other CI images. Anytime you rebuild the image it'll pull in the latest versions, so you wouldn't have to make any changes to the dockerfile.

Copy link
Member

@ilaflott ilaflott Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity and my own notekeeping, where can one find the dockerfile for the uploaded container image in question?

edit: this isn't a condition for approval/merge/etc, i just like knowing stufff cause its fun

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

steps:
- name: Checkout Files
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Add mkmf to PATH
run: |
echo $PWD/mkmf/bin >> $GITHUB_PATH
- name: Run Conda to Build
run: |
conda config --append channels conda-forge
Expand Down
49 changes: 18 additions & 31 deletions .github/workflows/create_test_conda_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,24 @@ on: [push]
jobs:
build-linux:
runs-on: ubuntu-latest
container:
image: ghcr.io/noaa-gfdl/fre-cli:miniconda24.7.1_gcc14.2.0
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '>=3.9'
- name: Add conda to system path
run: |
# $CONDA is an env var pointing to root of miniconda dir
echo $CONDA/bin >> $GITHUB_PATH

- name: Create fre-cli environment
run: |
# create environment containing all dependencies
# the env cannot be explicitly activated in github CI/CD
conda env create -f environment.yml --name fre-cli

# add conda env's executables to github's PATH equiv.
# sets CONDA to wherever it may be on the image
source /root/.bashrc

# add conda env's executables and mkmf to github's PATH equiv.
echo $CONDA/envs/fre-cli/bin >> $GITHUB_PATH
echo $PWD/mkmf/bin >> $GITHUB_PATH

# use *conda environment's pip* to install fre-cli
# called w/ full path to conda's python for explicitness
Expand All @@ -34,38 +31,28 @@ jobs:

- name: Run pytest in fre-cli environment
run: |
# try to make sure the right things are in GITHUB_PATH
echo $CONDA/envs/fre-cli/bin >> $GITHUB_PATH

# are we talking to the right python?
which python
python --version
$CONDA/envs/fre-cli/bin/python --version

# add spack installed binaries to front of path so that
# conda's netcdf/hdf5 installs don't break compilation tests
export path_save=$PATH
export PATH="/opt/views/view/bin:$PATH"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tom just walked me through views the other day, cool to see!


# run pytest
pytest --junit-xml=pytest_results.xml --config-file=fre/pytest.ini --cov-config=fre/coveragerc --cov-report=xml --cov=fre fre/

# install genbadge to generate coverage badge based on xml

# restore original path and install genbadge to generate coverage badge based on xml
export PATH="$path_save"
pip install genbadge
genbadge coverage -v -i coverage.xml -o docs/cov_badge.svg
genbadge tests -v -i pytest_results.xml -o docs/pytest_badge.svg

- name: Run pylint in fre-cli environment
run: |
# try to make sure the right things are in GITHUB_PATH
echo $CONDA/envs/fre-cli/bin >> $GITHUB_PATH

# are we talking to the right python?
which python
python --version
$CONDA/envs/fre-cli/bin/python --version
ilaflott marked this conversation as resolved.
Show resolved Hide resolved

# run pylint, ignored modules avoid warnings arising from code internal to those modules
# run pylint, ignored modules avoid warnings arising from code internal to those modules
pylint --max-args 6 -ry --ignored-modules netCDF4,cmor fre/ || echo "pylint returned non-zero exit code. preventing workflow from dying with this echo."

- name: Install Sphinx and Build Documentation
run: |
pip install sphinx renku-sphinx-theme sphinx-rtd-theme
pip install sphinx renku-sphinx-theme sphinx-rtd-theme
pip install --upgrade sphinx-rtd-theme
sphinx-apidoc --output-dir docs fre/ --separate
sphinx-build docs build
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/publish_conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ jobs:
publish:
runs-on: ubuntu-latest
container:
image: continuumio/miniconda3:latest
image: ghcr.io/noaa-gfdl/fre-cli:miniconda24.7.1_gcc14.2.0
steps:
- name: Checkout Files
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Add mkmf to PATH
ilaflott marked this conversation as resolved.
Show resolved Hide resolved
run: |
echo $PWD/mkmf/bin >> $GITHUB_PATH
- name: Run Conda to Build and Publish
run: |
conda config --append channels conda-forge
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "mkmf"]
path = mkmf
url = https://github.com/NOAA-GFDL/mkmf
[submodule "fre/gfdl_msd_schemas"]
path = fre/gfdl_msd_schemas
url = https://github.com/NOAA-GFDL/gfdl_msd_schemas
21 changes: 21 additions & 0 deletions fre/make/tests/compilation/test_fre_make_run_fremake.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
''' test "fre make run-fremake" calls '''

import os
from fre.make import runFremake
from pathlib import Path

# command options
YAMLFILE = "fre/make/tests/null_example/null_model.yaml"
PLATFORM = [ "ci.gnu" ]
CONTAINER_PLATFORM = ["hpcme.2023"]
TARGET = ["debug"]
EXPERIMENT = "null_model_full"

# get HOME dir to check output
HOME_DIR = os.environ["HOME"]

def test_fre_make_run_fremake_null_model_serial_compile():
''' run fre make with run-fremake subcommand and build the null model experiment with gnu'''
runFremake.fremake_run(YAMLFILE, PLATFORM, TARGET, False, 1, False, False)
assert Path(f"{HOME_DIR}/fremake_canopy/test/{EXPERIMENT}/{PLATFORM[0]}-{TARGET[0]}/exec/{EXPERIMENT}.x").exists()

6 changes: 6 additions & 0 deletions fre/make/tests/null_example/platforms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ platforms:
container: True
containerBuild: "podman"
containerRun: "apptainer"
- name: ci.gnu
compiler: gnu
fc: mpifort
cc: mpicc
mkTemplate: /__w/fre-cli/fre-cli/mkmf/templates/linux-ubuntu-xenial-gnu.mk
modelRoot: ${HOME}/fremake_canopy/test
2 changes: 1 addition & 1 deletion meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test:
- fre.catalog
commands:
- pylint --max-args 6 -ry --ignored-modules netCDF4,cmor fre/ || echo "pylint returned non-zero exit code and will kill the workflow. guarding against this now."
- pip install GitPython && pytest --config-file=fre/pytest.ini --cov-config=fre/coveragerc --cov=fre fre/
- pip install GitPython && pytest --config-file=fre/pytest.ini --cov-config=fre/coveragerc --cov=fre --ignore=fre/make/tests/compilation fre/ # run pytest but ignore any tests that require compilation
ilaflott marked this conversation as resolved.
Show resolved Hide resolved
- fre --help
- fre pp --help
- fre pp install --help
Expand Down
1 change: 1 addition & 0 deletions mkmf
Submodule mkmf added at 9830f1