From 3ea9efe79a3dbf0f4c397bf73b3a6bc9c0ddf210 Mon Sep 17 00:00:00 2001 From: Kate Date: Wed, 5 Jun 2024 18:06:58 +0100 Subject: [PATCH 1/2] Add a basic Github Action CI for Windows --- .github/workflows/windows.yml | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 00000000000..3a259296698 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,72 @@ +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: Cache opam + id: cache-opam + uses: actions/cache@v4 + with: + path: | + C:\Program Files\opam\bin + C:\Users\runneradmin\AppData\Local\opam + key: ${{ runner.os }}-opam + + - name: Install opam + if: steps.cache-opam.outputs.cache-hit != 'true' + 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: Init opam + if: steps.cache-opam.outputs.cache-hit != 'true' + run: opam init -yn . + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v44 + + - 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) { + opam install --confirm-level=unsafe-yes "$pkg" + switch ($LASTEXITCODE) { + 0 { Break } + 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" + } From a857151c2bac49471a47e5ac80d8ae6ed81647ec Mon Sep 17 00:00:00 2001 From: Kate Date: Wed, 12 Jun 2024 13:50:03 +0100 Subject: [PATCH 2/2] Move everything to the D: disk as it is faster storage --- .github/workflows/windows.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 3a259296698..957eac9ae1e 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,6 +1,8 @@ name: Windows CI on: pull_request: +env: + OPAMROOT: D:\opamroot jobs: build: strategy: @@ -17,15 +19,15 @@ jobs: uses: actions/cache@v4 with: path: | - C:\Program Files\opam\bin - C:\Users\runneradmin\AppData\Local\opam + D:\opam\bin + D:\opamroot key: ${{ runner.os }}-opam - name: Install opam if: steps.cache-opam.outputs.cache-hit != 'true' 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 + Invoke-Expression "& { $(Invoke-RestMethod https://raw.githubusercontent.com/kit-ty-kate/opam/windows-installer.debug/shell/install.ps1) } -OpamBinDir 'D:\opam\bin' -NoSetPath -NoAdmin" + "D:\opam\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: Init opam if: steps.cache-opam.outputs.cache-hit != 'true'