| 1 |
--- |
| 2 |
name: Windows build and test |
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- 'master' |
| 7 |
- 'stable/*' |
| 8 |
pull_request: |
| 9 |
branches: |
| 10 |
- '**' |
| 11 |
release: |
| 12 |
types: |
| 13 |
- created |
| 14 |
|
| 15 |
jobs: |
| 16 |
test: |
| 17 |
name: Run tests |
| 18 |
runs-on: ${{ matrix.os }} |
| 19 |
strategy: |
| 20 |
fail-fast: false |
| 21 |
matrix: |
| 22 |
include: [ |
| 23 |
{ os: windows-2019, arch: x86_64, msystem: mingw64, debug: true, suffix: "-dbg" }, |
| 24 |
{ os: windows-2019, arch: x86_64, msystem: mingw64, debug: false, suffix: "" }, |
| 25 |
{ os: windows-2019, arch: msvc, msystem: mingw64, debug: false, suffix: "-md" }, |
| 26 |
{ os: windows-2022, arch: msvc, msystem: mingw64, debug: false, suffix: "-md" }, |
| 27 |
] |
| 28 |
steps: |
| 29 |
- name: Checkout source |
| 30 |
uses: actions/checkout@v4 |
| 31 |
with: |
| 32 |
path: ${{ github.event.repository.name }} |
| 33 |
- name: Checkout coinbrew |
| 34 |
uses: actions/checkout@v4 |
| 35 |
with: |
| 36 |
repository: coin-or/coinbrew |
| 37 |
path: coinbrew |
| 38 |
- name: Set up msvc |
| 39 |
if: ${{ matrix.arch == 'msvc' }} |
| 40 |
uses: ilammy/msvc-dev-cmd@v1 |
| 41 |
- name: Set correct host flag and install requirements |
| 42 |
if: ${{ matrix.arch != 'msvc' }} |
| 43 |
run: | |
| 44 |
echo "host_flag=--host=${{ matrix.arch }}-w64-mingw32" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 45 |
C:\msys64\usr\bin\pacman -S mingw-w64-${{ matrix.arch }}-lapack mingw-w64-${{ matrix.arch }}-winpthreads-git mingw-w64-${{ matrix.arch }}-readline mingw-w64-${{ matrix.arch }}-suitesparse mingw-w64-${{ matrix.arch }}-metis --noconfirm |
| 46 |
- name: Set up msys with ${{ matrix.msystem }} |
| 47 |
uses: msys2/setup-msys2@v2 |
| 48 |
with: |
| 49 |
update: true |
| 50 |
install: >- |
| 51 |
base-devel |
| 52 |
git |
| 53 |
zip |
| 54 |
path-type: inherit |
| 55 |
msystem: ${{ matrix.msystem }} |
| 56 |
- name: Build project |
| 57 |
run: | |
| 58 |
ADD_ARGS=() |
| 59 |
ADD_ARGS+=( --skip='ThirdParty/Metis ThirdParty/Mumps ThirdParty/Blas ThirdParty/Lapack' ) |
| 60 |
ADD_BUILD_ARGS=() |
| 61 |
ADD_BUILD_ARGS+=( --build=x86_64-w64-mingw32 --tests main --enable-relocatable ) |
| 62 |
ADD_BUILD_ARGS+=( --verbosity 2 ) |
| 63 |
[[ ${{ matrix.debug }} == "true" ]] && ADD_BUILD_ARGS+=( --enable-debug ) |
| 64 |
[[ ${{ matrix.arch }} == "msvc" ]] && ADD_BUILD_ARGS+=( --enable-msvc ) |
| 65 |
./coinbrew/coinbrew fetch ${{ github.event.repository.name }} --skip-update "${ADD_ARGS[@]}" |
| 66 |
./coinbrew/coinbrew build ${{ github.event.repository.name }} ${{ env.host_flag }} \ |
| 67 |
"${ADD_ARGS[@]}" "${ADD_BUILD_ARGS[@]}" |
| 68 |
cp ${{ github.event.repository.name }}/README.md dist/ |
| 69 |
cp ${{ github.event.repository.name }}/LICENSE dist/ |
| 70 |
shell: msys2 {0} |
| 71 |
- name: Upload failed build directory |
| 72 |
uses: actions/upload-artifact@v4 |
| 73 |
if: failure() |
| 74 |
with: |
| 75 |
name: ${{ matrix.os}}-{{ matrix.arch }}-debug=${{ matrix.debug }}-failedbuild |
| 76 |
path: build |
| 77 |
- name: Generate package name for msvc |
| 78 |
run: | |
| 79 |
msvc_version=${VisualStudioVersion%.*} |
| 80 |
echo "package_suffix=w64-msvc${msvc_version}${{ matrix.suffix }}" >> $GITHUB_ENV |
| 81 |
shell: msys2 {0} |
| 82 |
if: ${{ matrix.arch == 'msvc' }} |
| 83 |
- name: Generate package name |
| 84 |
run: | |
| 85 |
echo "package_suffix=${{ matrix.arch }}-w64-${{ matrix.msystem }}${{ matrix.suffix }}" >> $GITHUB_ENV |
| 86 |
shell: msys2 {0} |
| 87 |
if: ${{ matrix.arch != 'msvc' }} |
| 88 |
- name: Upload artifact |
| 89 |
uses: actions/upload-artifact@v4 |
| 90 |
with: |
| 91 |
name: ${{ github.event.repository.name }}-${{ env.package_suffix }} |
| 92 |
path: dist |
| 93 |
if-no-files-found: error |
| 94 |
- name: Zip up dist contents for release |
| 95 |
if: ${{ github.event_name == 'release'}} |
| 96 |
run: cd dist && zip -r ../release.zip * |
| 97 |
shell: msys2 {0} |
| 98 |
- name: Upload package to release |
| 99 |
if: ${{ github.event_name == 'release'}} |
| 100 |
uses: actions/upload-release-asset@v1 |
| 101 |
env: |
| 102 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 103 |
with: |
| 104 |
upload_url: ${{ github.event.release.upload_url }} |
| 105 |
asset_path: ./release.zip |
| 106 |
asset_name: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}-${{ env.package_suffix }}.zip |
| 107 |
asset_content_type: application/gzip |