Skip to content

Commit 8a51790

Browse files
author
Hoang-Giang Bui
committed
Adjust the workflow and tests on Darwin
1 parent d1958c8 commit 8a51790

10 files changed

Lines changed: 338 additions & 171 deletions

File tree

.github/workflows/macos.yml

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,83 @@
11
name: macOS built test
22

33
on:
4-
#schedule:
5-
# - cron: 3 4 * * 0
4+
schedule:
5+
- cron: 3 4 * * 0
66
workflow_dispatch:
77

88
concurrency:
99
group: ${{ github.workflow }}-${{ github.ref }}
1010
cancel-in-progress: true
1111

1212
jobs:
13-
build-and-test:
14-
name: Build and test 4C on macOS
13+
build:
14+
name: Build 4C on macOS
1515
runs-on: macos-26
1616
steps:
1717
- uses: actions/checkout@v6
18-
- name: Preparation
19-
run: |
20-
g++ -v
21-
uname
22-
sysctl -n hw.physicalcpu
23-
pwd
24-
brew tap botantony/cmake3
25-
brew install cmake3
26-
echo "/opt/homebrew/opt/cmake3/bin" >> $GITHUB_PATH
27-
sudo ln -sf $(brew --prefix gcc@14)/bin/gfortran-14 /opt/homebrew/bin/gfortran
28-
brew install openmpi hdf5 llvm boost cln metis netcdf lld scalapack fftw
29-
echo "DYLD_LIBRARY_PATH=/opt/homebrew/lib:${DYLD_LIBRARY_PATH}" >> $GITHUB_ENV
30-
- name: Cache Dependencies
18+
- name: System preparation
19+
run: ./utilities/set_up_darwin.sh
20+
- name: Restore dependencies cache
3121
id: cache-deps
32-
uses: actions/cache@v4
22+
uses: actions/cache/restore@v4
3323
with:
34-
path: $HOME/opt
35-
key: ${{ runner.os }}-deps-${{ hashFiles('./dependencies/darwin/compile_dependencies.sh') }}
36-
- name: Install the dependencies
24+
path: ${{ env.HOME }}/opt
25+
key: ${{ runner.os }}-deps-${{ hashFiles('./dependencies/darwin/compile_dependencies.sh', 'dependencies/darwin/**/install.sh',
26+
'dependencies/current/**/install.sh') }}
27+
- name: Compile and install the dependencies
3728
if: steps.cache-deps.outputs.cache-hit != 'true'
3829
run: |
3930
echo "install the dependencies"
4031
cmake --version
41-
sh ./dependencies/darwin/compile_dependencies.sh
32+
./dependencies/darwin/compile_dependencies.sh
33+
- name: Save dependencies cache
34+
if: success() && steps.cache-deps.outputs.cache-hit != 'true'
35+
uses: actions/cache/save@v4
36+
with:
37+
path: ${{ env.HOME }}/opt
38+
key: ${{ runner.os }}-deps-${{ hashFiles('./dependencies/darwin/compile_dependencies.sh', 'dependencies/darwin/**/install.sh',
39+
'dependencies/current/**/install.sh') }}
40+
- name: Restore build cache
41+
id: cache-build
42+
uses: actions/cache/restore@v4
43+
with:
44+
path: build/
45+
key: ${{ runner.os }}-build-${{ github.sha }}
4246
- name: Build 4C
47+
if: steps.cache-build.outputs.cache-hit != 'true'
4348
run: |
4449
pwd
4550
g++ -v
46-
cmake -B build/ --fresh --preset=darwin-debug
51+
cmake -B build/ --fresh --preset=darwin
4752
cmake --build build/ --target full
53+
- name: Save build cache
54+
if: success() && steps.cache-build.outputs.cache-hit != 'true'
55+
uses: actions/cache/save@v4
56+
with:
57+
path: build/
58+
key: ${{ runner.os }}-build-${{ github.sha }}
59+
60+
test:
61+
name: Test 4C on macOS
62+
needs: build
63+
runs-on: macos-26
64+
steps:
65+
- uses: actions/checkout@v6
66+
- name: System preparation
67+
run: ./utilities/set_up_darwin.sh
68+
- name: Restore dependencies cache
69+
id: cache-deps
70+
uses: actions/cache/restore@v4
71+
with:
72+
path: ${{ env.HOME }}/opt
73+
key: ${{ runner.os }}-deps-${{ hashFiles('./dependencies/darwin/compile_dependencies.sh', 'dependencies/darwin/**/install.sh',
74+
'dependencies/current/**/install.sh') }}
75+
- name: Restore build cache
76+
id: cache-build
77+
uses: actions/cache/restore@v4
78+
with:
79+
path: build/
80+
key: ${{ runner.os }}-build-${{ github.sha }}
4881
- name: Run tests
4982
run: |
5083
echo "tests"

