Skip to content

Commit d4a121e

Browse files
committed
Split workflow
1 parent fee00f2 commit d4a121e

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

.github/workflows/windows.yml

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,40 @@ 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+
}
37+
return {build_env: ['cygwin', 'msys2'], packages: [packages.join(' ')]};
38+
1239
build:
1340
name: "target/host: x86_64-w64-mingw32, build: ${{ matrix.build_env }}"
1441
strategy:
1542
fail-fast: false
16-
matrix:
17-
build_env:
18-
- cygwin
19-
- msys2
43+
matrix: ${{ fromJSON(needs.analyse.outputs.matrix) }}
2044
runs-on: windows-latest
45+
needs: analyse
2146
steps:
2247
- name: Checkout tree
2348
uses: actions/checkout@v6
@@ -80,38 +105,14 @@ jobs:
80105
opam exec -- ocamlopt -config
81106
opam var
82107
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-
106108
- name: Install packages
107109
env:
108110
ALL_CHANGED_PACKAGES: ${{ steps.changed-packages.outputs.data }}
109111
if: github.event_name != 'push'
110112
run: |
111-
$pkgs = $env:ALL_CHANGED_PACKAGES | ConvertFrom-Json
112113
$failed = $false
113114
opam update
114-
Foreach ($pkg in $pkgs) {
115+
Foreach ($pkg in '${{ matrix.packages }}' -split ' ') {
115116
Write-Host "::group::Testing `e[1;34m$pkg`e[0m"
116117
opam install --color=always --confirm-level=unsafe-yes "$pkg"
117118
Write-Host "::endgroup::"

0 commit comments

Comments
 (0)