-
Notifications
You must be signed in to change notification settings - Fork 1.2k
131 lines (118 loc) · 4.74 KB
/
windows.yml
File metadata and controls
131 lines (118 loc) · 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Windows CI
on:
pull_request:
env:
OPAMROOT: D:\opamroot
OPAMSOLVERTIMEOUT: 120
MSYS: winsymlinks:native
jobs:
analyse:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.result }}
steps:
- name: Checkout tree
uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v47
- name: Compute build matrix
id: matrix
uses: actions/github-script@v8
with:
script: |
let changed_files = '${{ steps.changed-files.outputs.all_changed_files }}';
let packages = [];
for (file of changed_files.split(' ')) {
console.log("Changed: " + file);
const package = file.match(/^packages\/[^/]+\/([^/]+)/);
if (package)
packages.push(package[1]);
}
const splits =
Array.from({ length: Math.ceil(packages.length / 75) },
(_, i) => packages.slice(i * 75, i * 75 + 75).join(' '));
return {build_env: ['cygwin', 'msys2'], packages: splits};
build:
name: "target/host: x86_64-w64-mingw32, build: ${{ matrix.build_env }}"
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.analyse.outputs.matrix) }}
if: ${{ join(fromJSON(needs.analyse.outputs.matrix).packages) != '' }}
runs-on: windows-latest
needs: analyse
steps:
- name: Checkout tree
uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Download install.ps1
run: |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
(New-Object System.Net.WebClient).DownloadFile("https://raw.githubusercontent.com/ocaml/opam/master/shell/install.ps1", ".\install.ps1")
- name: Restore opam cache
id: cache-opam
uses: actions/cache/restore@v5
with:
path: |
D:\opam\bin
D:\opamroot
key: ${{ runner.os }}-${{ matrix.build_env }}-opam-${{ hashFiles('install.ps1') }}
- name: Add MSYS2 to PATH and install prerequisites
if: matrix.build_env == 'msys2'
run: |
"C:\msys64" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
C:\msys64\usr\bin\pacman.exe --noconfirm -Syuu # Core update (in case any core packages are outdated)
C:\msys64\usr\bin\pacman.exe --noconfirm -Syuu m4 make mingw-w64-i686-gcc mingw-w64-x86_64-gcc rsync unzip
- name: Install opam
if: steps.cache-opam.outputs.cache-hit != 'true'
run: |
Invoke-Expression "& ./install.ps1 -OpamBinDir 'D:\opam\bin'"
- name: Add opam to PATH
run: |
D:\opam\bin\opam --version
"D:\opam\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Init opam
if: steps.cache-opam.outputs.cache-hit != 'true'
run: opam init --yes --no-setup ${{ matrix.build_env == 'msys2' && '--cygwin-local-install' || '' }} .
- name: Restrict testing to available compilers
if: steps.cache-opam.outputs.cache-hit != 'true'
# TODO Amend this lowerbound as older compiler packages are updated
run: opam switch set-invariant --formula "`"ocaml`" {>= `"4.13`"}"
- name: Save opam cache
if: steps.cache-opam.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: |
D:\opam\bin
D:\opamroot
key: ${{ steps.cache-opam.outputs.cache-primary-key }}
- name: Print version and configuration information
run: |
opam --version
opam exec -- ocaml -version
opam exec -- ocamlopt -config
opam var
- name: Install packages
run: |
$failed = $false
opam update
Foreach ($pkg in '${{ matrix.packages }}' -split ' ') {
Write-Host "::group::Testing `e[1;34m$pkg`e[0m"
opam install --color=always --confirm-level=unsafe-yes "$pkg"
Write-Host "::endgroup::"
switch ($LASTEXITCODE) {
0 { Write-Host "`e[1;32m$pkg installed successfully`e[0m."; Break }
5 { Write-Host "$pkg is not installable. `e[1;33mSkip`e[0m."; Break } # TODO: Remove when https://github.com/ocaml/opam/issues/6017 is fixed
20 { Write-Host "$pkg is not installable. `e[1;33mSkip`e[0m."; Break }
31 { Write-Host "`e[1;31m$pkg failed to build`e[0m."; $failed = $true; Break }
default { throw "Unexpected error $_" }
}
Write-Host
}
if ($failed) {
throw "One or more packages failed to build"
}
Exit