|
1 | | -name: build |
| 1 | +name: Windows CI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | - push |
5 | 5 | - pull_request |
6 | 6 |
|
| 7 | +env: |
| 8 | + OPAMROOT: D:\opamroot |
| 9 | + OPAMSOLVERTIMEOUT: 120 |
| 10 | + MSYS: winsymlinks:native |
7 | 11 | jobs: |
8 | | - build-and-test: |
9 | | - name: build |
10 | | - |
| 12 | + build: |
11 | 13 | strategy: |
12 | 14 | fail-fast: false |
13 | 15 | matrix: |
14 | | - include: |
15 | | - - { ocaml-compiler: 5.0.0, os: ubuntu-latest } |
16 | | - - { ocaml-compiler: 5.0.0, os: macos-latest } |
17 | | - - { ocaml-compiler: 4.14.0, os: ubuntu-latest } |
18 | | - - { ocaml-compiler: 4.14.0, os: windows-latest } |
19 | | - - { ocaml-compiler: 4.14.0, os: macos-latest } |
20 | | - - { ocaml-compiler: 4.08.0, os: ubuntu-latest } |
21 | | - |
| 16 | + os: |
| 17 | + - windows-latest |
| 18 | + windows_env: |
| 19 | + - cygwin |
| 20 | + - msys2 |
22 | 21 | runs-on: ${{ matrix.os }} |
23 | | - |
24 | 22 | steps: |
25 | | - - name: Checkout code |
26 | | - uses: actions/checkout@v2 |
| 23 | + - name: Checkout tree |
| 24 | + uses: actions/checkout@v6 |
27 | 25 | with: |
28 | | - submodules: true |
| 26 | + fetch-depth: 2 |
29 | 27 |
|
30 | | - - name: Re-synchronize the package index files on Ubuntu |
31 | | - if: matrix.os == 'ubuntu-latest' |
32 | | - run: sudo apt-get update |
| 28 | + - name: Download install.ps1 |
| 29 | + run: | |
| 30 | + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 |
| 31 | + (New-Object System.Net.WebClient).DownloadFile("https://raw.githubusercontent.com/ocaml/opam/master/shell/install.ps1", ".\install.ps1") |
33 | 32 |
|
34 | | - - name: Use OCaml ${{ matrix.ocaml-compiler }} |
35 | | - uses: ocaml/setup-ocaml@v3 |
| 33 | + - name: Restore opam cache |
| 34 | + id: cache-opam |
| 35 | + uses: actions/cache/restore@v4 |
36 | 36 | with: |
37 | | - ocaml-compiler: ${{ matrix.ocaml-compiler }} |
| 37 | + path: | |
| 38 | + D:\opam\bin |
| 39 | + D:\opamroot |
| 40 | + key: ${{ runner.os }}-${{ matrix.windows_env }}-opam-${{ hashFiles('install.ps1') }} |
| 41 | + |
| 42 | + - name: Add MSys2 to PATH and install prerequisites |
| 43 | + if: matrix.windows_env == 'msys2' |
| 44 | + run: | |
| 45 | + "C:\msys64" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append |
| 46 | + C:\msys64\usr\bin\pacman.exe --noconfirm -Syuu # Core update (in case any core packages are outdated) |
| 47 | + C:\msys64\usr\bin\pacman.exe --noconfirm -Syuu m4 make mingw-w64-i686-gcc mingw-w64-x86_64-gcc rsync unzip |
38 | 48 |
|
39 | | - - run: opam pin -n . |
| 49 | + - name: Install opam |
| 50 | + if: steps.cache-opam.outputs.cache-hit != 'true' |
| 51 | + run: | |
| 52 | + Invoke-Expression "& ./install.ps1 -OpamBinDir 'D:\opam\bin'" |
40 | 53 |
|
41 | | - - run: opam install . --deps-only |
| 54 | + - name: Add opam to PATH |
| 55 | + run: | |
| 56 | + D:\opam\bin\opam --version |
| 57 | + "D:\opam\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append |
| 58 | +
|
| 59 | + - name: Init opam |
| 60 | + if: steps.cache-opam.outputs.cache-hit != 'true' |
| 61 | + run: opam init --yes --no-setup ${{ matrix.windows_env == 'msys2' && '--cygwin-local-install' || '' }} . |
| 62 | + |
| 63 | + - name: Restrict testing to available compilers |
| 64 | + if: steps.cache-opam.outputs.cache-hit != 'true' |
| 65 | + # TODO Amend this lowerbound as older compiler packages are updated |
| 66 | + run: opam switch set-invariant --formula "`"ocaml`" {>= `"4.13`"}" |
| 67 | + |
| 68 | + - name: Save opam cache |
| 69 | + if: steps.cache-opam.outputs.cache-hit != 'true' |
| 70 | + uses: actions/cache/save@v4 |
| 71 | + with: |
| 72 | + path: | |
| 73 | + D:\opam\bin |
| 74 | + D:\opamroot |
| 75 | + key: ${{ steps.cache-opam.outputs.cache-primary-key }} |
42 | 76 |
|
43 | | - - run: opam exec -- dune build |
44 | | - if: matrix.ocaml-compiler != '4.08.0' |
| 77 | + - name: Print version information |
| 78 | + run: | |
| 79 | + opam --version |
| 80 | + opam exec -- ocaml -version |
| 81 | + opam var |
45 | 82 |
|
46 | | - - run: opam install . |
47 | | - if: matrix.os != 'windows-latest' |
| 83 | + - run: opam install . -y |
0 commit comments