|
9 | 9 | OPAMSOLVERTIMEOUT: 120 |
10 | 10 | MSYS: winsymlinks:native |
11 | 11 | 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 | + |
12 | 39 | build: |
13 | 40 | name: "target/host: x86_64-w64-mingw32, build: ${{ matrix.build_env }}" |
14 | 41 | strategy: |
15 | 42 | fail-fast: false |
16 | | - matrix: |
17 | | - build_env: |
18 | | - - cygwin |
19 | | - - msys2 |
| 43 | + matrix: ${{ fromJSON(needs.analyse.outputs.matrix) }} |
20 | 44 | runs-on: windows-latest |
| 45 | + needs: analyse |
21 | 46 | steps: |
22 | 47 | - name: Checkout tree |
23 | 48 | uses: actions/checkout@v6 |
@@ -80,38 +105,14 @@ jobs: |
80 | 105 | opam exec -- ocamlopt -config |
81 | 106 | opam var |
82 | 107 |
|
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 | | -
|
106 | 108 | - name: Install packages |
107 | 109 | env: |
108 | 110 | ALL_CHANGED_PACKAGES: ${{ steps.changed-packages.outputs.data }} |
109 | 111 | if: github.event_name != 'push' |
110 | 112 | run: | |
111 | | - $pkgs = $env:ALL_CHANGED_PACKAGES | ConvertFrom-Json |
112 | 113 | $failed = $false |
113 | 114 | opam update |
114 | | - Foreach ($pkg in $pkgs) { |
| 115 | + Foreach ($pkg in '${{ matrix.packages }}' -split ' ') { |
115 | 116 | Write-Host "::group::Testing `e[1;34m$pkg`e[0m" |
116 | 117 | opam install --color=always --confirm-level=unsafe-yes "$pkg" |
117 | 118 | Write-Host "::endgroup::" |
|
0 commit comments