Skip to content

Commit 7b9132b

Browse files
committed
Does this work?
1 parent 5793527 commit 7b9132b

File tree

1 file changed

+64
-28
lines changed

1 file changed

+64
-28
lines changed

.github/workflows/main.yml

Lines changed: 64 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,83 @@
1-
name: build
1+
name: Windows CI
22

33
on:
44
- push
55
- pull_request
66

7+
env:
8+
OPAMROOT: D:\opamroot
9+
OPAMSOLVERTIMEOUT: 120
10+
MSYS: winsymlinks:native
711
jobs:
8-
build-and-test:
9-
name: build
10-
12+
build:
1113
strategy:
1214
fail-fast: false
1315
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
2221
runs-on: ${{ matrix.os }}
23-
2422
steps:
25-
- name: Checkout code
26-
uses: actions/checkout@v2
23+
- name: Checkout tree
24+
uses: actions/checkout@v6
2725
with:
28-
submodules: true
26+
fetch-depth: 2
2927

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")
3332
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
3636
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
3848
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'"
4053
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 }}
4276

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
4582
46-
- run: opam install .
47-
if: matrix.os != 'windows-latest'
83+
- run: opam install . -y

0 commit comments

Comments
 (0)