forked from ocaml/opam-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (67 loc) · 2.65 KB
/
windows.yml
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
name: Windows CI
on:
pull_request:
jobs:
build:
strategy:
matrix:
os:
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout tree
uses: actions/checkout@v4
- name: Install opam
run: |
Invoke-Expression "& { $(Invoke-RestMethod https://raw.githubusercontent.com/kit-ty-kate/opam/windows-installer.debug/shell/install.ps1) } -OpamBinDir 'C:\Program Files\opam\bin' -NoSetPath -NoAdmin"
"C:\Program Files\opam\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# - name: Install opam
# run: |
# curl -LO https://github.com/user-attachments/files/15792432/archive.zip
# unzip archive.zip
# New-Item -Force -Path "C:\Program Files\opam\bin" -Type Directory
# Move-Item -Force -Path "opam-tmp.exe" -Destination "C:\Program Files\opam\bin\opam.exe"
# "C:\Program Files\opam\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Init opam
run: opam init -yn .
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
#with:
# since_last_remote_commit: true
- name: List all changed packages
id: changed-packages
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
$output = @()
Foreach ($file in ($env:ALL_CHANGED_FILES).Split(" ")) {
switch -Regex ($file) {
'^packages\\[^\\]*\\([^\\]*)\\.*' { $output += "$($matches[1])"; Break }
default { Write-Host "$file skipped"; Break }
}
}
$outputJson = $output | ConvertTo-Json
"data<<@@@" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
$outputJson | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
"@@@" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Install packages
env:
ALL_CHANGED_PACKAGES: ${{ steps.changed-packages.outputs.data }}
run: |
$pkgs = $env:ALL_CHANGED_PACKAGES | ConvertFrom-Json
$failed = $false
Foreach ($pkg in $pkgs) {
try {
opam install --confirm-level=unsafe-yes "$pkg"
} catch {
switch ($?) {
20 { Write-Host "$pkg is not installable. Skip."; Break }
31 { Write-Host "$pkg failed to build."; $failed = $true; Break }
default { throw "Unexpected error $_" }
}
}
}
if ($failed) {
throw "build failed"
}