Skip to content

Fix various problems for building and running tests in GitHub CI #27

Fix various problems for building and running tests in GitHub CI

Fix various problems for building and running tests in GitHub CI #27

# Workflow to run CAM-ML test suite
name: TestSuiteUbuntu
# Controls when the workflow will run
on:
# Triggers the workflow on pushes to the "main" branch, i.e., PR merges
push:
branches: [ "main" ]
# Triggers the workflow on pushes to open pull requests with code changes
pull_request:
paths:
- '.github/workflows/test_suite_ubuntu.yml'
- '**.f90'
- '**.F90'
- '**CMakeLists.txt'
- '**requirements.txt'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Cancel jobs running if new commits are pushed
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# Workflow run - one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "test-suite-ubuntu"
test-suite-ubuntu:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
fail-fast: false
# These steps represent sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout code
with:
persist-credentials: false
uses: actions/checkout@v4
# Install Python 3
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
# Install dependencies
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libhdf5-dev libnetcdf-dev libnetcdff-dev
# Build the code with cmake
- name: Build test suite
run: |
export TEST_DIR=$(pwd)/tests
cd ${TEST_DIR}
mkdir build
cd build
cmake ..
cmake --build .
./test_CAM_interface
# Run the test suites
- name: Test suite
run: |
cd tests//build
./test_CAM_interface