this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #26069 from kit-ty-kate/windows-ci

Add a basic Github Action CI for Windows

authored by

Raphaël Proust and committed by
GitHub
6646d5bd d2544ddc

+87
+87
.github/workflows/windows.yml
··· 1 + name: Windows CI 2 + on: 3 + pull_request: 4 + env: 5 + OPAMROOT: D:\opamroot 6 + jobs: 7 + build: 8 + strategy: 9 + matrix: 10 + os: 11 + - windows-latest 12 + runs-on: ${{ matrix.os }} 13 + steps: 14 + - name: Checkout tree 15 + uses: actions/checkout@v4 16 + 17 + - name: Restore opam cache 18 + id: cache-opam 19 + uses: actions/cache/restore@v4 20 + with: 21 + path: | 22 + D:\opam\bin 23 + D:\opamroot 24 + key: ${{ runner.os }}-opam 25 + 26 + - name: Install opam 27 + if: steps.cache-opam.outputs.cache-hit != 'true' 28 + run: | 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" 30 + 31 + - name: Init opam 32 + if: steps.cache-opam.outputs.cache-hit != 'true' 33 + run: opam init --yes --no-setup . 34 + 35 + - name: Save opam cache 36 + if: steps.cache-opam.outputs.cache-hit != 'true' 37 + uses: actions/cache/save@v4 38 + with: 39 + path: | 40 + D:\opam\bin 41 + D:\opamroot 42 + key: ${{ steps.cache-opam.outputs.cache-primary-key }} 43 + 44 + - name: Add opam to PATH 45 + run: | 46 + "D:\opam\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append 47 + 48 + - name: Get changed files 49 + id: changed-files 50 + uses: tj-actions/changed-files@v44 51 + 52 + - name: List all changed packages 53 + id: changed-packages 54 + env: 55 + ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} 56 + run: | 57 + $output = @() 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 } 62 + } 63 + } 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 68 + 69 + - name: Install packages 70 + env: 71 + ALL_CHANGED_PACKAGES: ${{ steps.changed-packages.outputs.data }} 72 + run: | 73 + $pkgs = $env:ALL_CHANGED_PACKAGES | ConvertFrom-Json 74 + $failed = $false 75 + opam update 76 + Foreach ($pkg in $pkgs) { 77 + opam install --confirm-level=unsafe-yes "$pkg" 78 + switch ($LASTEXITCODE) { 79 + 0 { Break } 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 $_" } 83 + } 84 + } 85 + if ($failed) { 86 + throw "build failed" 87 + }