From aaa99f4867fb9b4a48a038ff02f63fa183bb3efb Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Sat, 20 Nov 2021 12:34:29 +0100 Subject: [PATCH] Update testing workflow --- .codecov.yml | 2 +- .github/workflows/build.yml | 404 ++++++++++++++++++++---------------- test/CMakeLists.txt | 6 +- 3 files changed, 233 insertions(+), 179 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index 7c2d7788..33ce4148 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,2 +1,2 @@ fixes: - - "/home/runner/work/grimme-lab/mctc-lib::" + - "/home/runner/work/mctc-lib/mctc-lib::" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b48b5d72..eb0d3b43 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,25 +3,107 @@ name: CI on: [push, pull_request] env: - M_BUILD_DIR: _build_meson - C_BUILD_DIR: _build_cmake + BUILD_DIR: _build PIP_PACKAGES: >- - meson - cmake + meson==0.58.0 ninja gcovr + MACOS_BASEKIT_URL: >- + https://registrationcenter-download.intel.com/akdlm/irc_nas/17969/m_BaseKit_p_2021.3.0.3043.dmg + MACOS_HPCKIT_URL: >- + https://registrationcenter-download.intel.com/akdlm/irc_nas/17890/m_HPCKit_p_2021.3.0.3226_offline.dmg + LINUX_INTEL_COMPONENTS: >- + intel-oneapi-compiler-fortran-2021.2.0 + intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2021.2.0 jobs: - gcc-build: + build: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] + build: [meson, cmake] + build-type: [debug] + compiler: [gnu] + version: [10] + + include: + - os: ubuntu-latest + build: fpm + build-type: debug + compiler: gnu + version: 10 + + - os: ubuntu-latest + build: meson + build-type: coverage + compiler: gnu + version: 9 + + - os: macos-latest + build: meson + build-type: coverage + compiler: gnu + version: 10 + + - os: ubuntu-latest + build: meson + build-type: coverage + compiler: gnu + version: 11 + + - os: macos-latest + build: meson + build-type: debug + compiler: gnu + version: 5 + + - os: ubuntu-latest + build: meson + build-type: debug + compiler: gnu + version: 7 + + - os: ubuntu-latest + build: cmake + build-type: debug + compiler: gnu + version: 8 + + - os: ubuntu-latest + build: meson + build-type: debug + compiler: gnu + version: 9 + + - os: ubuntu-latest + build: meson + build-type: debug + compiler: gnu + version: 11 + + - os: ubuntu-latest + build: meson + build-type: debug + compiler: intel + version: 2021 + + - os: macos-latest + build: meson + build-type: debug + compiler: intel + version: 2021 + + defaults: + run: + shell: ${{ matrix.shell || 'bash' }} env: - FC: gfortran - GCC_V: 9 + FC: ${{ matrix.compiler == 'intel' && 'ifort' || 'gfortran' }} + CC: ${{ matrix.compiler == 'intel' && 'icc' || 'gcc' }} + GCC_V: ${{ matrix.version }} + PYTHON_V: 3.8 steps: - name: Checkout code @@ -29,205 +111,177 @@ jobs: - uses: actions/setup-python@v1 with: - python-version: '3.x' + python-version: ${{ env.PYTHON_V }} - name: Install GCC (OSX) - if: contains(matrix.os, 'macos') + if: ${{ contains(matrix.os, 'macos') && matrix.compiler == 'gnu' }} run: | - ln -s /usr/local/bin/gfortran-${GCC_V} /usr/local/bin/gfortran - which gfortran-${GCC_V} - which gfortran + brew install gcc@${{ env.GCC_V }} + ln -s /usr/local/bin/gfortran-${{ env.GCC_V }} /usr/local/bin/gfortran + ln -s /usr/local/bin/gcc-${{ env.GCC_V }} /usr/local/bin/gcc + ln -s /usr/local/bin/g++-${{ env.GCC_V }} /usr/local/bin/g++ - name: Install GCC (Linux) - if: contains(matrix.os, 'ubuntu') + if: ${{ contains(matrix.os, 'ubuntu') && matrix.compiler == 'gnu' }} run: | - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \ - --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \ - --slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V} - - - name: Install meson/cmake - run: pip3 install ${{ env.PIP_PACKAGES }} - - - name: Configure meson build - run: >- - meson setup ${{ env.M_BUILD_DIR }} - --buildtype=debug - --prefix=$PWD/_mdist - --libdir=lib - -Db_coverage=true - - - name: Build project (meson) - run: meson compile -C ${{ env.M_BUILD_DIR }} - - - name: Run unit tests (meson) - run: meson test -C ${{ env.M_BUILD_DIR }} --print-errorlogs --no-rebuild - - - name: Install project (meson) - run: | - meson install -C ${{ env.M_BUILD_DIR }} --no-rebuild - echo "MCTC_M_PREFIX=$PWD/_mdist" >> $GITHUB_ENV - - - name: Create coverage report (meson) - run: ninja -C ${{ env.M_BUILD_DIR }} coverage - - - name: Upload coverage report - uses: codecov/codecov-action@v1 - - - name: Configure CMake build - run: >- - cmake - -B ${{ env.C_BUILD_DIR }} - -G Ninja - -DCMAKE_INSTALL_PREFIX=$PWD/_cdist - - - name: Build project (CMake) - run: cmake --build ${{ env.C_BUILD_DIR }} - - - name: Run unit tests (CTest) - run: ctest - working-directory: ${{ env.C_BUILD_DIR }} - - - name: Install project (CMake) - run: | - cmake --install ${{ env.C_BUILD_DIR }} - echo "MCTC_C_PREFIX=$PWD/_cdist" >> $GITHUB_ENV - - - name: Test integration (meson/meson) - run: | - meson _build_mm - meson compile -C _build_mm - working-directory: example - env: - PKG_CONFIG_PATH: ${{ env.MCTC_M_PREFIX }}/lib/pkgconfig - - - name: Test integration (CMake/meson) - run: | - meson _build_cm - meson compile -C _build_cm - working-directory: example - env: - PKG_CONFIG_PATH: ${{ env.MCTC_C_PREFIX }}/lib/pkgconfig - - - name: Test integration (CMake/CMake) - run: | - cmake -B _build_cc -G Ninja - cmake --build _build_cc - working-directory: example - env: - CMAKE_PREFIX_PATH: ${{ env.MCTC_C_PREFIX }}/lib/cmake - - - # Test native MinGW Windows build - mingw-build: - runs-on: windows-latest - strategy: - fail-fast: false - matrix: - include: [ - { msystem: MINGW64, arch: x86_64 }, - # { msystem: MINGW32, arch: i686 } - ] - defaults: - run: - shell: msys2 {0} - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Setup MSYS2 toolchain + sudo add-apt-repository ppa:ubuntu-toolchain-r/test + sudo apt-get update + sudo apt-get install -y gcc-${{ env.GCC_V}} gfortran-${{ env.GCC_V }} + sudo update-alternatives \ + --install /usr/bin/gcc gcc /usr/bin/gcc-${{ env.GCC_V }} 100 \ + --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ env.GCC_V }} \ + --slave /usr/bin/gcov gcov /usr/bin/gcov-${{ env.GCC_V }} + + - name: Install GCC (Windows) + if: ${{ contains(matrix.os, 'windows') && matrix.compiler == 'gnu' }} uses: msys2/setup-msys2@v2 with: - msystem: ${{ matrix.msystem }} + msystem: MINGW64 update: false install: >- git - mingw-w64-${{ matrix.arch }}-gcc-fortran - mingw-w64-${{ matrix.arch }}-cmake - mingw-w64-${{ matrix.arch }}-python - mingw-w64-${{ matrix.arch }}-python-pip - mingw-w64-${{ matrix.arch }}-ninja + mingw-w64-x86_64-gcc-fortran + mingw-w64-x86_64-openblas + mingw-w64-x86_64-lapack + mingw-w64-x86_64-meson + mingw-w64-x86_64-ninja + + - name: Install fpm + if: ${{ matrix.build == 'fpm' }} + uses: fortran-lang/setup-fpm@v3 + with: + fpm-version: 'v0.2.0' - - name: Install meson/cmake - run: pip3 install meson==0.56.2 + - name: Prepare for cache restore + if: ${{ matrix.compiler == 'intel' }} + run: | + sudo mkdir -p /opt/intel + sudo chown $USER /opt/intel - - name: Configure meson build - run: meson setup ${{ env.M_BUILD_DIR }} - env: - FC: gfortran - CC: gcc + - name: Cache Intel install + if: ${{ matrix.compiler == 'intel' }} + id: cache-install + uses: actions/cache@v2 + with: + path: /opt/intel/oneapi + key: install-${{ matrix.compiler }}-${{ matrix.version }}-${{ matrix.os }} - - name: Build project (meson) - run: meson compile -C ${{ env.M_BUILD_DIR }} + - name: Install Intel (Linux) + if: ${{ contains(matrix.os, 'ubuntu') && contains(matrix.compiler, 'intel') && steps.cache-install.outputs.cache-hit != 'true' }} + run: | + wget https://apt.repos.intel.com/intel-gpg-keys/${{ env.KEY }} + sudo apt-key add ${{ env.KEY }} + rm ${{ env.KEY }} + echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list + sudo apt-get update + sudo apt-get install ${{ env.PKG }} + env: + KEY: GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + PKG: ${{ env.LINUX_INTEL_COMPONENTS }} - - name: Run unit tests (meson) - run: meson test -C ${{ env.M_BUILD_DIR }} --print-errorlogs --no-rebuild + - name: Install Intel HPCKit (OSX) + if: ${{ contains(matrix.os, 'macos') && contains(matrix.compiler, 'intel') && steps.cache-install.outputs.cache-hit != 'true' }} + run: | + curl --output ${{ env.OUT }} --url "$URL" --retry 5 --retry-delay 5 + hdiutil attach ${{ env.OUT }} + if [ -z "$COMPONENTS" ]; then + sudo /Volumes/"$(basename "$URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s --action install --eula=accept --continue-with-optional-error=yes --log-dir=. + installer_exit_code=$? + else + sudo /Volumes/"$(basename "$URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s --action install --components="$COMPONENTS" --eula=accept --continue-with-optional-error=yes --log-dir=. + installer_exit_code=$? + fi + hdiutil detach /Volumes/"$(basename "$URL" .dmg)" -quiet + exit $installer_exit_code env: - OMP_NUM_THREADS: 2,1 + OUT: webimage-hpc.dmg + URL: ${{ env.MACOS_HPCKIT_URL }} + COMPONENTS: all - - name: Configure cmake build - run: cmake -B ${{ env.C_BUILD_DIR }} -G Ninja + - name: Setup Intel oneAPI environment + if: ${{ matrix.compiler == 'intel' }} + run: | + source /opt/intel/oneapi/setvars.sh + printenv >> $GITHUB_ENV - - name: Build project (CMake) - run: cmake --build ${{ env.C_BUILD_DIR }} + - name: Install build and test dependencies + if: ${{ ! contains(matrix.os, 'windows') }} + run: pip3 install ${{ env.PIP_PACKAGES }} - - name: Run unit tests (CTest) - run: ctest - working-directory: ${{ env.C_BUILD_DIR }} + - name: Configure build (meson) + if: ${{ matrix.build == 'meson' }} + run: >- + meson setup ${{ env.BUILD_DIR }} + --buildtype=debug + --prefix=$PWD/_dist + --libdir=lib + --warnlevel=0 + -Db_coverage=${{ env.COVERAGE }} + ${{ env.MESON_ARGS }} env: - OMP_NUM_THREADS: 2,1 + COVERAGE: ${{ matrix.build-type == 'coverage' }} + MESON_ARGS: ${{ matrix.compiler == 'intel' && '-Dfortran_link_args=-qopenmp' || '' }} + - name: Configure build (CMake) + if: ${{ matrix.build == 'cmake' }} + run: >- + cmake -B${{ env.BUILD_DIR }} + -GNinja + -DCMAKE_BUILD_TYPE=Debug + -DCMAKE_INSTALL_PREFIX=$PWD/_dist + -DCMAKE_INSTALL_LIBDIR=lib - intel-build: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-20.04] - - env: - FC: ifort - OMP_NUM_THREADS: 2,1 + - name: Build library (fpm) + if: ${{ matrix.build == 'fpm' }} + run: fpm build - steps: - - name: Checkout code - uses: actions/checkout@v2 + - name: Build library + if: ${{ matrix.build != 'fpm' }} + run: ninja -C ${{ env.BUILD_DIR }} - - uses: actions/setup-python@v1 - with: - python-version: '3.x' + - name: Run unit tests (fpm) + if: ${{ matrix.build == 'fpm' }} + run: fpm test - - name: Add Intel repository + - name: Run unit tests (meson) + if: ${{ matrix.build == 'meson' }} run: | - wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB - sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB - rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB - echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list - sudo apt-get update + meson test -C ${{ env.BUILD_DIR }} --print-errorlogs --no-rebuild --num-processes 2 -t 2 - - name: Install Intel oneAPI compiler + - name: Run unit tests (ctest) + if: ${{ matrix.build == 'cmake' }} run: | - sudo apt-get install intel-oneapi-compiler-fortran - source /opt/intel/oneapi/setvars.sh - printenv >> $GITHUB_ENV - - - name: Install meson/cmake - run: pip3 install ${{ env.PIP_PACKAGES }} + ctest --output-on-failure --parallel 2 + working-directory: ${{ env.BUILD_DIR }} - - name: Configure meson build - run: meson setup ${{ env.M_BUILD_DIR }} + - name: Create coverage report + if: ${{ matrix.build == 'meson' && matrix.build-type == 'coverage' }} + run: + ninja -C ${{ env.BUILD_DIR }} coverage - - name: Build library (meson) - run: meson compile -C ${{ env.M_BUILD_DIR }} + - name: Install project + if: ${{ matrix.build != 'fpm' }} + run: | + ninja -C ${{ env.BUILD_DIR }} install + echo "TBLITE_PREFIX=$PWD/_dist" >> $GITHUB_ENV - - name: Run unit tests (meson) - run: meson test -C ${{ env.M_BUILD_DIR }} --print-errorlogs --no-rebuild + - name: Create package + if: ${{ matrix.build == 'meson' }} + run: | + tar cvf ${{ env.OUTPUT }} _dist + xz -T0 ${{ env.OUTPUT }} + echo "TBLITE_OUTPUT=${{ env.OUTPUT }}.xz" >> $GITHUB_ENV + env: + OUTPUT: tblite-${{ matrix.compiler }}-${{ matrix.version }}-${{ matrix.os }}.tar - - name: Configure cmake build - run: cmake -B ${{ env.C_BUILD_DIR }} -G Ninja + - name: Upload package + if: ${{ matrix.build == 'meson' && matrix.build-type != 'coverage' }} + uses: actions/upload-artifact@v2 + with: + name: ${{ env.TBLITE_OUTPUT }} + path: ${{ env.TBLITE_OUTPUT }} - - name: Build library (CMake) - run: cmake --build ${{ env.C_BUILD_DIR }} + - name: Upload coverage report + if: ${{ matrix.build == 'meson' && matrix.build-type == 'coverage' }} + uses: codecov/codecov-action@v1 - - name: Run unit tests (CTest) - run: ctest - working-directory: ${{ env.C_BUILD_DIR }} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bfe792e1..6c97db26 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -45,15 +45,15 @@ foreach(t IN LISTS tests) endforeach() add_executable( - tester + "${PROJCET_NAME}-tester" "${test-srcs}" ) target_link_libraries( - tester + "${PROJECT_NAME}-tester" PRIVATE "${PROJECT_NAME}-lib" ) foreach(t IN LISTS tests) - add_test("${t}" tester "${t}") + add_test("${PROJECT_NAME}/${t}" tester "${t}") endforeach()