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

Add Windows CI test and setup regression tests against known output #27

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@ jobs:
gnu:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
gcc_version: [12, 13, 14]
build_type: [Debug, Release]
env:
FC: gfortran-${{ matrix.gcc_version }}

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: brew install netcdf netcdf-fortran
- name: Checkout code
uses: actions/checkout@v4

- name: Run Cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }}

- name: Build
run: cmake --build build --verbose

- name: Run tests
run: ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure . --verbose
working-directory: build
22 changes: 14 additions & 8 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
name: Ubuntu

on: [pull_request, workflow_dispatch]
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
gnu:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
gcc_version: [12, 13, 14]
build_type: [Debug, Release]
env:
FC: gfortran
FC: gfortran-${{ matrix.gcc_version }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libnetcdf-dev netcdf-bin libnetcdff-dev

- name: Run Cmake
run: cmake -S . -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }}

- name: Build
run: cmake --build build --verbose

- name: Run tests
run: ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure . --verbose
working-directory: build
47 changes: 47 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Windows

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
gnu:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
build_type: [Debug, Release]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
base-devel
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-cmake
msystem: MINGW64

- name: Add MSYS2 mingw64 to PATH
run: echo "C:/msys64/mingw64/bin" >> $GITHUB_PATH

- name: Configure with CMake
run: cmake -G "MinGW Makefiles" -B build -D CMAKE_BUILD_TYPE=${{ matrix.build_type }}

- name: Build the project
run: cmake --build build --verbose

- name: Run tests
run: ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure . --verbose
working-directory: build
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ This file documents all notable changes to the Cloud-J repository since the init

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [8.0.1] - TBD
### Added
- Github actions workflow to build on windows
- Tests which compare the output of Cloud-J to some saved reference output.

### Changed
- The try_compile.f90 file no longer tries to use netcdf

### Removed
- Removed all mentions of netcdf in the cmake files as netcdf was only needed to compile a test program
- Removed installation of netcdf in Ubuntu and macOS github actions as these are no longer needed.

## [8.0.0] - 2024-08-29
### Added
- Added M. Prather's new Cloud-J v8 feature of UV absorption by water (source of differences between v7.7 and v8)
Expand Down
67 changes: 29 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ message("Cloud-J ${PROJECT_VERSION}")
message("Current status: ${CLDJ_REPO_VERSION}")
message("=================================================================")

#-----------------------------------------------------------------------------
# options
#-----------------------------------------------------------------------------
option(CLOUDJ_ENABLE_TESTS "Build the tests" ON)

#-----------------------------------------------------------------------------
# Set policies
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -174,41 +179,12 @@ target_include_directories(CloudJBuildProperties
# Append Cloud-J's environment variables to CMAKE_PREFIX_PATH
#-----------------------------------------------------------------------------
list(APPEND CMAKE_PREFIX_PATH
# Possible NetCDF environment variables
$ENV{NetCDF_F_ROOT} $ENV{NetCDF_C_ROOT} $ENV{NetCDF_ROOT}
$ENV{NETCDF_F_ROOT} $ENV{NETCDF_C_ROOT} $ENV{NETCDF_ROOT}
$ENV{NetCDF_Fortran_ROOT}
$ENV{NETCDF_FORTRAN_ROOT}

# Possible Cloud-J environmnet variables (still needed? -ewl)
$ENV{GC_F_BIN} $ENV{GC_BIN}
$ENV{GC_F_INCLUDE} $ENV{GC_INCLUDE}
$ENV{GC_F_LIB} $ENV{GC_LIB}
)

#-----------------------------------------------------------------------------
# Link NetCDF-F to CloudJBuildProperties
#-----------------------------------------------------------------------------
find_package(NetCDF REQUIRED)
target_include_directories(CloudJBuildProperties
INTERFACE ${NETCDF_INCLUDE_DIRS}
)
target_link_libraries(CloudJBuildProperties
INTERFACE ${NETCDF_LIBRARIES}
)

#-----------------------------------------------------------------------------
# Use the NC_HAS_COMPRESSION def if nf_def_var_deflate is in netcdf.inc
#-----------------------------------------------------------------------------
if(EXISTS ${NETCDF_F77_INCLUDE_DIR}/netcdf.inc)
file(READ ${NETCDF_F77_INCLUDE_DIR}/netcdf.inc NCINC)
if("${NCINC}" MATCHES ".*nf_def_var_deflate.*")
target_compile_definitions(CloudJBuildProperties
INTERFACE "NC_HAS_COMPRESSION"
)
endif()
endif()

#-----------------------------------------------------------------------------
# Print a description of the source code repo's version
# (Needs more work to enable)
Expand Down Expand Up @@ -326,14 +302,14 @@ file(WRITE ${CMAKE_BINARY_DIR}/CloudJBuildProperties.txt
"CloudJBuildProperties::INTERFACE_INCLUDE_DIRECTORIES:${BT_INCLUDES}\n"
)

#-----------------------------------------------------------------------------
# Try to compile a simple program that uses NetCDF-Fortran and OpenMP
#-----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# Try to compile a simple program that uses OpenMP
# -----------------------------------------------------------------------------
if(NOT CLOUDJ_EXTERNAL_CONFIG AND NOT CLOUDJ_TRY_RUN_PASSED)

# Format definitions with -D prefix
set(TRY_RUN_LIBRARIES ${NETCDF_LIBRARIES})
set(TRY_RUN_INCLUDE_DIRS ${NETCDF_INCLUDE_DIRS})
set(TRY_RUN_LIBRARIES "")
set(TRY_RUN_INCLUDE_DIRS "")
set(TRY_RUN_COMPILER_FLAGS "")
set(TRY_RUN_DEFINITIONS "")

Expand Down Expand Up @@ -362,9 +338,8 @@ if(NOT CLOUDJ_EXTERNAL_CONFIG AND NOT CLOUDJ_TRY_RUN_PASSED)
endif()
message(WARNING
"Failed to compile a simple program that uses "
"NetCDF-Fortran ${CONDITIONAL_AND_OMP}! Could "
"your NetCDF installation be broken?\nSee "
"\"FailedCompile.txt\" for more info."
"${CONDITIONAL_AND_OMP}!"
"\nSee \"FailedCompile.txt\" for more info."
)
file(WRITE ${CMAKE_BINARY_DIR}/FailedCompile.txt
"${COMPILE_OUTPUT}"
Expand All @@ -379,7 +354,7 @@ if(NOT CLOUDJ_EXTERNAL_CONFIG AND NOT CLOUDJ_TRY_RUN_PASSED)
set(CONDITIONAL_AND_OMP "and OpenMP ")
endif()
message(WARNING
"A simple program that uses NetCDF-Fortran "
"A simple program that uses "
"${CONDITIONAL_AND_OMP}compiled successfully, "
"but its execution failed!\n\nSee "
"\"FailedExecution.txt\" for more info."
Expand Down Expand Up @@ -410,3 +385,19 @@ endif()
# Add source code directory
#-----------------------------------------------------------------------------
add_subdirectory(src)

#-----------------------------------------------------------------------------
# Add test directory
#-----------------------------------------------------------------------------
if (CLOUDJ_ENABLE_TESTS)
enable_testing()

add_subdirectory(test)

#-----------------------------------------------------------------------------
# The executable needs the data tables, copy them into the bin directory if tests are enabled
#-----------------------------------------------------------------------------

add_custom_target(copy_table_data ALL ${CMAKE_COMMAND} -E copy_directory
${PROJECT_SOURCE_DIR}/tables ${PROJECT_BINARY_DIR}/bin/tables)
endif()
Loading