cmake/functions/four_c_testing_functions.cmake

Lines changed: 88 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,17 @@ function(_add_test_with_options)
203203
ADDITIONAL_FIXTURE
204204
TOTAL_PROCS
205205
TIMEOUT
206+
SKIP
206207
INPUT_FILE
207208
OUTPUT_DIR
208209
)
209-
set(multiValueArgs TEST_COMMAND REQUIRED_DEPENDENCIES LABELS CLEANUP_FIXTURES)
210+
set(multiValueArgs
211+
TEST_COMMAND
212+
REQUIRED_DEPENDENCIES
213+
LABELS
214+
EXCLUDE_PLATFORM
215+
CLEANUP_FIXTURES
216+
)
210217
cmake_parse_arguments(
211218
_parsed
212219
"${options}"
@@ -233,6 +240,10 @@ function(_add_test_with_options)
233240
set(_parsed_TOTAL_PROCS 1)
234241
endif()
235242

243+
if(NOT DEFINED _parsed_SKIP)
244+
set(_parsed_SKIP "OFF")
245+
endif()
246+
236247
if(NOT DEFINED _parsed_TIMEOUT)
237248
set(_parsed_TIMEOUT "")
238249
endif()
@@ -252,6 +263,11 @@ function(_add_test_with_options)
252263
# check if all required dependencies are present
253264
check_required_dependencies(skip_message "${_parsed_REQUIRED_DEPENDENCIES}")
254265

266+
# check if the test is marked to be skipped
267+
if(_parsed_SKIP STREQUAL "ON")
268+
set(skip_message "The test ${_parsed_NAME_OF_TEST} is marked to be skipped")
269+
endif()
270+
255271
if(NOT skip_message STREQUAL "")
256272
# The dummy test needs to report a arbitrary error code that ctest interprets as "skipped".
257273
set(dummy_command "echo \"${skip_message}\"; exit 42")
@@ -321,6 +337,7 @@ endfunction()
321337
# If multiple dependencies are provided, all must be met for the test to run.
322338
# Note that the version is the _internal_ version that 4C assigns to the dependency.
323339
# RETURN_AS: A variable name that allows to add further dependent tests based on this test.
340+
# EXCLUDE_PLATFORM: Mark to not run the test on specific platform.
324341
function(four_c_test)
325342
set(options "")
326343
set(oneValueArgs
@@ -330,7 +347,7 @@ function(four_c_test)
330347
OMP_THREADS
331348
RETURN_AS
332349
)
333-
set(multiValueArgs LABELS REQUIRED_DEPENDENCIES)
350+
set(multiValueArgs LABELS REQUIRED_DEPENDENCIES EXCLUDE_PLATFORM)
334351
cmake_parse_arguments(
335352
_parsed
336353
"${options}"
@@ -397,6 +414,14 @@ function(four_c_test)
397414
math(EXPR _parsed_TIMEOUT "${FOUR_C_TEST_TIMEOUT_SCALE} * ${_parsed_TIMEOUT}")
398415
endif()
399416

417+
# check if the platform is matched
418+
# By default we enable the test, but if EXCLUDE_PLATFORM is defined, e.g., Linux|Darwin|Windows,
419+
# then the test is ignored if the platform is matched.
420+
set(skip_var "OFF")
421+
if(CMAKE_SYSTEM_NAME IN_LIST _parsed_EXCLUDE_PLATFORM)
422+
set(skip_var "ON")
423+
endif()
424+
400425
_add_test_with_options(
401426
NAME_OF_TEST
402427
${name_of_test}
@@ -414,6 +439,8 @@ function(four_c_test)
414439
"${test_directory}"
415440
REQUIRED_DEPENDENCIES
416441
"${_parsed_REQUIRED_DEPENDENCIES}"
442+
SKIP
443+
"${skip_var}"
417444
)
418445
endfunction()
419446

@@ -433,6 +460,7 @@ endfunction()
433460
# LABELS: Add labels to the test
434461
# REQUIRED_DEPENDENCIES: Any required external dependencies. The test will be skipped if the dependencies are not met.
435462
# RETURN_AS: A variable name that allows to add further dependent tests based on this test.
463+
# EXCLUDE_PLATFORM: Mark to not run the restart test on specific platform.
436464
function(__four_c_test_restart)
437465
set(options SAME_FILE)
438466
set(oneValueArgs
@@ -445,7 +473,7 @@ function(__four_c_test_restart)
445473
RETURN_AS
446474
ASSERT_RESTART_STEP
447475
)
448-
set(multiValueArgs LABELS REQUIRED_DEPENDENCIES)
476+
set(multiValueArgs LABELS REQUIRED_DEPENDENCIES EXCLUDE_PLATFORM)
449477
cmake_parse_arguments(
450478
_parsed
451479
"${options}"
@@ -533,6 +561,21 @@ function(__four_c_test_restart)
533561
)
534562
endif()
535563

564+
# skip the restart test if the main test is skipped
565+
get_test_property(${_parsed_BASED_ON} SKIP_RETURN_CODE skip_code_base_var)
566+
if(skip_code_base_var STREQUAL "NOTFOUND")
567+
set(skip_var "OFF")
568+
else()
569+
set(skip_var "ON")
570+
endif()
571+
572+
# check if the platform is matched
573+
# By default we enable the test, but if EXCLUDE_PLATFORM is defined, e.g., Linux|Darwin|Windows,
574+
# then the test is ignored if the platform is matched.
575+
if(CMAKE_SYSTEM_NAME IN_LIST _parsed_EXCLUDE_PLATFORM)
576+
set(skip_var "ON")
577+
endif()
578+
536579
check_test_exists(_base_test_exists ${_parsed_BASED_ON})
537580
if(NOT _base_test_exists)
538581
message(FATAL_ERROR "Base test ${_parsed_BASED_ON} for restart does not exist.")
@@ -549,6 +592,8 @@ function(__four_c_test_restart)
549592
"${total_procs}"
550593
TIMEOUT
551594
"${_parsed_TIMEOUT}"
595+
SKIP
596+
"${skip_var}"
552597
LABELS
553598
"${_parsed_LABELS}"
554599
INPUT_FILE
@@ -602,6 +647,7 @@ endfunction()
602647
# optional parameters:
603648
# LABELS: add labels to the test
604649
# REQUIRED_DEPENDENCIES: any required external dependencies. The test will be skipped if the dependencies are not met.
650+
# EXCLUDE_PLATFORM: mark to not run the test on specific platform.
605651
#
606652
function(__four_c_test_add_csv_yaml_comparison)
607653
set(options "")
@@ -612,7 +658,7 @@ function(__four_c_test_add_csv_yaml_comparison)
612658
TOL_R
613659
TOL_A
614660
)
615-
set(multiValueArgs LABELS REQUIRED_DEPENDENCIES)
661+
set(multiValueArgs LABELS REQUIRED_DEPENDENCIES EXCLUDE_PLATFORM)
616662
cmake_parse_arguments(
617663
_parsed
618664
"${options}"
@@ -642,6 +688,21 @@ function(__four_c_test_add_csv_yaml_comparison)
642688
"diff-with-tolerance ${test_directory}/${_parsed_RESULT_FILE} ${PROJECT_SOURCE_DIR}/tests/input_files/${_parsed_REFERENCE_FILE} ${_parsed_TOL_R} ${_parsed_TOL_A}"
643689
)
644690

691+
# skip the test if the main test is skipped
692+
get_test_property(${_parsed_BASED_ON} SKIP_RETURN_CODE skip_code_base_var)
693+
if(skip_code_base_var STREQUAL "NOTFOUND")
694+
set(skip_var "OFF")
695+
else()
696+
set(skip_var "ON")
697+
endif()
698+
699+
# check if the platform is matched
700+
# By default we enable the test, but if EXCLUDE_PLATFORM is defined, e.g., Linux|Darwin|Windows,
701+
# then the test is ignored if the platform is matched.
702+
if(CMAKE_SYSTEM_NAME IN_LIST _parsed_EXCLUDE_PLATFORM)
703+
set(skip_var "ON")
704+
endif()
705+
645706
# Ensure that Python is listed as required dependency
646707
list(APPEND _parsed_REQUIRED_DEPENDENCIES "Python")
647708
_add_test_with_options(
@@ -651,10 +712,14 @@ function(__four_c_test_add_csv_yaml_comparison)
651712
${csv_comparison_command}
652713
ADDITIONAL_FIXTURE
653714
${_parsed_BASED_ON}
715+
SKIP
716+
"${skip_var}"
654717
LABELS
655718
"${_parsed_LABELS}"
656719
REQUIRED_DEPENDENCIES
657720
"${_parsed_REQUIRED_DEPENDENCIES}"
721+
SKIP
722+
"${skip_var}"
658723
)
659724
endfunction()
660725

@@ -908,9 +973,10 @@ endfunction()
908973
# The supported version constraint operators are: >=, <=, >, <, ==
909974
# If multiple dependencies are provided, all must be met for the test to run.
910975
# Note that the version is the _internal_ version that 4C assigns to the dependency.
976+
# EXCLUDE_PLATFORM: Mark to not run the test on specific platform.
911977
function(four_c_test_tutorial)
912978
set(oneValueArgs TEST_FILE NP TIMEOUT)
913-
set(multiValueArgs COPY_FILES REQUIRED_DEPENDENCIES)
979+
set(multiValueArgs COPY_FILES REQUIRED_DEPENDENCIES EXCLUDE_PLATFORM)
914980
cmake_parse_arguments(
915981
_parsed
916982
"${options}"
@@ -964,6 +1030,13 @@ function(four_c_test_tutorial)
9641030
# check whether the dependencies are required
9651031
check_required_dependencies(skip_message "${_parsed_REQUIRED_DEPENDENCIES}")
9661032

1033+
# check if the test is marked to be skipped
1034+
if(skip_message STREQUAL "")
1035+
if(CMAKE_SYSTEM_NAME IN_LIST _parsed_EXCLUDE_PLATFORM)
1036+
set(skip_message "The test ${name_of_test} is marked to be skipped")
1037+
endif()
1038+
endif()
1039+
9671040
if(NOT skip_message STREQUAL "")
9681041
# The dummy test needs to report a arbitrary error code that ctest interprets as "skipped".
9691042
set(dummy_command "echo \"${message}\"; exit 42")
@@ -1163,6 +1236,14 @@ function(__four_c_test_vtk)
11631236
# Ensure that Python is listed as required dependency
11641237
list(APPEND _parsed_REQUIRED_DEPENDENCIES "Python")
11651238

1239+
# skip the test if the main test is skipped
1240+
get_test_property(${_parsed_BASED_ON} SKIP_RETURN_CODE skip_code_base_var)
1241+
if(skip_code_base_var STREQUAL "NOTFOUND")
1242+
set(skip_var "OFF")
1243+
else()
1244+
set(skip_var "ON")
1245+
endif()
1246+
11661247
# Add test
11671248
_add_test_with_options(
11681249
NAME_OF_TEST
@@ -1175,6 +1256,8 @@ function(__four_c_test_vtk)
11751256
"1"
11761257
TIMEOUT
11771258
"${_parsed_TIMEOUT}"
1259+
SKIP
1260+
"${skip_var}"
11781261
LABELS
11791262
"${_parsed_LABELS}"
11801263
OUTPUT_DIR

dependencies/darwin/compile_dependencies.sh

100644100755
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
#!/bin/zsh
1+
#!/usr/bin/env bash
2+
23
# This file is part of 4C multiphysics licensed under the
34
# GNU Lesser General Public License v3.0 or later.
45
#
56
# See the LICENSE.md file in the top-level for license information.
67
#
78
# SPDX-License-Identifier: LGPL-3.0-or-later
89

10+
# Exit the script at the first failure
11+
set -e
12+
913
export DEP_DIR=$HOME/opt
1014

15+
# workaround for cmake-4
16+
export CMAKE_POLICY_VERSION_MINIMUM=3.5
17+
1118
# compiled the dependencies
1219
cd dependencies/current/backtrace
1320
sh install.sh $DEP_DIR/libbacktrace

dependencies/darwin/mumps/install.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,26 @@ set -e
1616
INSTALL_DIR="$1"
1717
# Number of procs for building (default 4)
1818
NPROCS=${NPROCS=4}
19-
VERSION="5.6.0"
20-
CHECKSUM="3e08c1bdea7aaaba303d3cf03059f3b4336fa49bef93f4260f478f067f518289"
19+
PREFIX="mumps-debian-"
20+
VERSION="5.6.2-2"
21+
CHECKSUM="5555eead9891938a54f12bf5c0cbd77e906648bb5409e97d69f29adaaf59a295"
2122

22-
wget --no-verbose https://ftp.mcs.anl.gov/pub/petsc/externalpackages/MUMPS_${VERSION}.tar.gz
23+
wget --no-verbose https://salsa.debian.org/science-team/mumps/-/archive/debian/${VERSION}/${PREFIX}${VERSION}.tar.gz
2324
# Verify checksum
24-
if [ $CHECKSUM = `sha256sum MUMPS_${VERSION}.tar.gz | awk '{print $1}'` ]
25+
if [ $CHECKSUM = `sha256sum ${PREFIX}${VERSION}.tar.gz | awk '{print $1}'` ]
2526
then
2627
echo "Checksum matches"
2728
else
2829
echo "Checksum does not match"
2930
exit 1
3031
fi
3132

32-
tar -xzf MUMPS_${VERSION}.tar.gz
33-
cd MUMPS_${VERSION}/
33+
tar -xzf ${PREFIX}${VERSION}.tar.gz
34+
cd ${PREFIX}${VERSION}
3435
cp Make.inc/Makefile.inc.generic Makefile.inc
3536
make -j${NPROCS} FC=mpif90 FL=mpif90 \
36-
INCPAR="-I/opt/homebrew/include" \
37-
LIBPAR="-L/opt/homebrew/lib -lmetis -lparmetis -lscalapack -llapack" \
37+
INCPAR="-I/opt/homebrew/include -I$HOME/opt/parmetis/include" \
38+
LIBPAR="-L/opt/homebrew/lib -lmetis -lscalapack -llapack -L$HOME/opt/parmetis/lib -lparmetis" \
3839
ORDERINGSF="-Dpord -Dparmetis" \
3940
OPTF="-O3 -fallow-argument-mismatch"
4041
mkdir -p ${INSTALL_DIR}

0 commit comments

Comments
 (0)