|
| 1 | +# This workflow builds and tests svZeroDSolver. It is built and tested on |
| 2 | +# different versions of ubuntu and macOS. |
| 3 | +name: Build and test |
| 4 | +on: [push, pull_request] |
| 5 | +jobs: |
| 6 | + test: |
| 7 | + runs-on: ${{ matrix.os }} |
| 8 | + strategy: |
| 9 | + matrix: |
| 10 | + os: [ubuntu-22.04, ubuntu-latest, macos-13, macos-latest, windows-latest] |
| 11 | + version: [13] # GCC version |
| 12 | + fail-fast: false |
| 13 | + env: |
| 14 | + GCC_V: ${{ matrix.version }} |
| 15 | + CONDA_ENV: zerod |
| 16 | + PYTHONPATH: ${{ github.workspace }} |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + - uses: conda-incubator/setup-miniconda@v3 |
| 20 | + with: |
| 21 | + auto-update-conda: true |
| 22 | + activate-environment: ${{env.CONDA_ENV}} |
| 23 | + python-version: "3.11.4" |
| 24 | + - name: Install ubuntu dependencies |
| 25 | + if: startsWith(matrix.os, 'ubuntu') |
| 26 | + run: sudo apt update && sudo apt install build-essential cmake lcov |
| 27 | + |
| 28 | + - name: Install dependencies to get correct version numbers (Ubuntu) |
| 29 | + if: startsWith(matrix.os, 'ubuntu') |
| 30 | + run: conda install -c conda-forge libstdcxx-ng=${GCC_V} gcc=${GCC_V} |
| 31 | + |
| 32 | + - name: Install dependencies to get correct version numbers (MacOS) |
| 33 | + if: startsWith(matrix.os, 'macos') |
| 34 | + run: | |
| 35 | + brew install gcc@${GCC_V} |
| 36 | + ln -s /usr/local/bin/gcc-${GCC_V} /usr/local/bin/gcc |
| 37 | +
|
| 38 | + - name: Install dependencies for windows |
| 39 | + if: startsWith(matrix.os, 'windows') |
| 40 | + shell: pwsh |
| 41 | + run: | |
| 42 | + choco install mingw --no-progress |
| 43 | + conda install -y -c conda-forge cmake graphviz python-graphviz pydot |
| 44 | + pip install --upgrade cmake-setuptools |
| 45 | +
|
| 46 | + - name: Install POISX-like svZeroDSolver |
| 47 | + if: ${{!startsWith(matrix.os, 'windows')}} |
| 48 | + run: conda run pip install -e ".[dev]" |
| 49 | + |
| 50 | + - name: Install Windows svZeroDSolver |
| 51 | + if: startsWith(matrix.os, 'windows') |
| 52 | + shell: pwsh |
| 53 | + run: | |
| 54 | + $Env:CMAKE_GENERATOR = 'MinGW Makefiles' |
| 55 | + Write-Host "→ Using CMAKE_GENERATOR = $Env:CMAKE_GENERATOR" |
| 56 | + pip install --no-build-isolation -v .[dev] |
| 57 | + pip show pysvzerod |
| 58 | +
|
| 59 | + - name: Install Networkx |
| 60 | + run: | |
| 61 | + conda run pip install networkx |
| 62 | +
|
| 63 | + - name: Test the build |
| 64 | + run: | |
| 65 | + cd tests |
| 66 | + conda run pytest -v --durations=0 --ignore=test_dirgraph.py |
| 67 | +
|
| 68 | + - name: Build using CMake for POISX-like Systems |
| 69 | + if: ${{!startsWith(matrix.os, 'windows')}} |
| 70 | + run: | |
| 71 | + mkdir Release |
| 72 | + cd Release |
| 73 | + cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_DISTRIBUTION=ON .. |
| 74 | + make -j2 |
| 75 | +
|
| 76 | + - name: Build using CMake for Windows Systems |
| 77 | + if: startsWith(matrix.os, 'windows') |
| 78 | + shell: pwsh |
| 79 | + run: | |
| 80 | + mkdir Release |
| 81 | + cd Release |
| 82 | + cmake -G "MinGW Makefiles" ` |
| 83 | + -DCMAKE_BUILD_TYPE=Release ` |
| 84 | + -DENABLE_DISTRIBUTION=ON ` |
| 85 | + .. |
| 86 | + cmake --build . --parallel 2 |
| 87 | +
|
| 88 | + - name: Test interface POISX-like Systems |
| 89 | + if: ${{!startsWith(matrix.os, 'windows')}} |
| 90 | + run: | |
| 91 | + cd tests/test_interface |
| 92 | + mkdir build_tests |
| 93 | + cd build_tests |
| 94 | + cmake ../ |
| 95 | + make -j2 |
| 96 | + cd test_01 |
| 97 | + ./svZeroD_interface_test01 ../../../../Release ../../test_01/svzerod_3Dcoupling.json |
| 98 | + cd ../test_02 |
| 99 | + ./svZeroD_interface_test02 ../../../../Release ../../test_02/svzerod_tuned.json |
| 100 | +
|
| 101 | + - name: Test interface Windows Systems |
| 102 | + if: startsWith(matrix.os, 'windows') |
| 103 | + shell: pwsh |
| 104 | + run: | |
| 105 | + cd tests/test_interface |
| 106 | + mkdir build_tests |
| 107 | + cd build_tests |
| 108 | + cmake -G "MinGW Makefiles" .. |
| 109 | + cmake --build . --parallel 2 |
| 110 | + cd test_01 |
| 111 | + ./svZeroD_interface_test01.exe ` |
| 112 | + ../../../../Release ` |
| 113 | + ../../test_01/svzerod_3Dcoupling.json |
| 114 | + |
| 115 | + cd ../test_02 |
| 116 | + ./svZeroD_interface_test02 ` |
| 117 | + ../../../../Release ` |
| 118 | + ../../test_02/svzerod_tuned.json |
| 119 | +
|
| 120 | + - name: Generate code coverage |
| 121 | + if: startsWith(matrix.os, 'ubuntu-22.04') |
| 122 | + run: | |
| 123 | + cd Release |
| 124 | + cmake -DENABLE_COVERAGE=ON .. |
| 125 | + make -j2 |
| 126 | + cd ../tests |
| 127 | + conda run pytest -v --durations=0 --coverage --ignore=test_dirgraph.py |
| 128 | + cd ../Release |
| 129 | + make coverage |
| 130 | +
|
| 131 | + - name: Save coverage report |
| 132 | + if: startsWith(matrix.os, 'ubuntu-22.04') |
| 133 | + uses: actions/upload-artifact@v4 |
| 134 | + with: |
| 135 | + name: coverage_report |
| 136 | + path: Release/coverage |
| 137 | + |
| 138 | + - name: Upload coverage reports to Codecov |
| 139 | + if: startsWith(matrix.os, 'ubuntu-22.04') |
| 140 | + uses: codecov/codecov-action@v4 |
| 141 | + env: |
| 142 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 143 | + |
| 144 | + - name: Build installer POISX-like Systems |
| 145 | + if: ${{!startsWith(matrix.os, 'windows')}} |
| 146 | + run: | |
| 147 | + cd Release |
| 148 | + cpack |
| 149 | + cp distribution/svZeroDSolver_* .. |
| 150 | +
|
| 151 | + - name: Install NSIS |
| 152 | + if: startsWith(matrix.os, 'windows') |
| 153 | + run: choco install nsis -y |
| 154 | + |
| 155 | + - name: Build installer Windows Systems |
| 156 | + if: startsWith(matrix.os, 'windows') |
| 157 | + shell: pwsh |
| 158 | + run: | |
| 159 | + # NSIS will be at C:\Program Files (x86)\NSIS\Bin |
| 160 | + echo "C:\Program Files (x86)\NSIS\Bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append |
| 161 | + cd Release |
| 162 | + cpack -C Release |
| 163 | + Copy-Item distribution\svZeroDSolver_* -Destination ..\ |
| 164 | +
|
| 165 | + - name: Upload installer |
| 166 | + uses: actions/upload-artifact@v4 |
| 167 | + with: |
| 168 | + name: ${{ matrix.os }} installer |
| 169 | + path: svZeroDSolver_* |
| 170 | + if-no-files-found: error |
0 commit comments