Skip to content

Commit 4e1b3d8

Browse files
committed
Split workflow
1 parent fee00f2 commit 4e1b3d8

File tree

1 file changed

+33
-29
lines changed

1 file changed

+33
-29
lines changed

.github/workflows/windows.yml

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,43 @@ env:
99
OPAMSOLVERTIMEOUT: 120
1010
MSYS: winsymlinks:native
1111
jobs:
12+
analyse:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
matrix: ${{ steps.matrix.outputs.result }}
16+
steps:
17+
- name: Checkout tree
18+
uses: actions/checkout@v6
19+
with:
20+
fetch-depth: 2
21+
22+
- name: Get changed files
23+
id: changed-files
24+
if: github.event_name != 'push'
25+
uses: tj-actions/changed-files@v47
26+
27+
- name: Compute build matrix
28+
id: matrix
29+
uses: actions/github-script@v7
30+
with:
31+
script: |
32+
let changed_files = '${{ steps.changed-files.outputs.all_changed_files }}';
33+
let packages = [];
34+
for (file of changed_files.split(' ')) {
35+
console.log("Changed: " + file);
36+
const package = file.match(/^packages\/[^/]+\/([^/]+)/);
37+
if (package)
38+
packages.push(package[1]);
39+
}
40+
return {build_env: ['cygwin', 'msys2']};
41+
1242
build:
1343
name: "target/host: x86_64-w64-mingw32, build: ${{ matrix.build_env }}"
1444
strategy:
1545
fail-fast: false
16-
matrix:
17-
build_env:
18-
- cygwin
19-
- msys2
46+
matrix: ${{ fromJSON(needs.analyse.outputs.matrix) }}
2047
runs-on: windows-latest
48+
needs: analyse
2149
steps:
2250
- name: Checkout tree
2351
uses: actions/checkout@v6
@@ -80,38 +108,14 @@ jobs:
80108
opam exec -- ocamlopt -config
81109
opam var
82110
83-
- name: Get changed files
84-
id: changed-files
85-
if: github.event_name != 'push'
86-
uses: tj-actions/changed-files@v47
87-
88-
- name: List all changed packages
89-
id: changed-packages
90-
if: github.event_name != 'push'
91-
env:
92-
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
93-
run: |
94-
$output = @()
95-
Foreach ($file in ($env:ALL_CHANGED_FILES).Split(" ")) {
96-
switch -Regex ($file) {
97-
'^packages\\[^\\]*\\([^\\]*)\\.*' { $output += "$($matches[1])"; Break }
98-
default { Write-Host "$file skipped"; Break }
99-
}
100-
}
101-
$outputJson = $output | ConvertTo-Json
102-
"data<<@@@" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
103-
$outputJson | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
104-
"@@@" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
105-
106111
- name: Install packages
107112
env:
108113
ALL_CHANGED_PACKAGES: ${{ steps.changed-packages.outputs.data }}
109114
if: github.event_name != 'push'
110115
run: |
111-
$pkgs = $env:ALL_CHANGED_PACKAGES | ConvertFrom-Json
112116
$failed = $false
113117
opam update
114-
Foreach ($pkg in $pkgs) {
118+
Foreach ($pkg in '${{ matrix.packages }}' -split ' ') {
115119
Write-Host "::group::Testing `e[1;34m$pkg`e[0m"
116120
opam install --color=always --confirm-level=unsafe-yes "$pkg"
117121
Write-Host "::endgroup::"

0 commit comments

Comments
 (0)