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

GitHub Actions based testing for TriBITS (#363) #393

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c29c737
first try with CI (#363)
marcinwrobel1986 Jul 15, 2021
1f4eefc
added no fortran option (#363)
marcinwrobel1986 Jul 15, 2021
0a820c9
run job only when push on master branch (#363)
marcinwrobel1986 Jul 15, 2021
516e4b8
attempt to try different variants (#363)
marcinwrobel1986 Jul 16, 2021
abb9d26
added version checking (#363)
marcinwrobel1986 Jul 16, 2021
6a583e3
try to get specific versions (#363)
marcinwrobel1986 Jul 16, 2021
8bd47f0
separate removing and installation (#363)
marcinwrobel1986 Jul 16, 2021
2828e15
checks for testing purposes (#363)
marcinwrobel1986 Jul 16, 2021
28f09d1
removed checks (#363)
marcinwrobel1986 Jul 16, 2021
ea1bcc1
created aliases (#363)
marcinwrobel1986 Jul 16, 2021
53b85c6
check if aliases work (#363)
marcinwrobel1986 Jul 16, 2021
b5a7235
trying other way (#363)
marcinwrobel1986 Jul 16, 2021
66eba6b
fixed if (#363)
marcinwrobel1986 Jul 16, 2021
13738fb
fixed if (#363)
marcinwrobel1986 Jul 16, 2021
d384806
check for aliases (#363)
marcinwrobel1986 Jul 16, 2021
d42fa0e
try alternatives (#363)
marcinwrobel1986 Jul 16, 2021
390645a
try alternatives (#363)
marcinwrobel1986 Jul 16, 2021
cf1fb0d
try alternatives (#363)
marcinwrobel1986 Jul 16, 2021
c9d7fd2
fix memory problem (#363)
marcinwrobel1986 Jul 16, 2021
c43ae1c
removed unnecessary options (#363)
marcinwrobel1986 Jul 16, 2021
643451e
changing order of the tests (#363)
marcinwrobel1986 Jul 16, 2021
0bb8b63
No more hello_world.yml (#363)
bartlettroscoe Jul 19, 2021
49dd52f
Add 'generator' option (not used yet) (#363)
bartlettroscoe Jul 16, 2021
44eea91
Add GitHub Actions-specific driver (#363)
bartlettroscoe Jul 16, 2021
cf44d9b
Change max-parallel from 1 to 4 (#363)
bartlettroscoe Jul 19, 2021
4b3f451
Set 'fail-fast' to false (#363)
bartlettroscoe Jul 19, 2021
ad91648
Don't test build of docs for now (#363)
bartlettroscoe Jul 19, 2021
46fb97f
Rearrange options in matrix to match order in CTEST_BUILD_NAME (#363)
bartlettroscoe Jul 19, 2021
533268b
Make all builds use makefiles for now (#363)
bartlettroscoe Jul 19, 2021
1ea9945
Switch from cmake 3.17.0 to cmake 3.17.5 (#363)
bartlettroscoe Jul 20, 2021
4fdfceb
Disable failing cmake-3.21.0 tests for now (#363)
bartlettroscoe Jul 21, 2021
6ae2723
Install dependencies for and test build of docutils documentation (#363)
bartlettroscoe Jul 21, 2021
56b5036
Add manual and cron triggers, set proper CDash groups (#363)
bartlettroscoe Jul 21, 2021
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
33 changes: 0 additions & 33 deletions .github/workflows/hellow_world.yml

This file was deleted.

84 changes: 84 additions & 0 deletions .github/workflows/tribits_testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: TriBITS Testing

# Controls when the action will run.
# Triggers the workflow on push or pull request
# for the master and develop branch
on:
schedule:
- cron: '10 0 * * *' # Run 10 minutes after midnight
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
ctest_build_name:
description: 'CTEST_BUILD_NAME'
required: false
jobs:
build:
strategy:
max-parallel: 4 # Only limit to 1 for debugging?
fail-fast: false # Allow each job to run to completion even if other jobs fail first
matrix:
config:
- { os: ubuntu-latest, cmake: "3.17.5", generator: "makefiles", python: "2.7", cc: gcc-8, cxx: g++-8, fc: gfortran-8 }
- { os: ubuntu-latest, cmake: "3.17.5", generator: "makefiles", python: "3.8", cc: gcc-10, cxx: g++-10, fc: gfortran-10 }
- { os: ubuntu-latest, cmake: "3.17.5", generator: "makefiles", python: "3.8", cc: gcc-11, cxx: g++-11 }
- { os: ubuntu-latest, cmake: "3.21.0", generator: "makefiles", python: "3.8", cc: gcc-9, cxx: g++-9, fc: gfortran-9 }

runs-on: ${{ matrix.config.os }}

steps:
- uses: actions/checkout@v2

- name: Update OS
run: |
sudo apt-get update -y
- name: Install CMake
run: |
wget -O cmake.sh https://github.com/Kitware/CMake/releases/download/v${{ matrix.config.cmake }}/cmake-${{ matrix.config.cmake }}-Linux-x86_64.sh
sudo sh cmake.sh --skip-license --exclude-subdir --prefix=/usr/local/
- name: Install packages
run: |
sudo apt-get install -y ${{ matrix.config.cc }} ${{ matrix.config.cxx }} ${{ matrix.config.fc }}
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/${{ matrix.config.cc }} 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/${{ matrix.config.cxx }} 10
sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/${{ matrix.config.fc }} 10
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 20
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 20
sudo update-alternatives --set c++ /usr/bin/g++
sudo update-alternatives --install /usr/bin/fortrann fortrann /usr/bin/gfortran 20
sudo update-alternatives --set fortrann /usr/bin/gfortran
sudo apt-get -y install valgrind
sudo apt-get -y install ninja-build
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.config.python }}
- name: Install Python packages
run: |
pip3 install sphinx sphinx-rtd-theme # For testing doc build
- name: Version checks
run: |
echo "Checking Cmake path and version"
which cmake
cmake --version
echo "Checking gcc path and version"
which ${{ matrix.config.cc }}
${{ matrix.config.cc }} --version
echo "Checking g++ path and version"
which ${{ matrix.config.cxx }}
${{ matrix.config.cxx }} --version
if [ "${{ matrix.config.fc }}" = "" ]; then echo "No fortran compiler"; else echo "Checking gfortran path and version" && which ${{ matrix.config.fc }} && ${{ matrix.config.fc }} --version; fi
- name: Run configure, build, test, and submit to CDash
run: |
cd ..
./TriBITS/cmake/ctest/github_actions/run_github_actions_ctest_driver.sh \
--os ${{ matrix.config.os }} \
--cmake-ver ${{ matrix.config.cmake }} \
--generator ${{ matrix.config.generator }} \
--python-ver ${{ matrix.config.python }} \
--cxx-compiler-and-ver ${{ matrix.config.cxx }} \
--fortran-compiler-and-ver ${{ matrix.config.fc }}
50 changes: 50 additions & 0 deletions cmake/ctest/github_actions/ctest_github_actions_serial_debug.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
include("${CMAKE_CURRENT_LIST_DIR}/../TribitsProjCTestDriver.cmake")

set(CTEST_BUILD_NAME $ENV{CTEST_BUILD_NAME})

set(CTEST_TEST_TIMEOUT 60)
set(CTEST_DO_UPDATES OFF)
set_default_and_from_env(CTEST_BUILD_FLAGS "-j2")
set_default_and_from_env(CTEST_PARALLEL_LEVEL "2")

if (CTEST_BUILD_NAME MATCHES ".*_nofortran")
set(fortranCompilerStr "")
set(enableFortranStr "-DTriBITS_ENABLE_Fortran=OFF")
else()
set(fortranCompilerStr "-DCMAKE_Fortran_COMPILER=gfortran")
set(enableFortranStr "-DTriBITS_ENABLE_Fortran=ON")
endif()

set(buildTweaksFile "${CMAKE_CURRENT_LIST_DIR}/${CTEST_BUILD_NAME}_tweaks.cmake")
if (EXISTS "${buildTweaksFile}")
set(configureOptionsFilesStr
"-DTriBITS_CONFIGURE_OPTIONS_FILE=${buildTweaksFile}")
else()
set(configureOptionsFilesStr "")
endif()

set( EXTRA_CONFIGURE_OPTIONS
"${configureOptionsFilesStr}"
"-DBUILD_SHARED_LIBS:BOOL=ON"
"-DCMAKE_BUILD_TYPE=DEBUG"
"-DCMAKE_C_COMPILER=gcc"
"-DCMAKE_CXX_COMPILER=g++"
"${fortranCompilerStr}"
"${enableFortranStr}"
"-DTriBITS_CTEST_DRIVER_COVERAGE_TESTS=TRUE"
"-DTriBITS_CTEST_DRIVER_MEMORY_TESTS=TRUE"
"-DTriBITS_ENABLE_DOC_GENERATION_TESTS=ON"
"-DTriBITS_ENABLE_REAL_GIT_CLONE_TESTS=TRUE"
"-DTriBITS_TRACE_ADD_TEST=ON"
"-DTriBITS_SHOW_TEST_START_END_DATE_TIME=ON"
)

if ("$ENV{CTEST_TEST_TYPE}" STREQUAL "")
set(CTEST_TEST_TYPE Experimental)
endif()

#
# Run the CTest driver and submit to CDash
#

tribits_proj_ctest_driver()
192 changes: 192 additions & 0 deletions cmake/ctest/github_actions/run_github_actions_ctest_driver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
#!/bin/bash -e

#
# Run local configure/build/test and submit to CDash with
# tribits_ctest_driver().
#
# Usage:
#
# $ cd <some-base-dir>/
#
# <this-dir>/run_github_actions_ctest_driver.sh \
# --os <os> --cmake-ver <cmake-ver> \
# --generator ninja|makefiles \
# --python-ver <python-ver> \
# --cxx-compiler-and-ver <cxx-compiler-and-ver> \
# [ --fortran-compiler-and-ver <fortran-comiler-and-ver> ]
#
# This is called by the GitHub Actions script:
#
# TriBITS/.github/workflows/tribits_testing.yml
#
# but can also be run locally to develop on and debug.
#
# NOTE: This will create the subdir 'tribits-build' under $PWD if that
# directory does not already exist. But it will not delete an existing
# directly 'tribits-build' if it already exists (but that is usually fine to
# do rebulids).
#
# NOTE: One can control various behaviors and other options as documented with
# tribits_ctest_driver() including not submitting to CDash to do testing
# output spamming CDash by running with:
#
# env CTEST_DO_SUBMIT=OFF <this-dir>/run_github_actions_ctest_driver.sh [options]
#

# Get locaiton of TriBITS
if [ "$TRIBITS_BASE_DIR" == "" ] ; then
_ABS_FILE_PATH=`readlink -f $0`
_BASE_DIR=`dirname $_ABS_FILE_PATH`
TRIBITS_BASE_DIR=`realpath $_BASE_DIR/../../..`
fi


#
# Functions
#


function assert_option_has_value {
value=$1
if [[ ${value:0:1} == "-" ]] ; then
echo "Error, expecting a value, not next option '${value}'" >&2
exit 1
fi
}


function assert_required_option_set {
arg_name=$1
arg_value=$2
#echo "${arg_name} ${arg_value}"
if [[ "${arg_value}" == "" ]] ; then
echo "Error, argument ${arg_name} can not be empty!"
exit 1
fi
}


#
# A) Parse and assert command-line arguments
#

os=
cmake_ver=
cmake_generator=
python_ver=
cxx_compiler_and_ver=
fortran_compiler_and_ver=

while (( "$#" )); do
case "$1" in
--os)
assert_option_has_value $2
os=$2
shift 2
;;
--cmake-ver)
assert_option_has_value $2
cmake_ver=$2
shift 2
;;
--generator)
assert_option_has_value $2
cmake_generator=$2
shift 2
;;
--python-ver)
assert_option_has_value $2
python_ver=$2
shift 2
;;
--cxx-compiler-and-ver)
assert_option_has_value $2
cxx_compiler_and_ver=$2
shift 2
;;
--fortran-compiler-and-ver)
if [[ -n "$2" ]] && [[ ${2:0:1} != "-" ]]; then
fortran_compiler_and_ver=$2
shift 2
else
shift 1
fi
;;
*)
echo "Error: The argument '$1' is not supported!" >&2
exit 1
;;
esac
done

assert_required_option_set --os ${os}
assert_required_option_set --cmake-ver "${cmake_ver}"
assert_required_option_set --generator "${cmake_generator}"
assert_required_option_set --python-ver "${python_ver}"
assert_required_option_set --cxx-compiler-and-ver "${cxx_compiler_and_ver}"
# NOTE: Fortran is not required!


#
# B) Set up options for running build
#

echo
echo "Options to run set in github actions driver:"
echo

# CTEST_SITE
export CTEST_SITE=${os}
echo "CTEST_SITE = '${CTEST_SITE}'"

# CTEST_BUILD_NAME
CTEST_BUILD_NAME=tribits_cmake-${cmake_ver}_${cmake_generator}_python-${python_ver}_${cxx_compiler_and_ver}
if [[ "${fortran_compiler_and_ver}" == "" ]] ; then
CTEST_BUILD_NAME=${CTEST_BUILD_NAME}_nofortran
fi
export CTEST_BUILD_NAME
echo "CTEST_BUILD_NAME = '${CTEST_BUILD_NAME}'"

# CTEST_CMAKE_GENERATOR
if [[ "${cmake_generator}" == "ninja" ]] ; then
CTEST_CMAKE_GENERATOR=Ninja
elif [[ "${cmake_generator}" == "makefiles" ]] ; then
CTEST_CMAKE_GENERATOR="Unix Makefiles"
else
echo "Error, --generator ${cmake_generator} is invalid! Only 'makefiles', 'ninja'!" >&2
exit 1
fi
export CTEST_CMAKE_GENERATOR
echo "CTEST_CMAKE_GENERATOR = '${CTEST_CMAKE_GENERATOR}'"

# CTEST_TEST_TYPE
if [[ "${GITHUB_EVENT_NAME}" == "schedule" ]]; then
CTEST_TEST_TYPE=Nightly
elif [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
CTEST_TEST_TYPE=Continuous
else
CTEST_TEST_TYPE=Experimental
fi
export CTEST_TEST_TYPE
echo "CTEST_TEST_TYPE = '${CTEST_TEST_TYPE}'"


#
# C) Run the local configure, build, test and submit using exported vars above
#

echo

if [[ -d tribits-build ]] ; then
echo "tribits-build/ already exists so leaving it."
else
echo "tribits-build/ does not exist yet so creating it."
mkdir tribits-build
fi

cd tribits-build/

echo

ctest -V -S \
${TRIBITS_BASE_DIR}/cmake/ctest/github_actions/ctest_github_actions_serial_debug.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function(set_test_disables)
foreach (testName ${ARGN})
set(testNameDisableVar ${testName}_DISABLE)
message("-- Setting ${testNameDisableVar}=ON")
set(${testNameDisableVar} ON CACHE BOOL "Set in ${CMAKE_CURRENT_LIST_FILE}")
endforeach()
endfunction()

set_test_disables(
TriBITS_CTestDriver_PBP_PT_ALL_PASS_CALLS_2
TriBITS_CTestDriver_PBP_PT_ALL_PASS_CALLS_4
TriBITS_CTestDriver_PBP_ST_ALL_COVERAGE
TriBITS_CTestDriver_PBP_ST_ALL_MEMORY
TriBITS_CTestDriver_PBP_ST_ALL_PASS
TriBITS_CTestDriver_PBP_ST_BreakBuildAllOptionalPkg
TriBITS_CTestDriver_PBP_ST_BreakBuildLibOptionalPkg
TriBITS_CTestDriver_PBP_ST_BreakConfigureOptionalPkg
TriBITS_CTestDriver_PBP_ST_BreakConfigureRequiredPkg
TriBITS_CTestDriver_PBP_ST_BreakTestPkg
)