|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +env: |
| 6 | + BUILD_DIR: _build |
| 7 | + PIP_PACKAGES: >- |
| 8 | + meson==0.58.0 |
| 9 | + cmake |
| 10 | + ninja |
| 11 | + gcovr |
| 12 | + MACOS_BASEKIT_URL: >- |
| 13 | + https://registrationcenter-download.intel.com/akdlm/irc_nas/17969/m_BaseKit_p_2021.3.0.3043.dmg |
| 14 | + MACOS_HPCKIT_URL: >- |
| 15 | + https://registrationcenter-download.intel.com/akdlm/irc_nas/17890/m_HPCKit_p_2021.3.0.3226_offline.dmg |
| 16 | + LINUX_INTEL_COMPONENTS: >- |
| 17 | + intel-oneapi-compiler-fortran |
| 18 | + intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic |
| 19 | + intel-oneapi-mkl |
| 20 | + intel-oneapi-mkl-devel |
| 21 | +
|
| 22 | +jobs: |
| 23 | + build: |
| 24 | + runs-on: ${{ matrix.os }} |
| 25 | + strategy: |
| 26 | + fail-fast: false |
| 27 | + matrix: |
| 28 | + os: [ubuntu-latest] |
| 29 | + build: [meson] |
| 30 | + build-type: [debug] |
| 31 | + compiler: [intel] |
| 32 | + version: [2021] |
| 33 | + |
| 34 | + env: |
| 35 | + FC: ${{ matrix.compiler == 'intel' && 'ifort' || 'gfortran' }} |
| 36 | + CC: ${{ matrix.compiler == 'intel' && 'icc' || 'gcc' }} |
| 37 | + GCC_V: ${{ matrix.version }} |
| 38 | + OMP_NUM_THREADS: 1,2,1 |
| 39 | + PYTHON_V: 3.8 |
| 40 | + |
| 41 | + steps: |
| 42 | + - name: Checkout code |
| 43 | + uses: actions/checkout@v2 |
| 44 | + |
| 45 | + - uses: actions/setup-python@v1 |
| 46 | + with: |
| 47 | + python-version: ${{ env.PYTHON_V }} |
| 48 | + |
| 49 | + - name: Install GCC (OSX) |
| 50 | + if: ${{ contains(matrix.os, 'macos') && matrix.compiler == 'gnu' }} |
| 51 | + run: | |
| 52 | + brew install gcc@${{ env.GCC_V }} |
| 53 | + ln -s /usr/local/bin/gfortran-${GCC_V} /usr/local/bin/gfortran |
| 54 | + which gfortran-${GCC_V} |
| 55 | + which gfortran |
| 56 | +
|
| 57 | + - name: Install GCC (Linux) |
| 58 | + if: ${{ contains(matrix.os, 'ubuntu') && matrix.compiler == 'gnu' }} |
| 59 | + run: | |
| 60 | + sudo add-apt-repository ppa:ubuntu-toolchain-r/test |
| 61 | + sudo apt-get update |
| 62 | + sudo apt-get install -y gcc-${{ env.GCC_V}} gfortran-${{ env.GCC_V }} |
| 63 | + sudo update-alternatives \ |
| 64 | + --install /usr/bin/gcc gcc /usr/bin/gcc-${{ env.GCC_V }} 100 \ |
| 65 | + --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${{ env.GCC_V }} \ |
| 66 | + --slave /usr/bin/gcov gcov /usr/bin/gcov-${{ env.GCC_V }} |
| 67 | +
|
| 68 | + - name: Install GCC (Windows) |
| 69 | + if: ${{ contains(matrix.os, 'windows') && matrix.compiler == 'gnu' }} |
| 70 | + uses: msys2/setup-msys2@v2 |
| 71 | + with: |
| 72 | + msystem: MINGW64 |
| 73 | + update: false |
| 74 | + install: >- |
| 75 | + git |
| 76 | + mingw-w64-x86_64-gcc-fortran |
| 77 | + mingw-w64-x86_64-openblas |
| 78 | + mingw-w64-x86_64-lapack |
| 79 | + mingw-w64-x86_64-cmake |
| 80 | + mingw-w64-x86_64-meson |
| 81 | + mingw-w64-x86_64-ninja |
| 82 | +
|
| 83 | + - name: Prepare for cache restore |
| 84 | + if: ${{ matrix.compiler == 'intel' }} |
| 85 | + run: | |
| 86 | + sudo mkdir -p /opt/intel |
| 87 | + sudo chown $USER /opt/intel |
| 88 | +
|
| 89 | + - name: Cache Intel install |
| 90 | + if: ${{ matrix.compiler == 'intel' }} |
| 91 | + id: cache-install |
| 92 | + uses: actions/cache@v2 |
| 93 | + with: |
| 94 | + path: /opt/intel/oneapi |
| 95 | + key: install-${{ matrix.compiler }}-${{ matrix.version }}-${{ matrix.os }} |
| 96 | + |
| 97 | + - name: Install Intel (Linux) |
| 98 | + if: ${{ contains(matrix.os, 'ubuntu') && contains(matrix.compiler, 'intel') && steps.cache-install.outputs.cache-hit != 'true' }} |
| 99 | + run: | |
| 100 | + wget https://apt.repos.intel.com/intel-gpg-keys/${{ env.KEY }} |
| 101 | + sudo apt-key add ${{ env.KEY }} |
| 102 | + rm ${{ env.KEY }} |
| 103 | + echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list |
| 104 | + sudo apt-get update |
| 105 | + sudo apt-get install ${{ env.PKG }} |
| 106 | + env: |
| 107 | + KEY: GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB |
| 108 | + PKG: ${{ env.LINUX_INTEL_COMPONENTS }} |
| 109 | + |
| 110 | + - name: Install Intel BaseKit (OSX) |
| 111 | + if: ${{ contains(matrix.os, 'macos') && contains(matrix.compiler, 'intel') && steps.cache-install.outputs.cache-hit != 'true' }} |
| 112 | + run: | |
| 113 | + curl --output ${{ env.OUT }} --url "$URL" --retry 5 --retry-delay 5 |
| 114 | + hdiutil attach ${{ env.OUT }} |
| 115 | + if [ -z "$COMPONENTS" ]; then |
| 116 | + sudo /Volumes/"$(basename "$URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s --action install --eula=accept --continue-with-optional-error=yes --log-dir=. |
| 117 | + installer_exit_code=$? |
| 118 | + else |
| 119 | + sudo /Volumes/"$(basename "$URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s --action install --components="$COMPONENTS" --eula=accept --continue-with-optional-error=yes --log-dir=. |
| 120 | + installer_exit_code=$? |
| 121 | + fi |
| 122 | + hdiutil detach /Volumes/"$(basename "$URL" .dmg)" -quiet |
| 123 | + exit $installer_exit_code |
| 124 | + env: |
| 125 | + OUT: webimage-base.dmg |
| 126 | + URL: ${{ env.MACOS_BASEKIT_URL }} |
| 127 | + COMPONENTS: intel.oneapi.mac.mkl.devel |
| 128 | + |
| 129 | + - name: Install Intel HPCKit (OSX) |
| 130 | + if: ${{ contains(matrix.os, 'macos') && contains(matrix.compiler, 'intel') && steps.cache-install.outputs.cache-hit != 'true' }} |
| 131 | + run: | |
| 132 | + curl --output ${{ env.OUT }} --url "$URL" --retry 5 --retry-delay 5 |
| 133 | + hdiutil attach ${{ env.OUT }} |
| 134 | + if [ -z "$COMPONENTS" ]; then |
| 135 | + sudo /Volumes/"$(basename "$URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s --action install --eula=accept --continue-with-optional-error=yes --log-dir=. |
| 136 | + installer_exit_code=$? |
| 137 | + else |
| 138 | + sudo /Volumes/"$(basename "$URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s --action install --components="$COMPONENTS" --eula=accept --continue-with-optional-error=yes --log-dir=. |
| 139 | + installer_exit_code=$? |
| 140 | + fi |
| 141 | + hdiutil detach /Volumes/"$(basename "$URL" .dmg)" -quiet |
| 142 | + exit $installer_exit_code |
| 143 | + env: |
| 144 | + OUT: webimage-hpc.dmg |
| 145 | + URL: ${{ env.MACOS_HPCKIT_URL }} |
| 146 | + COMPONENTS: all |
| 147 | + |
| 148 | + - name: Setup Intel oneAPI environment |
| 149 | + if: ${{ matrix.compiler == 'intel' }} |
| 150 | + run: | |
| 151 | + source /opt/intel/oneapi/setvars.sh |
| 152 | + printenv >> $GITHUB_ENV |
| 153 | +
|
| 154 | + - name: Install build and test dependencies |
| 155 | + if: ${{ ! contains(matrix.os, 'windows') }} |
| 156 | + run: pip3 install ${{ env.PIP_PACKAGES }} ${{ env.PIP_EXTRAS }} |
| 157 | + |
| 158 | + - name: Configure build (meson) |
| 159 | + if: ${{ matrix.build == 'meson' }} |
| 160 | + run: >- |
| 161 | + meson setup ${{ env.BUILD_DIR }} |
| 162 | + --buildtype=debug |
| 163 | + --prefix=$PWD/_dist |
| 164 | + --libdir=lib |
| 165 | + --warnlevel=0 |
| 166 | + -Db_coverage=${{ env.COVERAGE }} |
| 167 | + ${{ env.MESON_ARGS }} |
| 168 | + env: |
| 169 | + COVERAGE: ${{ matrix.build-type == 'coverage' }} |
| 170 | + MESON_ARGS: ${{ matrix.compiler == 'intel' && '-Dfortran_link_args=-qopenmp' || '' }} |
| 171 | + |
| 172 | + - name: Configure build (CMake) |
| 173 | + if: ${{ matrix.build == 'cmake' }} |
| 174 | + run: >- |
| 175 | + cmake -B${{ env.BUILD_DIR }} |
| 176 | + -GNinja |
| 177 | + -DCMAKE_BUILD_TYPE=Debug |
| 178 | + -DCMAKE_INSTALL_PREFIX=$PWD/_dist |
| 179 | + -DCMAKE_INSTALL_LIBDIR=lib |
| 180 | +
|
| 181 | + - name: Build library |
| 182 | + run: ninja -C ${{ env.BUILD_DIR }} |
| 183 | + |
| 184 | + - name: Run unit tests |
| 185 | + if: ${{ matrix.build == 'meson' }} |
| 186 | + run: | |
| 187 | + meson test -C ${{ env.BUILD_DIR }} --print-errorlogs --no-rebuild --num-processes 2 -t 2 |
| 188 | +
|
| 189 | + - name: Run unit tests |
| 190 | + if: ${{ matrix.build == 'cmake' }} |
| 191 | + run: | |
| 192 | + ctest --output-on-failure --parallel 2 |
| 193 | + working-directory: ${{ env.BUILD_DIR }} |
| 194 | + |
| 195 | + - name: Create coverage report |
| 196 | + if: ${{ matrix.build == 'meson' && matrix.build-type == 'coverage' }} |
| 197 | + run: |
| 198 | + ninja -C ${{ env.BUILD_DIR }} coverage |
| 199 | + |
| 200 | + - name: Install project |
| 201 | + run: | |
| 202 | + ninja -C ${{ env.BUILD_DIR }} install |
| 203 | + echo "QCXMS_PREFIX=$PWD/_dist" >> $GITHUB_ENV |
| 204 | +
|
| 205 | + - name: Create package |
| 206 | + if: ${{ matrix.build == 'meson' }} |
| 207 | + run: | |
| 208 | + tar cvf ${{ env.OUTPUT }} _dist |
| 209 | + xz -T0 ${{ env.OUTPUT }} |
| 210 | + echo "QCXMS_OUTPUT=${{ env.OUTPUT }}.xz" >> $GITHUB_ENV |
| 211 | + env: |
| 212 | + OUTPUT: qcxms-${{ matrix.compiler }}-${{ matrix.version }}-${{ matrix.os }}.tar |
| 213 | + |
| 214 | + - name: Upload package |
| 215 | + if: ${{ matrix.build == 'meson' && matrix.build-type != 'coverage' }} |
| 216 | + uses: actions/upload-artifact@v2 |
| 217 | + with: |
| 218 | + name: ${{ env.QCXMS_OUTPUT }} |
| 219 | + path: ${{ env.QCXMS_OUTPUT }} |
| 220 | + |
| 221 | + - name: Upload coverage report |
| 222 | + if: ${{ matrix.build == 'meson' && matrix.build-type == 'coverage' }} |
| 223 | + uses: codecov/codecov-action@v1 |
0 commit comments