From 7e85cb19ad4f781e8c7af3f76d3ef47ccfc8ff9f Mon Sep 17 00:00:00 2001 From: Franck HOUSSEN Date: Sun, 6 Feb 2022 11:49:54 +0100 Subject: [PATCH] CI: fix github-actions workflow. c45094c broke the workflow: CI triggered on PR (modified code) was actually testing master codebase (untouched code). Solution: - Drop pull_request_target: use pull_request - Drop all docker jobs (which need pull_request_target to be based on master to be able to access opencollab secrets) - Remove opencollab secrets (docker login and password) - Drop coverage jobs (OK with TravisCI but never worked with github-actions) --- .github/workflows/jobs.yml | 121 ++++----- CMakeLists.txt | 43 --- cmake/Coveralls.cmake | 128 --------- cmake/CoverallsClear.cmake | 24 -- cmake/CoverallsGenerateGcov.cmake | 430 ------------------------------ scripts/travis_centos.sh | 47 ---- scripts/travis_redhat.sh | 32 +++ 7 files changed, 84 insertions(+), 741 deletions(-) delete mode 100644 cmake/Coveralls.cmake delete mode 100644 cmake/CoverallsClear.cmake delete mode 100644 cmake/CoverallsGenerateGcov.cmake delete mode 100755 scripts/travis_centos.sh create mode 100755 scripts/travis_redhat.sh diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index 9986f757f..b8853d619 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -1,13 +1,18 @@ name: arpack-ng -on: [push, pull_request_target] +on: [push, pull_request] jobs: ubuntu_latest_cmake: runs-on: ubuntu-latest steps: - name: Clone and check out repository code uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{github.event.pull_request.head.ref}} # Branch where changes are implemented. + repository: ${{github.event.pull_request.head.repo.full_name}} # Repo where changes are implemented. - name: Check commit - run: git log -1 + run: | + git log -1 - name: Update OS run: sudo apt-get update - name: Install apt-get dependencies @@ -25,8 +30,13 @@ jobs: steps: - name: Clone and check out repository code uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{github.event.pull_request.head.ref}} # Branch where changes are implemented. + repository: ${{github.event.pull_request.head.repo.full_name}} # Repo where changes are implemented. - name: Check commit - run: git log -1 + run: | + git log -1 - name: Update OS run: sudo apt-get update - name: Install apt-get dependencies @@ -43,8 +53,13 @@ jobs: steps: - name: Clone and check out repository code uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{github.event.pull_request.head.ref}} # Branch where changes are implemented. + repository: ${{github.event.pull_request.head.repo.full_name}} # Repo where changes are implemented. - name: Check commit - run: git log -1 + run: | + git log -1 - name: Update OS run: sudo apt-get update - name: Install apt-get dependencies @@ -68,8 +83,13 @@ jobs: steps: - name: Clone and check out repository code uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{github.event.pull_request.head.ref}} # Branch where changes are implemented. + repository: ${{github.event.pull_request.head.repo.full_name}} # Repo where changes are implemented. - name: Check commit - run: git log -1 + run: | + git log -1 - name: Update OS run: sudo apt-get update - name: Install apt-get dependencies @@ -87,74 +107,21 @@ jobs: FCFLAGS: "-DMKL_ILP64 -I/usr/include/mkl" LIBS: "-Wl,--no-as-needed -L/usr/lib/x86_64-linux-gnu -lmkl_sequential -lmkl_core -lpthread -lm -ldl" INTERFACE64: "1" - ubuntu_latest_coverage: - runs-on: ubuntu-latest - steps: - - name: Clone and check out repository code - uses: actions/checkout@v2 - - name: Check commit - run: git log -1 - - name: Update OS - run: sudo apt-get update - - name: Install apt-get dependencies - run: sudo apt-get install -y gfortran gcc g++ openmpi-bin libopenmpi-dev libblas-dev liblapack-dev cmake - - name: Run job - run: | - mkdir build - cd build - cmake -DEXAMPLES=ON -DMPI=ON -DICB=ON -DCOVERALLS=ON .. - make all - make test - make coveralls - docker_centos: - runs-on: ubuntu-latest - steps: - - name: Clone and check out repository code - uses: actions/checkout@v2 - - name: Check commit - run: git log -1 - - name: Update OS - run: sudo apt-get update - - name: Login to Docker Hub - run: sudo docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_TOKEN }}" - - name: Run job - run: ./scripts/travis_centos.sh - docker_fedora: - runs-on: ubuntu-latest - steps: - - name: Clone and check out repository code - uses: actions/checkout@v2 - - name: Check commit - run: git log -1 - - name: Update OS - run: sudo apt-get update - - name: Login to Docker Hub - run: sudo docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_TOKEN }}" - - name: Run job - run: ./scripts/travis_fedora.sh setup mpich - docker_debian: - runs-on: ubuntu-latest - steps: - - name: Clone and check out repository code - uses: actions/checkout@v2 - - name: Check commit - run: git log -1 - - name: Update OS - run: sudo apt-get update - - name: Login to Docker Hub - run: sudo docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_TOKEN }}" - - name: Run job - run: ./scripts/travis_ubuntu.sh debian macos_latest_cmake: runs-on: macos-latest steps: - name: Clone and check out repository code uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{github.event.pull_request.head.ref}} # Branch where changes are implemented. + repository: ${{github.event.pull_request.head.repo.full_name}} # Repo where changes are implemented. - name: Check commit - run: git log -1 + run: | + git log -1 - name: Update OS run: | - brew rm gcc + brew uninstall --ignore-dependencies gcc brew update softwareupdate --install --all - name: Install brew dependencies @@ -166,7 +133,13 @@ jobs: run: | mkdir -p build cd build - LIBS="-framework Accelerate" FFLAGS="-ff2c -fno-second-underscore" FCFLAGS="-ff2c -fno-second-underscore" cmake -DBLA_VENDOR=Generic -DEXAMPLES=ON -DICB=ON -DMPI=ON .. + export FC=mpif90 # Uses gfortran. + export FFLAGS="-ff2c -fno-second-underscore" + export CC=mpicc # Uses clang. + export CFLAGS="-Qunused-arguments" + export CXX=mpic++ # Uses clang++. + export CXXFLAGS="-Qunused-arguments" + LIBS="-framework Accelerate" cmake -DBLA_VENDOR=Generic -DEXAMPLES=ON -DICB=ON -DMPI=ON .. make all make test macos_latest_autotools: @@ -174,11 +147,16 @@ jobs: steps: - name: Clone and check out repository code uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{github.event.pull_request.head.ref}} # Branch where changes are implemented. + repository: ${{github.event.pull_request.head.repo.full_name}} # Repo where changes are implemented. - name: Check commit - run: git log -1 + run: | + git log -1 - name: Update OS run: | - brew rm gcc + brew uninstall --ignore-dependencies gcc brew update softwareupdate --install --all - name: Install brew dependencies @@ -197,8 +175,13 @@ jobs: steps: - name: Clone and check out repository code uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{github.event.pull_request.head.ref}} # Branch where changes are implemented. + repository: ${{github.event.pull_request.head.repo.full_name}} # Repo where changes are implemented. - name: Check commit - run: git log -1 + run: | + git log -1 - name: Update OS run: | choco install -y msys2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e78126d9..d4113ac6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,17 +39,6 @@ option(INTERFACE64 "use the 64-bit integer interface (ILP64) for ARPACK, BLAS an set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -# We don't want this to run on every build. -option(COVERALLS "Generate coveralls data" OFF) -if (COVERALLS) - include(Coveralls) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") - # The no space is by design: issue in cmake. See CMP0004. - set(EXTRA_LDFLAGS "${EXTRA_LDFLAGS}-lgcov") -endif() - function(prefixlist list_name prefix) set(${list_name}_TMP) foreach(l ${${list_name}}) @@ -830,38 +819,6 @@ set(CPACK_SOURCE_IGNORE_FILES "/BUILD/" "/Build/" "/build/" "/local/") # Do not set(CPACK_SOURCE_PACKAGE_FILE_NAME "arpack-ng-${CPACK_VERSION_MAJOR}.${CPACK_VERSION_MINOR}.${CPACK_VERSION_PATCH}") include(CPack) -if (COVERALLS) - set(arpack_TST_SRC - ${arpack_SOURCE_DIR}/TESTS/bug_1323.f - ${arpack_SOURCE_DIR}/TESTS/bug_142.f - ${arpack_SOURCE_DIR}/TESTS/bug_142_gen.f - ${arpack_SOURCE_DIR}/TESTS/bug_58_double.f - ${arpack_SOURCE_DIR}/TESTS/bug_79_double_complex.f - ${arpack_SOURCE_DIR}/TESTS/dnsimp.f - ${arpack_SOURCE_DIR}/TESTS/mmio.f - ${arpack_SOURCE_DIR}/TESTS/bug_1315_single.c - ${arpack_SOURCE_DIR}/TESTS/bug_1315_double.c - ${arpack_SOURCE_DIR}/TESTS/icb_arpack_c.c - ${arpack_SOURCE_DIR}/TESTS/icb_arpack_cpp.cpp - ) - file(GLOB_RECURSE arpack_EX_F_SRC "${arpack_SOURCE_DIR}/EXAMPLES/*/*.f") - set(arpack_EX_CPP_SRC ${arpack_SOURCE_DIR}/EXAMPLES/MATRIX_MARKET/arpackmm.cpp) - - set(parpack_TST_SRC - ${arpack_SOURCE_DIR}/PARPACK/TESTS/MPI/issue46.f - ${arpack_SOURCE_DIR}/PARPACK/TESTS/MPI/icb_parpack_c.c - ${arpack_SOURCE_DIR}/PARPACK/TESTS/MPI/icb_parpack_cpp.cpp - ) - file(GLOB_RECURSE parpack_EX_F_SRC "${arpack_SOURCE_DIR}/PARPACK/EXAMPLES/MPI/*.f") - - # Create the coveralls target. - # Also lists the c/cpp files for test purposes - coveralls_setup( - "${arpacksrc_STAT_SRCS} ${arpackutil_STAT_SRCS} ${arpacksrc_ICB} ${arpack_TST_SRC} ${arpack_EX_F_SRC} ${arpack_EX_CPP_SRC} ${parpacksrc_STAT_SRCS} ${parpackutil_STAT_SRCS} ${parpacksrc_ICB} ${parpack_TST_SRC} ${parpack_EX_F_SRC}" # The source files. - ON # If we should upload. - "${PROJECT_SOURCE_DIR}/cmake/") # (Optional) Alternate project cmake module path. -endif() - function(libsummary title include libraries) message(" -- ${title}:") foreach(inc ${include}) diff --git a/cmake/Coveralls.cmake b/cmake/Coveralls.cmake deleted file mode 100644 index 425039731..000000000 --- a/cmake/Coveralls.cmake +++ /dev/null @@ -1,128 +0,0 @@ -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# Copyright (C) 2014 Joakim Söderberg -# - -set(_CMAKE_SCRIPT_PATH ${CMAKE_CURRENT_LIST_DIR}) # must be outside coveralls_setup() to get correct path - -# -# Param _COVERAGE_SRCS A list of source files that coverage should be collected for. -# Param _COVERALLS_UPLOAD Upload the result to coveralls? -# - -function(coveralls_setup _COVERAGE_SRCS _COVERALLS_UPLOAD) - - if (ARGC GREATER 2) - set(_CMAKE_SCRIPT_PATH ${ARGN}) - message(STATUS "Coveralls: Using alternate CMake script dir: ${_CMAKE_SCRIPT_PATH}") - endif() - - if (NOT EXISTS "${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake") - message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake") - endif() - - if (NOT EXISTS "${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake") - message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake") - endif() - - # When passing a CMake list to an external process, the list - # will be converted from the format "1;2;3" to "1 2 3". - # This means the script we're calling won't see it as a list - # of sources, but rather just one long path. We remedy this - # by replacing ";" with "*" and then reversing that in the script - # that we're calling. - # http://cmake.3232098.n2.nabble.com/Passing-a-CMake-list-quot-as-is-quot-to-a-custom-target-td6505681.html - set(COVERAGE_SRCS_TMP ${_COVERAGE_SRCS}) - set(COVERAGE_SRCS "") - foreach (COVERAGE_SRC ${COVERAGE_SRCS_TMP}) - set(COVERAGE_SRCS "${COVERAGE_SRCS}*${COVERAGE_SRC}") - endforeach() - - #message("Coverage sources: ${COVERAGE_SRCS}") - set(COVERALLS_FILE ${PROJECT_BINARY_DIR}/coveralls.json) - - add_custom_target(coveralls_generate - - # Zero the coverage counters. - COMMAND ${CMAKE_COMMAND} -DPROJECT_BINARY_DIR="${PROJECT_BINARY_DIR}" -P "${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake" - - # Run regress tests. - COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure - - # Generate Gcov and translate it into coveralls JSON. - # We do this by executing an external CMake script. - # (We don't want this to run at CMake generation time, but after compilation and everything has run). - COMMAND ${CMAKE_COMMAND} - -DCOVERAGE_SRCS="${COVERAGE_SRCS}" # TODO: This is passed like: "a b c", not "a;b;c" - -DCOVERALLS_OUTPUT_FILE="${COVERALLS_FILE}" - -DCOV_PATH="${PROJECT_BINARY_DIR}" - -DPROJECT_ROOT="${PROJECT_SOURCE_DIR}" - -P "${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake" - - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - COMMENT "Generating coveralls output..." - ) - - if (_COVERALLS_UPLOAD) - message("COVERALLS UPLOAD: ON") - - find_program(CURL_EXECUTABLE curl) - - if (NOT CURL_EXECUTABLE) - message(FATAL_ERROR "Coveralls: curl not found! Aborting") - endif() - - add_custom_target(coveralls_upload - # Upload the JSON to coveralls. - COMMAND ${CURL_EXECUTABLE} - -S -F json_file=@${COVERALLS_FILE} - https://coveralls.io/api/v1/jobs - - DEPENDS coveralls_generate - - WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - COMMENT "Uploading coveralls output...") - - add_custom_target(coveralls DEPENDS coveralls_upload) - else() - message("COVERALLS UPLOAD: OFF") - add_custom_target(coveralls DEPENDS coveralls_generate) - endif() - -endfunction() - -macro(coveralls_turn_on_coverage) - if(NOT (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) - AND (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")) - message(FATAL_ERROR "Coveralls: Compiler ${CMAKE_C_COMPILER_ID} is not GNU gcc! Aborting... You can set this on the command line using CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake ..") - endif() - - if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") - message(FATAL_ERROR "Coveralls: Code coverage results with an optimised (non-Debug) build may be misleading! Add -DCMAKE_BUILD_TYPE=Debug") - endif() - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") -endmacro() - - - diff --git a/cmake/CoverallsClear.cmake b/cmake/CoverallsClear.cmake deleted file mode 100644 index eb68695a2..000000000 --- a/cmake/CoverallsClear.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# Copyright (C) 2014 Joakim Söderberg -# - -file(REMOVE_RECURSE ${PROJECT_BINARY_DIR}/*.gcda) - diff --git a/cmake/CoverallsGenerateGcov.cmake b/cmake/CoverallsGenerateGcov.cmake deleted file mode 100644 index d04cdf4e5..000000000 --- a/cmake/CoverallsGenerateGcov.cmake +++ /dev/null @@ -1,430 +0,0 @@ -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# Copyright (C) 2014 Joakim Söderberg -# -# This is intended to be run by a custom target in a CMake project like this. -# 0. Compile program with coverage support. -# 1. Clear coverage data. (Recursively delete *.gcda in build dir) -# 2. Run the unit tests. -# 3. Run this script specifying which source files the coverage should be performed on. -# -# This script will then use gcov to generate .gcov files in the directory specified -# via the COV_PATH var. This should probably be the same as your cmake build dir. -# -# It then parses the .gcov files to convert them into the Coveralls JSON format: -# https://coveralls.io/docs/api -# -# Example for running as standalone CMake script from the command line: -# (Note it is important the -P is at the end...) -# $ cmake -DCOV_PATH=$(pwd) -# -DCOVERAGE_SRCS="catcierge_rfid.c;catcierge_timer.c" -# -P ../cmake/CoverallsGcovUpload.cmake -# -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) - - -# -# Make sure we have the needed arguments. -# -if (NOT COVERALLS_OUTPUT_FILE) - message(FATAL_ERROR "Coveralls: No coveralls output file specified. Please set COVERALLS_OUTPUT_FILE") -endif() - -if (NOT COV_PATH) - message(FATAL_ERROR "Coveralls: Missing coverage directory path where gcov files will be generated. Please set COV_PATH") -endif() - -if (NOT COVERAGE_SRCS) - message(FATAL_ERROR "Coveralls: Missing the list of source files that we should get the coverage data for COVERAGE_SRCS") -endif() - -if (NOT PROJECT_ROOT) - message(FATAL_ERROR "Coveralls: Missing PROJECT_ROOT.") -endif() - -# Since it's not possible to pass a CMake list properly in the -# "1;2;3" format to an external process, we have replaced the -# ";" with "*", so reverse that here so we get it back into the -# CMake list format. -string(REGEX REPLACE "\\*" ";" COVERAGE_SRCS "${COVERAGE_SRCS}") - -find_program(GCOV_EXECUTABLE gcov) - -if (NOT GCOV_EXECUTABLE) - message(FATAL_ERROR "gcov not found! Aborting...") -endif() - -find_package(Git) - -# TODO: Add these git things to the coveralls json. -if (GIT_FOUND) - # Branch. - execute_process( - COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE GIT_BRANCH - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - macro (git_log_format FORMAT_CHARS VAR_NAME) - execute_process( - COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%${FORMAT_CHARS} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE ${VAR_NAME} - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - endmacro() - - git_log_format(an GIT_AUTHOR_EMAIL) - git_log_format(ae GIT_AUTHOR_EMAIL) - git_log_format(cn GIT_COMMITTER_NAME) - git_log_format(ce GIT_COMMITTER_EMAIL) - git_log_format(B GIT_COMMIT_MESSAGE) - - message("Git exe: ${GIT_EXECUTABLE}") - message("Git branch: ${GIT_BRANCH}") - message("Git author: ${GIT_AUTHOR_NAME}") - message("Git e-mail: ${GIT_AUTHOR_EMAIL}") - message("Git committer name: ${GIT_COMMITTER_NAME}") - message("Git committer e-mail: ${GIT_COMMITTER_EMAIL}") - message("Git commit message: ${GIT_COMMIT_MESSAGE}") - -endif() - -############################# Macros ######################################### - -# -# This macro converts from the full path format gcov outputs: -# -# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov -# -# to the original source file path the .gcov is for: -# -# /path/to/project/root/subdir/the_file.c -# -macro(get_source_path_from_gcov_filename _SRC_FILENAME _GCOV_FILENAME) - - # /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov - # -> - # #path#to#project#root#subdir#the_file.c.gcov - get_filename_component(_GCOV_FILENAME_WEXT ${_GCOV_FILENAME} NAME) - - # #path#to#project#root#subdir#the_file.c.gcov -> /path/to/project/root/subdir/the_file.c - string(REGEX REPLACE "\\.gcov$" "" SRC_FILENAME_TMP "${_GCOV_FILENAME_WEXT}") - string(REGEX REPLACE "\#" "/" SRC_FILENAME_TMP "${SRC_FILENAME_TMP}") - set(${_SRC_FILENAME} "${SRC_FILENAME_TMP}") -endmacro() - -############################################################################## - -# Get the coverage data. -file(GLOB_RECURSE GCDA_FILES "${COV_PATH}/*.gcda") -message("GCDA files:") - -# Get a list of all the object directories needed by gcov -# (The directories the .gcda files and .o files are found in) -# and run gcov on those. -foreach(GCDA ${GCDA_FILES}) - message("Process: ${GCDA}") - message("------------------------------------------------------------------------------") - get_filename_component(GCDA_DIR ${GCDA} PATH) - - # - # The -p below refers to "Preserve path components", - # This means that the generated gcov filename of a source file will - # keep the original files entire filepath, but / is replaced with #. - # Example: - # - # /path/to/project/root/build/CMakeFiles/the_file.dir/subdir/the_file.c.gcda - # ------------------------------------------------------------------------------ - # File '/path/to/project/root/subdir/the_file.c' - # Lines executed:68.34% of 199 - # /path/to/project/root/subdir/the_file.c:creating '#path#to#project#root#subdir#the_file.c.gcov' - # - # If -p is not specified then the file is named only "the_file.c.gcov" - # - execute_process( - COMMAND ${GCOV_EXECUTABLE} -p -o ${GCDA_DIR} ${GCDA} - WORKING_DIRECTORY ${COV_PATH} - ) -endforeach() - -# TODO: Make these be absolute path -file(GLOB ALL_GCOV_FILES ${COV_PATH}/*.gcov) - -# Get only the filenames to use for filtering. -#set(COVERAGE_SRCS_NAMES "") -#foreach (COVSRC ${COVERAGE_SRCS}) -# get_filename_component(COVSRC_NAME ${COVSRC} NAME) -# message("${COVSRC} -> ${COVSRC_NAME}") -# list(APPEND COVERAGE_SRCS_NAMES "${COVSRC_NAME}") -#endforeach() - -# -# Filter out all but the gcov files we want. -# -# We do this by comparing the list of COVERAGE_SRCS filepaths that the -# user wants the coverage data for with the paths of the generated .gcov files, -# so that we only keep the relevant gcov files. -# -# Example: -# COVERAGE_SRCS = -# /path/to/project/root/subdir/the_file.c -# -# ALL_GCOV_FILES = -# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov -# /path/to/project/root/build/#path#to#project#root#subdir#other_file.c.gcov -# -# Result should be: -# GCOV_FILES = -# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov -# -set(GCOV_FILES "") -#message("Look in coverage sources: ${COVERAGE_SRCS}") -message("\nFilter out unwanted GCOV files:") -message("===============================") - -set(COVERAGE_SRCS_REMAINING ${COVERAGE_SRCS}) - -foreach (GCOV_FILE ${ALL_GCOV_FILES}) - - # - # /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov - # -> - # /path/to/project/root/subdir/the_file.c - get_source_path_from_gcov_filename(GCOV_SRC_PATH ${GCOV_FILE}) - - # Is this in the list of source files? - # TODO: We want to match against relative path filenames from the source file root... - list(FIND COVERAGE_SRCS ${GCOV_SRC_PATH} WAS_FOUND) - - if (NOT WAS_FOUND EQUAL -1) - message("YES: ${GCOV_FILE}") - list(APPEND GCOV_FILES ${GCOV_FILE}) - - # We remove it from the list, so we don't bother searching for it again. - # Also files left in COVERAGE_SRCS_REMAINING after this loop ends should - # have coverage data generated from them (no lines are covered). - list(REMOVE_ITEM COVERAGE_SRCS_REMAINING ${GCOV_SRC_PATH}) - else() - message("NO: ${GCOV_FILE}") - endif() -endforeach() - -# TODO: Enable setting these -set(JSON_SERVICE_NAME "travis-ci") -set(JSON_SERVICE_JOB_ID $ENV{TRAVIS_JOB_ID}) - -set(JSON_TEMPLATE -"{ - \"service_name\": \"\@JSON_SERVICE_NAME\@\", - \"service_job_id\": \"\@JSON_SERVICE_JOB_ID\@\", - \"source_files\": \@JSON_GCOV_FILES\@ -}" -) - -set(SRC_FILE_TEMPLATE -"{ - \"name\": \"\@GCOV_SRC_REL_PATH\@\", - \"source_digest\": \"\@GCOV_CONTENTS_MD5\@\", - \"coverage\": \@GCOV_FILE_COVERAGE\@ - }" -) - -message("\nGenerate JSON for files:") -message("=========================") - -set(JSON_GCOV_FILES "[") - -# Read the GCOV files line by line and get the coverage data. -foreach (GCOV_FILE ${GCOV_FILES}) - - get_source_path_from_gcov_filename(GCOV_SRC_PATH ${GCOV_FILE}) - file(RELATIVE_PATH GCOV_SRC_REL_PATH "${PROJECT_ROOT}" "${GCOV_SRC_PATH}") - - # The new coveralls API doesn't need the entire source (Yay!) - # However, still keeping that part for now. Will cleanup in the future. - file(MD5 "${GCOV_SRC_PATH}" GCOV_CONTENTS_MD5) - message("MD5: ${GCOV_SRC_PATH} = ${GCOV_CONTENTS_MD5}") - - # Loads the gcov file as a list of lines. - # (We first open the file and replace all occurrences of [] with _ - # because CMake will fail to parse a line containing unmatched brackets... - # also the \ to escaped \n in macros screws up things.) - # https://public.kitware.com/Bug/view.php?id=15369 - file(READ ${GCOV_FILE} GCOV_CONTENTS) - string(REPLACE "[" "_" GCOV_CONTENTS "${GCOV_CONTENTS}") - string(REPLACE "]" "_" GCOV_CONTENTS "${GCOV_CONTENTS}") - string(REPLACE "\\" "_" GCOV_CONTENTS "${GCOV_CONTENTS}") - file(WRITE ${GCOV_FILE}_tmp "${GCOV_CONTENTS}") - - file(STRINGS ${GCOV_FILE}_tmp GCOV_LINES) - list(LENGTH GCOV_LINES LINE_COUNT) - - # Instead of trying to parse the source from the - # gcov file, simply read the file contents from the source file. - # (Parsing it from the gcov is hard because C-code uses ; in many places - # which also happens to be the same as the CMake list delimiter). - file(READ ${GCOV_SRC_PATH} GCOV_FILE_SOURCE) - - string(REPLACE "\\" "\\\\" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}") - string(REGEX REPLACE "\"" "\\\\\"" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}") - string(REPLACE "\t" "\\\\t" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}") - string(REPLACE "\r" "\\\\r" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}") - string(REPLACE "\n" "\\\\n" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}") - # According to http://json.org/ these should be escaped as well. - # Don't know how to do that in CMake however... - #string(REPLACE "\b" "\\\\b" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}") - #string(REPLACE "\f" "\\\\f" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}") - #string(REGEX REPLACE "\u([a-fA-F0-9]{4})" "\\\\u\\1" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}") - - # We want a json array of coverage data as a single string - # start building them from the contents of the .gcov - set(GCOV_FILE_COVERAGE "[") - - set(GCOV_LINE_COUNT 1) # Line number for the .gcov. - set(DO_SKIP 0) - foreach (GCOV_LINE ${GCOV_LINES}) - #message("${GCOV_LINE}") - # Example of what we're parsing: - # Hitcount |Line | Source - # " 8: 26: if (!allowed || (strlen(allowed) == 0))" - string(REGEX REPLACE - "^([^:]*):([^:]*):(.*)$" - "\\1;\\2;\\3" - RES - "${GCOV_LINE}") - - # Check if we should exclude lines using the Lcov syntax. - string(REGEX MATCH "LCOV_EXCL_START" START_SKIP "${GCOV_LINE}") - string(REGEX MATCH "LCOV_EXCL_END" END_SKIP "${GCOV_LINE}") - string(REGEX MATCH "LCOV_EXCL_LINE" LINE_SKIP "${GCOV_LINE}") - - set(RESET_SKIP 0) - if (LINE_SKIP AND NOT DO_SKIP) - set(DO_SKIP 1) - set(RESET_SKIP 1) - endif() - - if (START_SKIP) - set(DO_SKIP 1) - message("${GCOV_LINE_COUNT}: Start skip") - endif() - - if (END_SKIP) - set(DO_SKIP 0) - endif() - - list(LENGTH RES RES_COUNT) - - if (RES_COUNT GREATER 2) - list(GET RES 0 HITCOUNT) - list(GET RES 1 LINE) - list(GET RES 2 SOURCE) - - string(STRIP ${HITCOUNT} HITCOUNT) - string(STRIP ${LINE} LINE) - - # Lines with 0 line numbers are metadata and can be ignored. - if (NOT ${LINE} EQUAL 0) - - if (DO_SKIP) - set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}null, ") - else() - # Translate the hitcount into valid JSON values. - if (${HITCOUNT} STREQUAL "#####") - set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}0, ") - elseif (${HITCOUNT} STREQUAL "-") - set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}null, ") - else() - set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}${HITCOUNT}, ") - endif() - endif() - endif() - else() - message(WARNING "Failed to properly parse line (RES_COUNT = ${RES_COUNT}) ${GCOV_FILE}:${GCOV_LINE_COUNT}\n-->${GCOV_LINE}") - endif() - - if (RESET_SKIP) - set(DO_SKIP 0) - endif() - math(EXPR GCOV_LINE_COUNT "${GCOV_LINE_COUNT}+1") - endforeach() - - message("${GCOV_LINE_COUNT} of ${LINE_COUNT} lines read!") - - # Advanced way of removing the trailing comma in the JSON array. - # "[1, 2, 3, " -> "[1, 2, 3" - string(REGEX REPLACE ",[ ]*$" "" GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}") - - # Append the trailing ] to complete the JSON array. - set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}]") - - # Generate the final JSON for this file. - message("Generate JSON for file: ${GCOV_SRC_REL_PATH}...") - string(CONFIGURE ${SRC_FILE_TEMPLATE} FILE_JSON) - - set(JSON_GCOV_FILES "${JSON_GCOV_FILES}${FILE_JSON}, ") -endforeach() - -# Loop through all files we couldn't find any coverage for -# as well, and generate JSON for those as well with 0% coverage. -string(REPLACE "\\ " ";" COVERAGE_SRCS_REMAINING "${COVERAGE_SRCS_REMAINING}") -string(REPLACE "\\" "" COVERAGE_SRCS_REMAINING "${COVERAGE_SRCS_REMAINING}") -foreach(NOT_COVERED_SRC ${COVERAGE_SRCS_REMAINING}) - # Loads the source file as a list of lines. - file(STRINGS ${NOT_COVERED_SRC} SRC_LINES) - - set(GCOV_FILE_COVERAGE "[") - set(GCOV_FILE_SOURCE "") - - foreach (SOURCE ${SRC_LINES}) - set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}0, ") - - string(REPLACE "\\" "\\\\" SOURCE "${SOURCE}") - string(REGEX REPLACE "\"" "\\\\\"" SOURCE "${SOURCE}") - string(REPLACE "\t" "\\\\t" SOURCE "${SOURCE}") - string(REPLACE "\r" "\\\\r" SOURCE "${SOURCE}") - set(GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}${SOURCE}\\n") - endforeach() - - # Remove trailing comma, and complete JSON array with ] - string(REGEX REPLACE ",[ ]*$" "" GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}") - set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}]") - - # Generate the final JSON for this file. - message("Generate JSON for non-gcov file: ${NOT_COVERED_SRC}...") - string(CONFIGURE ${SRC_FILE_TEMPLATE} FILE_JSON) - set(JSON_GCOV_FILES "${JSON_GCOV_FILES}${FILE_JSON}, ") -endforeach() - -# Get rid of trailing comma. -string(REGEX REPLACE ",[ ]*$" "" JSON_GCOV_FILES "${JSON_GCOV_FILES}") -set(JSON_GCOV_FILES "${JSON_GCOV_FILES}]") - -# Generate the final complete JSON! -message("Generate final JSON...") -string(CONFIGURE ${JSON_TEMPLATE} JSON) - -file(WRITE "${COVERALLS_OUTPUT_FILE}" "${JSON}") -message("###########################################################################") -message("Generated coveralls JSON containing coverage data:") -message("${COVERALLS_OUTPUT_FILE}") -message("###########################################################################") diff --git a/scripts/travis_centos.sh b/scripts/travis_centos.sh deleted file mode 100755 index b597c9f78..000000000 --- a/scripts/travis_centos.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -# usage: ./travis_centos.sh [:7|:8|:latest|:stream] -# -## -e : Make sure all errors cause the script to fail -## -x be verbose; write what we are doing, as we do it -set -ex - -# centos-stream should be pulled from quay.io -# note: a RedHad account is required after 2021.06, -# see https://quay.io/repository/centos/centos?tab=tags -if [ $1 = ":stream" ]; then - prefix="quay.io/centos/" -fi - -if [ $1 = ":7" ]; then # for 7 - pm="yum" - cmake="cmake3" -else # for 8+, stream - pm="dnf" - cmake="cmake" - cmd_powertools="dnf config-manager --set-enabled powertools &&" -fi - -sudo docker pull "${prefix}centos$1" \ -&& \ -sudo docker create --name mobydick ${prefix}centos$1 /bin/bash -c \ -"$pm install -y ${pm}-plugins-core epel-release && \ - $pm upgrade -y && \ - $cmd_powertools \ - $pm install -y git make gcc gcc-gfortran gcc-c++ environment-modules && \ - $pm install -y $cmake && \ - $pm install -y mpich-devel && \ - $pm --enablerepo=\"epel\" install -y openblas-devel lapack-devel && \ - . /etc/profile.d/modules.sh && \ - module avail && module load mpi && module list && \ - cd /tmp && \ - cd arpack-ng && \ - git status && \ - git log -2 && \ - mkdir -p build && cd build && \ - $cmake -DEXAMPLES=ON -DMPI=ON -DICB=ON .. && \ - make all && make test" \ -&& \ -sudo docker cp -a ${GITHUB_WORKSPACE} mobydick:/tmp \ -&& \ -sudo docker start -a mobydick - diff --git a/scripts/travis_redhat.sh b/scripts/travis_redhat.sh new file mode 100755 index 000000000..60ba0859c --- /dev/null +++ b/scripts/travis_redhat.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# usage: ./travis_centos.sh [:7|:8|:latest|:stream] +# +## -e : Make sure all errors cause the script to fail +## -x be verbose; write what we are doing, as we do it +set -ex + +podman pull registry.access.redhat.com/ubi8/ubi \ +&& \ +podman create --name ubi ${prefix}centos$1 /bin/bash -c \ +"cat /etc/os-release && \ + dnf install -y dnf-plugins-core epel-release && \ + dnf upgrade -y && \ + dnf config-manager --set-enabled powertools && \ + dnf install -y git make gcc gcc-gfortran gcc-c++ environment-modules && \ + dnf install -y cmake && \ + dnf install -y mpich-devel && \ + dnf --enablerepo=\"epel\" install -y openblas-devel lapack-devel && \ + . /etc/profile.d/modules.sh && \ + module avail && module load mpi && module list && \ + cd /tmp && \ + cd arpack-ng && \ + git status && \ + git log -2 && \ + mkdir -p build && cd build && \ + cmake -DEXAMPLES=ON -DMPI=ON -DICB=ON .. && \ + make all && make test" \ +&& \ +podman cp -a ${GITHUB_WORKSPACE} ubi:/tmp \ +&& \ +podman start -a ubi +