Skip to content

Commit

Permalink
[ci] Simplify windows ci with native opam (#11879)
Browse files Browse the repository at this point in the history
* [ci] Remove windows 32 ocaml install script

* [ci] Remove installation of perl libraries

These were only needed for camlp5 which has now been removed

* [ci] Remove unneeded PATH step on windows

This is handled now by the mingw-w64-shims package:
https://github.com/dra27/mingw-w64-shims/blob/3c4a82700d9b03443ad6f2927449f7a8f25a77cf/mingw-w64-shims.opam#L8

* [ci] Use cygwin tar

* [ci] Update setup-ocaml

* [ci] Update to latest ocaml 4 release on windows

4.08.1 was not supported natively on windows

* [ci] Add required PATH entries for installing luv

See: aantron/luv#162

* [ci] Run windows make commands natively

With native opam, we no longer need to build from the cygwin bash.

This means we can rely on native git.
  • Loading branch information
tobil4sk authored Dec 12, 2024
1 parent 30cea1a commit 4cf4555
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 124 deletions.
60 changes: 18 additions & 42 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ jobs:
with:
submodules: recursive

- name: Use GNU Tar from msys
run: |
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
rm C:\msys64\usr\bin\bash.exe
- name: choco install nsis
uses: nick-invision/retry@v3
with:
Expand Down Expand Up @@ -51,44 +46,30 @@ jobs:
run: neko -version 2>&1

- name: Setup ocaml
uses: ocaml/setup-ocaml@v2
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: 4.08.1
opam-repositories: |
opam-repository-mingw: https://github.com/ocaml-opam/opam-repository-mingw.git#sunset
default: https://github.com/ocaml/opam-repository.git
ocaml-compiler: 4
opam-local-packages: |
haxe.opam
- name: Install dependencies
shell: pwsh
env:
MBEDTLS_VERSION: 2.16.3
run: |
Set-PSDebug -Trace 1
curl.exe -fsSL -o "libmbedtls.tar.xz" --retry 3 https://github.com/Simn/mingw64-mbedtls/releases/download/2.16.3/mingw64-$($env:MINGW_ARCH)-mbedtls-2.16.3-1.tar.xz
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'curl -L https://cpanmin.us | perl - App::cpanminus')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cpanm IPC::System::Simple module')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cpanm String::ShellQuote')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'echo "$OLDPWD"')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && tar -C / -xvf libmbedtls.tar.xz')
curl.exe -fsSL -o "libmbedtls.tar.xz" --retry 3 `
https://github.com/Simn/mingw64-mbedtls/releases/download/${{ env.MBEDTLS_VERSION }}/mingw64-${{ env.MINGW_ARCH }}-mbedtls-${{ env.MBEDTLS_VERSION }}-1.tar.xz
${{ env.CYG_ROOT }}\bin\tar.exe -C ${{ env.CYG_ROOT }} -xvf libmbedtls.tar.xz
- name: Install OCaml libraries
shell: pwsh
run: |
Set-PSDebug -Trace 1
# see: https://github.com/aantron/luv/issues/162
$env:PATH="${env:CYG_ROOT}\bin;${env:CYG_ROOT}\usr\x86_64-w64-mingw32\bin;${env:PATH}"
opam install haxe --deps-only
opam list
- name: Expose mingw dll files
shell: pwsh
run: Write-Host "::add-path::${env:CYG_ROOT}/usr/$($env:MINGW_ARCH)-w64-mingw32/sys-root/mingw/bin"

# required to be able to retrieve the revision
- name: Mark directory as safe
shell: pwsh
run: |
Set-PSDebug -Trace 1
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'git config --global --add safe.directory "$OLDPWD"')
- name: Set ADD_REVISION=1 for non-release
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
shell: pwsh
Expand All @@ -98,20 +79,15 @@ jobs:
shell: pwsh
run: |
Set-PSDebug -Trace 1
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -s -f Makefile.win -j`nproc` haxe 2>&1')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -s -f Makefile.win haxelib 2>&1')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -f Makefile.win echo_package_files package_bin package_installer_win package_choco 2>&1')
dir out
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && cygcheck ./haxe.exe')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && cygcheck ./haxelib.exe')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && ls ./out')
- name: Check artifact
shell: bash
run: |
ls out
# Output should contain binaries zip, installer zip and nupkg
[ $(ls -1 out | wc -l) -eq "3" ]
# stop after any command returns an error
$PSNativeCommandUseErrorActionPreference = $true
$ErrorActionPreference = 'Stop'
opam exec -- make -s -f Makefile.win -j"$env:NUMBER_OF_PROCESSORS" haxe
opam exec -- make -s -f Makefile.win haxelib
opam exec -- make -f Makefile.win echo_package_files package_bin package_installer_win package_choco
cygcheck ./haxe.exe
cygcheck ./haxelib.exe
ls ./out
- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
34 changes: 9 additions & 25 deletions extra/github-actions/build-windows.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
- name: Expose mingw dll files
shell: pwsh
run: Write-Host "::add-path::${env:CYG_ROOT}/usr/$($env:MINGW_ARCH)-w64-mingw32/sys-root/mingw/bin"

# required to be able to retrieve the revision
- name: Mark directory as safe
shell: pwsh
run: |
Set-PSDebug -Trace 1
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'git config --global --add safe.directory "$OLDPWD"')
- name: Set ADD_REVISION=1 for non-release
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
shell: pwsh
Expand All @@ -18,20 +7,15 @@
shell: pwsh
run: |
Set-PSDebug -Trace 1
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -s -f Makefile.win -j`nproc` haxe 2>&1')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -s -f Makefile.win haxelib 2>&1')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -f Makefile.win echo_package_files package_bin package_installer_win package_choco 2>&1')
dir out
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && cygcheck ./haxe.exe')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && cygcheck ./haxelib.exe')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && ls ./out')
- name: Check artifact
shell: bash
run: |
ls out
# Output should contain binaries zip, installer zip and nupkg
[ $(ls -1 out | wc -l) -eq "3" ]
# stop after any command returns an error
$PSNativeCommandUseErrorActionPreference = $true
$ErrorActionPreference = 'Stop'
opam exec -- make -s -f Makefile.win -j"$env:NUMBER_OF_PROCESSORS" haxe
opam exec -- make -s -f Makefile.win haxelib
opam exec -- make -f Makefile.win echo_package_files package_bin package_installer_win package_choco
cygcheck ./haxe.exe
cygcheck ./haxelib.exe
ls ./out
- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
2 changes: 2 additions & 0 deletions extra/github-actions/install-ocaml-libs-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
shell: pwsh
run: |
Set-PSDebug -Trace 1
# see: https://github.com/aantron/luv/issues/162
$env:PATH="${env:CYG_ROOT}\bin;${env:CYG_ROOT}\usr\x86_64-w64-mingw32\bin;${env:PATH}"
opam install haxe --deps-only
opam list
38 changes: 7 additions & 31 deletions extra/github-actions/install-ocaml-windows.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,15 @@
- name: Setup ocaml
id: ocaml
continue-on-error: true
uses: kLabz/setup-ocaml@win32
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: 4.08.1
opam-depext: false
opam-repositories: |
opam-repository-mingw: https://github.com/ocaml-opam/opam-repository-mingw.git#sunset
default: https://github.com/ocaml/opam-repository.git
ocaml-compiler: 4
opam-local-packages: |
haxe.opam
cache-prefix: w32-v1

# TODO make it work on first try
# (when cygwin cache doesn't exist, ocaml install fails with a curl error)
- name: Setup ocaml (second chance)
if: steps.ocaml.outcome == 'failure'
uses: kLabz/setup-ocaml@win32
with:
ocaml-compiler: 4.08.1
opam-depext: false
opam-repositories: |
opam-repository-mingw: https://github.com/ocaml-opam/opam-repository-mingw.git#sunset
default: https://github.com/ocaml/opam-repository.git
opam-local-packages: |
haxe.opam
cache-prefix: w32-v1
- name: Install dependencies
shell: pwsh
env:
MBEDTLS_VERSION: 2.16.3
run: |
Set-PSDebug -Trace 1
curl.exe -fsSL -o "libmbedtls.tar.xz" --retry 3 https://github.com/Simn/mingw64-mbedtls/releases/download/2.16.3/mingw64-$($env:MINGW_ARCH)-mbedtls-2.16.3-1.tar.xz
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'curl -L https://cpanmin.us | perl - App::cpanminus')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cpanm IPC::System::Simple module')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cpanm String::ShellQuote')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'echo "$OLDPWD"')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && tar -C / -xvf libmbedtls.tar.xz')
curl.exe -fsSL -o "libmbedtls.tar.xz" --retry 3 `
https://github.com/Simn/mingw64-mbedtls/releases/download/${{ env.MBEDTLS_VERSION }}/mingw64-${{ env.MINGW_ARCH }}-mbedtls-${{ env.MBEDTLS_VERSION }}-1.tar.xz
${{ env.CYG_ROOT }}\bin\tar.exe -C ${{ env.CYG_ROOT }} -xvf libmbedtls.tar.xz
20 changes: 0 additions & 20 deletions extra/github-actions/install-ocaml-windows64.yml

This file was deleted.

7 changes: 1 addition & 6 deletions extra/github-actions/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@ jobs:
with:
submodules: recursive

- name: Use GNU Tar from msys
run: |
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
rm C:\msys64\usr\bin\bash.exe
@import install-nsis.yml
@import install-neko-windows.yml
@import install-ocaml-windows64.yml
@import install-ocaml-windows.yml
@import install-ocaml-libs-windows.yml
@import build-windows.yml

Expand Down

0 comments on commit 4cf4555

Please sign in to comment.