···
5
+
OPAMROOT: D:\opamroot
12
+
runs-on: ${{ matrix.os }}
14
+
- name: Checkout tree
15
+
uses: actions/checkout@v4
17
+
- name: Restore opam cache
19
+
uses: actions/cache/restore@v4
24
+
key: ${{ runner.os }}-opam
26
+
- name: Install opam
27
+
if: steps.cache-opam.outputs.cache-hit != 'true'
29
+
Invoke-Expression "& { $(Invoke-RestMethod https://raw.githubusercontent.com/kit-ty-kate/opam/windows-installer.debug/shell/install.ps1) } -OpamBinDir 'D:\opam\bin' -NoSetPath -NoAdmin"
32
+
if: steps.cache-opam.outputs.cache-hit != 'true'
33
+
run: opam init --yes --no-setup .
35
+
- name: Save opam cache
36
+
if: steps.cache-opam.outputs.cache-hit != 'true'
37
+
uses: actions/cache/save@v4
42
+
key: ${{ steps.cache-opam.outputs.cache-primary-key }}
44
+
- name: Add opam to PATH
46
+
"D:\opam\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
48
+
- name: Get changed files
50
+
uses: tj-actions/changed-files@v44
52
+
- name: List all changed packages
53
+
id: changed-packages
55
+
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
58
+
Foreach ($file in ($env:ALL_CHANGED_FILES).Split(" ")) {
59
+
switch -Regex ($file) {
60
+
'^packages\\[^\\]*\\([^\\]*)\\.*' { $output += "$($matches[1])"; Break }
61
+
default { Write-Host "$file skipped"; Break }
64
+
$outputJson = $output | ConvertTo-Json
65
+
"data<<@@@" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
66
+
$outputJson | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
67
+
"@@@" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
69
+
- name: Install packages
71
+
ALL_CHANGED_PACKAGES: ${{ steps.changed-packages.outputs.data }}
73
+
$pkgs = $env:ALL_CHANGED_PACKAGES | ConvertFrom-Json
76
+
Foreach ($pkg in $pkgs) {
77
+
opam install --confirm-level=unsafe-yes "$pkg"
78
+
switch ($LASTEXITCODE) {
80
+
20 { Write-Host "$pkg is not installable. Skip."; Break }
81
+
31 { Write-Host "$pkg failed to build."; $failed = $true; Break }
82
+
default { throw "Unexpected error $_" }
86
+
throw "build failed"