Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6fb7dfe
add initial version of unit-testing workflow
glemieux Jun 12, 2025
512f588
add working directory context and make sure that the spack environmen…
glemieux Jun 12, 2025
624c10b
tempory change to cime path to test rest of container workflow
glemieux Jun 16, 2025
c32019b
Attempt to get the CIMEROOT env variable (if set)
glemieux Jun 16, 2025
b70af9e
fix simple cime path option
glemieux Jun 16, 2025
7ff29b5
Reinstate initial check with updated logic
glemieux Jun 16, 2025
755d000
attempt simple install of matplotlib
glemieux Jun 16, 2025
12ddd2e
run pip from python
glemieux Jun 16, 2025
4e85f59
add python setup
glemieux Jun 16, 2025
dfb7585
cache pip
glemieux Jun 16, 2025
24cd9a3
Try activating the spack environment first
glemieux Jun 16, 2025
a15825d
try running pip through python
glemieux Jun 16, 2025
c0ba1d0
call python3 explicitly
glemieux Jun 16, 2025
7ebac5c
remove comment
glemieux Jun 16, 2025
1596342
simplify python call
glemieux Jun 16, 2025
51cf676
temporarily comment out unit test call
glemieux Jun 16, 2025
bf0d14d
debug python call
glemieux Jun 16, 2025
0cac52d
more debugging
glemieux Jun 16, 2025
7bdcb2e
more debugs
glemieux Jun 16, 2025
0316980
activate spack first
glemieux Jun 16, 2025
3eebf4b
check python version
glemieux Jun 16, 2025
e3e3603
echo python path
glemieux Jun 16, 2025
4a9d9f2
should have entrypoint now
glemieux Jun 16, 2025
7121bab
comment out to trigger workflow
glemieux Jun 16, 2025
95c6808
switch echo
glemieux Jun 16, 2025
07ffac2
add source of entrypoint
glemieux Jun 16, 2025
8c0ffee
change from bash to sh command for sourcing
glemieux Jun 16, 2025
0f68573
fix entrypoint call
glemieux Jun 16, 2025
767b744
don't bother with entrypoint and just us activate directly
glemieux Jun 16, 2025
43a4bd9
reinstate checkout to trigger tests
glemieux Jun 17, 2025
af21b68
combine activation and testing into one step
glemieux Jun 17, 2025
d3c23d1
add hostname option to docker image to allow CIME to reference the ne…
glemieux Jun 17, 2025
62bc7a7
minor change to trigger workflow
glemieux Jun 17, 2025
bb28ff7
add echos
glemieux Jun 17, 2025
60a96d7
add cime call to debug
glemieux Jun 17, 2025
7ecb3e0
trigger workflow
glemieux Jun 17, 2025
41e7fc3
update the HOME env variable for the container
glemieux Jun 17, 2025
fb6b34f
add more echos
glemieux Jun 17, 2025
3d1fb71
deal with $HOME runner issue 863
glemieux Jun 17, 2025
f0baa4a
put unit test run back in
glemieux Jun 17, 2025
bb9120a
slight update to github_env
glemieux Jun 17, 2025
1510e03
initial hack to avoid using CIME build utils
glemieux Jul 22, 2025
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
52 changes: 52 additions & 0 deletions .github/workflows/unit-test-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Run Unit Tests

on:
workflow_dispatch:
pull_request:
branches: [ main ]

jobs:
unit-tests:
runs-on: ubuntu-latest
container:
image: ghcr.io/glemieux/containers/unit-testing:latest
options: --hostname fatestestcontainer

steps:

- name: Preserve $HOME set in the container
run: echo HOME=/root/ >> "$GITHUB_ENV"

- name: Checkout repository
uses: actions/checkout@v4

- name: Activate Spack environment and run tests
run: |
. /opt/spack-environment/activate.sh
python -m pip install matplotlib
echo "HOSTNAME: $HOSTNAME"
echo "HOME: $HOME"
echo "CIMEROOT: $CIMEROOT"
echo "NETCDF_FORTRAN_PATH: $NETCDF_FORTRAN_PATH"
echo "NETCDF_C_PATH: $NETCDF_C_PATH"
cd testing/
python run_unit_tests.py --make-j 2 --test-list all

# cd /cime/CIME
# echo "get cime root"
# python -c 'from utils import get_cime_root; print(get_cime_root())'
# echo "get config path"
# python -c 'from utils import get_config_path; print(get_config_path())'
# echo "get schema path"
# python -c 'from utils import get_schema_path; print(get_schema_path())'


# cd testing/
# echo "path_to_cime:"
# python -c 'from path_utils import path_to_cime; print(path_to_cime())'
# python run_unit_tests.py --make-j 2 --test-list all

# - name: Run FATES unit tests
# working-directory: ./testing/
# run: |
# python run_unit_tests.py --make-j 2 --test-list all
66 changes: 39 additions & 27 deletions testing/build_fortran_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import os
import shutil
from socket import gethostname
from path_utils import add_cime_lib_to_path

add_cime_lib_to_path()
Expand Down Expand Up @@ -101,37 +102,48 @@ def get_extra_cmake_args(build_dir:str, mpilib:str) -> str:
Returns:
str: space-separated list of cmake arguments
"""
# get the machine objects file
machobj = Machines()

# get compiler
compiler = machobj.get_default_compiler()

# get operating system
os_ = machobj.get_value("OS")

# create the environment, and the Macros.cmake file
configure(
machobj,
build_dir,
["CMake"],
compiler,
mpilib,
True,
"nuopc",
os_,
unit_testing=True,
)
machspecific = EnvMachSpecific(build_dir, unit_testing=True)

# make a fake case
fake_case = FakeCase(compiler, mpilib, True, "nuopc", threading=False)
machspecific.load_env(fake_case)
# Check if the test is being run in a FATES testing container
if (gethostname() == "fatestestcontainer"):
machinename = "fatestestcontainer"
compiler = "gnu"
mplilib = "mpi-serial"
# build_dir
else:
# If not in a testing container, assume we are running on a machine
# that has a supported environment

# get the machine objects file
machobj = Machines()

# get compiler
compiler = machobj.get_default_compiler()

# get operating system
os_ = machobj.get_value("OS")

# create the environment, and the Macros.cmake file
configure(
machobj,
build_dir,
["CMake"],
compiler,
mpilib,
True,
"nuopc",
os_,
unit_testing=True,
)
machspecific = EnvMachSpecific(build_dir, unit_testing=True)

# make a fake case
fake_case = FakeCase(compiler, mpilib, True, "nuopc", threading=False)
machspecific.load_env(fake_case)
machinename = machobj.get_machine_name()

# create cmake argument list with information from the fake case and machine object
cmake_args_list = [
f"-DOS={os_}",
f"-DMACH={machobj.get_machine_name()}",
f"-DMACH={machinename}",
f"-DCOMPILER={compiler}",
f"-DDEBUG={stringify_bool(True)}",
f"-DMPILIB={mpilib}",
Expand Down
3 changes: 3 additions & 0 deletions testing/path_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def path_to_cime() -> str:
cime_path = os.path.join(path_to_fates_root(), "../../cime")
if os.path.isdir(cime_path):
return cime_path
elif os.path.isdir("/cime"):
return "/cime"

raise RuntimeError("Cannot find cime.")


Expand Down
Loading