diff --git a/.github/workflows/hellow_world.yml b/.github/workflows/hellow_world.yml deleted file mode 100644 index d6783e218..000000000 --- a/.github/workflows/hellow_world.yml +++ /dev/null @@ -1,33 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: CI - -# Controls when the action will run. Triggers the workflow on push or pull request -# events but only for the master branch -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a 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 - - uses: actions/checkout@v2 - - # Runs a single command using the runners shell - - name: Run a one-line script - run: echo Hello, world! - - # Runs a set of commands using the runners shell - - name: Run a multi-line script - run: | - echo Add other actions to build, - echo test, and deploy your project. diff --git a/.github/workflows/tribits_testing.yml b/.github/workflows/tribits_testing.yml new file mode 100644 index 000000000..417047f65 --- /dev/null +++ b/.github/workflows/tribits_testing.yml @@ -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 }} diff --git a/cmake/ctest/github_actions/ctest_github_actions_serial_debug.cmake b/cmake/ctest/github_actions/ctest_github_actions_serial_debug.cmake new file mode 100644 index 000000000..d3eb42d3b --- /dev/null +++ b/cmake/ctest/github_actions/ctest_github_actions_serial_debug.cmake @@ -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() diff --git a/cmake/ctest/github_actions/run_github_actions_ctest_driver.sh b/cmake/ctest/github_actions/run_github_actions_ctest_driver.sh new file mode 100755 index 000000000..42a2e543f --- /dev/null +++ b/cmake/ctest/github_actions/run_github_actions_ctest_driver.sh @@ -0,0 +1,192 @@ +#!/bin/bash -e + +# +# Run local configure/build/test and submit to CDash with +# tribits_ctest_driver(). +# +# Usage: +# +# $ cd / +# +# /run_github_actions_ctest_driver.sh \ +# --os --cmake-ver \ +# --generator ninja|makefiles \ +# --python-ver \ +# --cxx-compiler-and-ver \ +# [ --fortran-compiler-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 /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 diff --git a/cmake/ctest/github_actions/tribits_cmake-3.21.0_makefiles_python-3.8_g++-9_tweaks.cmake b/cmake/ctest/github_actions/tribits_cmake-3.21.0_makefiles_python-3.8_g++-9_tweaks.cmake new file mode 100644 index 000000000..6629e3de9 --- /dev/null +++ b/cmake/ctest/github_actions/tribits_cmake-3.21.0_makefiles_python-3.8_g++-9_tweaks.cmake @@ -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 + )