|
| 1 | +name: msvc |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +permissions: |
| 6 | + contents: read # to fetch code (actions/checkout) |
| 7 | + |
| 8 | +jobs: |
| 9 | + msvc: |
| 10 | + runs-on: windows-latest |
| 11 | + |
| 12 | + strategy: |
| 13 | + # Allow other runners in the matrix to continue if some fail |
| 14 | + fail-fast: false |
| 15 | + |
| 16 | + matrix: |
| 17 | + library: [shared, static] |
| 18 | + include: |
| 19 | + - library: shared |
| 20 | + library-flags: -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF |
| 21 | + - library: static |
| 22 | + library-flags: -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON |
| 23 | + |
| 24 | + defaults: |
| 25 | + run: |
| 26 | + # Use bash as default shell |
| 27 | + shell: bash -el {0} |
| 28 | + |
| 29 | + env: |
| 30 | + CHERE_INVOKING: 1 |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: get CPU name |
| 34 | + shell: pwsh |
| 35 | + run : | |
| 36 | + Get-CIMInstance -Class Win32_Processor | Select-Object -Property Name |
| 37 | +
|
| 38 | + - name: checkout repository |
| 39 | + uses: actions/checkout@v3 |
| 40 | + |
| 41 | + - uses: conda-incubator/setup-miniconda@v2 |
| 42 | + with: |
| 43 | + auto-update-conda: true |
| 44 | + |
| 45 | + - name: cache conda packages |
| 46 | + id: conda-cache |
| 47 | + uses: actions/cache/restore@v3 |
| 48 | + with: |
| 49 | + path: C:/Miniconda/envs/test |
| 50 | + key: conda:msvc |
| 51 | + |
| 52 | + - name: install packages with conda |
| 53 | + if: ${{ steps.conda-cache.outputs.cache-hit != 'true' }} |
| 54 | + run: | |
| 55 | + echo ${{ steps.conda-cache.outputs.cache-hit }} |
| 56 | + conda info |
| 57 | + conda list |
| 58 | + conda install -y -c conda-forge --override-channels ccache |
| 59 | +
|
| 60 | + - name: save conda cache |
| 61 | + if: ${{ steps.conda-cache.outputs.cache-hit != 'true' }} |
| 62 | + uses: actions/cache/save@v3 |
| 63 | + with: |
| 64 | + path: C:/Miniconda/envs/test |
| 65 | + key: ${{ steps.conda-cache.outputs.cache-primary-key }} |
| 66 | + |
| 67 | + - name: Prepare ccache |
| 68 | + # Get cache location of ccache |
| 69 | + # Create key that is used in action/cache/restore and action/cache/save steps |
| 70 | + id: ccache-prepare |
| 71 | + run: | |
| 72 | + echo "ccachedir=$(cygpath -m $(ccache -k cache_dir))" >> $GITHUB_OUTPUT |
| 73 | + # We include the commit sha in the cache key, as new cache entries are |
| 74 | + # only created if there is no existing entry for the key yet. |
| 75 | + echo "key=ccache-msvc-${{ matrix.library }}-${{ github.ref }}-${{ github.sha }}" >> $GITHUB_OUTPUT |
| 76 | +
|
| 77 | + - name: Restore ccache |
| 78 | + uses: actions/cache/restore@v3 |
| 79 | + with: |
| 80 | + path: ${{ steps.ccache-prepare.outputs.ccachedir }} |
| 81 | + key: ${{ steps.ccache-prepare.outputs.key }} |
| 82 | + # Restore a matching ccache cache entry. Prefer same branch. |
| 83 | + restore-keys: | |
| 84 | + ccache-msvc-${{ matrix.library }}-${{ github.ref }} |
| 85 | + ccache-msvc-${{ matrix.library }} |
| 86 | + ccache-msvc |
| 87 | +
|
| 88 | + - name: Configure ccache |
| 89 | + # Limit the maximum size and switch on compression to avoid exceeding the total disk or cache quota. |
| 90 | + run: | |
| 91 | + which ccache |
| 92 | + test -d ${{ steps.ccache-prepare.outputs.ccachedir }} || mkdir -p ${{ steps.ccache-prepare.outputs.ccachedir }} |
| 93 | + echo "max_size = 250M" > ${{ steps.ccache-prepare.outputs.ccachedir }}/ccache.conf |
| 94 | + echo "compression = true" >> ${{ steps.ccache-prepare.outputs.ccachedir }}/ccache.conf |
| 95 | + ccache -p |
| 96 | + ccache -s |
| 97 | + echo $HOME |
| 98 | + cygpath -w $HOME |
| 99 | +
|
| 100 | + - name: setup MSVC toolchain |
| 101 | + uses: ilammy/msvc-dev-cmd@v1 |
| 102 | + |
| 103 | + - name: Configure OpenBLAS |
| 104 | + run: | |
| 105 | + mkdir build && cd build |
| 106 | + cmake -G"Ninja Multi-Config" \ |
| 107 | + -DCMAKE_BUILD_TYPE=Release \ |
| 108 | + ${{ matrix.library-flags }} \ |
| 109 | + -DNOFORTRAN=ON \ |
| 110 | + -DC_LAPACK=ON \ |
| 111 | + -DUSE_OPENMP=ON \ |
| 112 | + -DNUM_THREADS=64 \ |
| 113 | + -DTARGET=CORE2 \ |
| 114 | + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ |
| 115 | + -DCMAKE_Fortran_COMPILER_LAUNCHER=ccache \ |
| 116 | + .. |
| 117 | +
|
| 118 | + - name: Build OpenBLAS |
| 119 | + run: cd build && cmake --build . --config Release |
| 120 | + |
| 121 | + - name: Show ccache status |
| 122 | + continue-on-error: true |
| 123 | + run: ccache -s |
| 124 | + |
| 125 | + - name: Save ccache |
| 126 | + # Save the cache after we are done (successfully) building |
| 127 | + uses: actions/cache/save@v3 |
| 128 | + with: |
| 129 | + path: ${{ steps.ccache-prepare.outputs.ccachedir }} |
| 130 | + key: ${{ steps.ccache-prepare.outputs.key }} |
| 131 | + |
| 132 | + - name: Run tests |
| 133 | + id: run-ctest |
| 134 | + timeout-minutes: 60 |
| 135 | + run: cd build && PATH="${GITHUB_WORKSPACE}/build/lib/RELEASE;${PATH}" ctest -C Release |
| 136 | + |
| 137 | + - name: Re-run tests |
| 138 | + if: always() && (steps.run-ctest.outcome == 'failure') |
| 139 | + timeout-minutes: 60 |
| 140 | + run: | |
| 141 | + cd build |
| 142 | + echo "::group::Re-run ctest" |
| 143 | + PATH="${GITHUB_WORKSPACE}/build/lib/RELEASE;${PATH}" ctest -C Release --rerun-failed --output-on-failure || true |
| 144 | + echo "::endgroup::" |
| 145 | + echo "::group::Log from these tests" |
| 146 | + [ ! -f Testing/Temporary/LastTest.log ] || cat Testing/Temporary/LastTest.log |
| 147 | + echo "::endgroup::" |
0 commit comments