Describe 3.1.0 #108
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
push: | |
branches: | |
- "main" | |
jobs: | |
test-with-Cross-Platform-Action: | |
# macOS-12 is only GitHub CI runner that supports VirtualBox | |
# - the suggested 10.15 from https://stackoverflow.com/questions/66261101/using-vagrant-on-github-actions-ideally-incl-virtualbox | |
# is deprecated (https://github.com/actions/runner-images/issues/5583) | |
# - virtualbox added to macOS-12 in https://github.com/actions/runner-images/pull/5594 | |
runs-on: macos-12 | |
timeout-minutes: 90 | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- name: openbsd | |
version: '6.8' | |
- name: openbsd | |
version: '7.1' | |
# 6.9 gives ... | |
# <><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><> | |
# Error: Could not update repository "default": OpamDownload.Download_fail(_, "Download command failed: \"/usr/bin/ftp -o /tmp/opam-87092-8f3a45/index.tar.gz.part -U opam/2.1.2 -- https://opam.ocaml.org/index.tar.gz\" exited with code 1 \"TLS handshake failure: certificate verification failed: certificate has expired\"") | |
# because a syspatch has not been applied to the Cross-Platform-Action OpenBSD 6.9. | |
# See https://marc.info/?l=openbsd-misc&m=163303405028215&w=2 | |
# It would be nice to run syspatch at startup, but it complains of `syspatch: cannot apply patches while reorder_kernel is running` | |
# and `run_as_root rcctl disable library_aslr` (https://www.facebook.com/groups/2210554563/posts/10157117341779564/) is ineffective | |
continue-on-error: yes | |
- name: freebsd | |
version: '13.0' | |
# netbsd 9.2 does not start in VirtualBox as of 2022-06-05 | |
# - name: netbsd | |
# version: '9.2' | |
name: Cross-Platform-Action / ${{ matrix.os.name }}-${{ matrix.os.version }} | |
continue-on-error: ${{ matrix.os.continue-on-error == 'yes' }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Cache Opam root | |
uses: actions/cache@v3 | |
with: | |
path: _opamroot | |
key: ${{ matrix.os.name }}-${{ matrix.os.version }} | |
- name: Cache Opam binaries | |
uses: actions/cache@v3 | |
with: | |
path: _opambin | |
key: ${{ matrix.os.name }}-${{ matrix.os.version }} | |
- name: Test in VirtualBox | |
uses: cross-platform-actions/[email protected] | |
with: | |
operating_system: ${{ matrix.os.name }} | |
version: ${{ matrix.os.version }} | |
shell: bash | |
run: | | |
uname -a | |
usys=$(uname -s) | |
workspace_root=$(pwd) | |
export OPAMROOT="$workspace_root/_opamroot" | |
run_as_root() { | |
# doas on OpenBSD is not enabled (yet) | |
sudo "$@" | |
} | |
set -x | |
case "$usys" in | |
OpenBSD) | |
run_as_root pkg_add curl | |
run_as_root pkg_add gmake bzip2 | |
run_as_root pkg_add gpatch | |
# 6.8 | |
run_as_root pkg_add gtar-1.32p1 unzip-6.0p13 || true | |
# 6.9 and 7.1 | |
run_as_root pkg_add gtar-1.34 unzip-6.0p14 || true | |
run_as_root pkg_add git | |
;; | |
FreeBSD) | |
run_as_root pkg upgrade --yes pkg | |
run_as_root pkg install --yes curl | |
run_as_root pkg install --yes gmake bzip2 | |
run_as_root pkg install --yes patch gtar unzip | |
run_as_root pkg install --yes git | |
;; | |
esac | |
# bin/opam cache miss? | |
opamver="2.1.2" | |
opamsha256="de1e3efffd5942e0101ef83dcdead548cc65a93e13986aecb4a264a059457ede" | |
opamcachemiss=OFF | |
if [ ! -x "$workspace_root/_opambin/bin/opam" ]; then | |
opamcachemiss=ON | |
else | |
opamactualver=$("$workspace_root/_opambin/bin/opam" --version || true) | |
if [ ! "$opamactualver" = "$opamver" ]; then | |
opamcachemiss=ON | |
fi | |
fi | |
if [ "$opamcachemiss" = ON ]; then | |
# <needs> curl | |
curl -fsSL https://github.com/ocaml/opam/releases/download/$opamver/opam-full-$opamver.tar.gz > opam-full-$opamver.tar.gz | |
case "$usys" in | |
OpenBSD) | |
echo "SHA256 (opam-full-$opamver.tar.gz) = de1e3efffd5942e0101ef83dcdead548cc65a93e13986aecb4a264a059457ede" | sha256 -c | |
;; | |
FreeBSD) | |
sha256 -c 'de1e3efffd5942e0101ef83dcdead548cc65a93e13986aecb4a264a059457ede' opam-full-$opamver.tar.gz | |
;; | |
esac | |
tar xfz opam-full-$opamver.tar.gz | |
rm -f opam-full-$opamver.tar.gz | |
# <needs> gmake bzip2 | |
cd opam-full-$opamver | |
gmake cold CONFIGURE_ARGS="--prefix '$workspace_root/_opambin'" | |
gmake cold-install | |
cd "$workspace_root" | |
rm -rf opam-full-$opamver | |
fi | |
PATH="$workspace_root/_opambin/bin:$PATH" | |
# minimize cross-platform-actions/action post-step 'rsync' that | |
# transfers files out of virtual machine | |
install -d "$workspace_root/_build" | |
trap 'rm -rf $workspace_root/_build' EXIT | |
# <needs> gpatch gtar unzip | |
opam init --auto-setup | |
# <needs> git | |
opam install . --deps-only --with-test --yes | |
opam exec -- dune build --root "$workspace_root" --display=short | |
opam exec -- dune runtest --root "$workspace_root" --display=short | |
opam exec -- dune install --root "$workspace_root" | |
opam exec -- sh -c 'cat samples/show_abi.ml | ocaml' | |
test-with-setup-ocaml: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- windows-latest | |
- ubuntu-latest | |
- macos-latest | |
ocaml-compiler: | |
- "4.13.x" | |
runs-on: ${{ matrix.os }} | |
name: test-ocaml / ${{ matrix.os }}-${{ matrix.ocaml-compiler }} | |
# Windows on ocaml/setup-ocaml has been flaky ... let's not stop the Tests simply because it is flaky. | |
# Confer: ocaml/setup-ocaml issue no. 529 | |
# Also: | |
# -> installed opam-depext.1.1.5 | |
# #===ERRORwhile compiling depext-cygwinports.0.0.9===========================# | |
# #context 2.0.10 | win32/x86_64 | ocaml-variants.4.13.1+mingw64c | git+https://github.com/fdopen/opam-repository-mingw.git#opam2 | |
# #path D:/a/dkml-c-probe/dkml-c-probe/_opam/.opam-switch/build/depext-cygwinports.0.0.9 | |
# #command D:\cygwin\bin\make.exe -j2 all | |
# #exit-code 2 | |
# #env-file D:/.opam/log/depext-cygwinports-1604-d2d111.env | |
# #output-file D:/.opam/log/depext-cygwinports-1604-d2d111.out | |
# ### output ### | |
# # ocamlopt -g str.cmxa unix.cmxa config_file.mli config_file.ml run.mli run.ml cygwin.mli cygwin.ml -o cygwin-install.exe | |
# # x86_64-w64-mingw32-gcc -O2 -fno-strict-aliasing -fwrapv -mms-bitfields -s symlink.c -o pkg-config.exe | |
# # ** Fatal error: Cannot run cygpath -m "libmsvcrt" "libmsvcrt.lib" "libmsvcrt.dll.a" "libmsvcrt.a" "D:/a/dkml-c-probe/dkml-c-probe/_opam/lib/ocaml\libmsvcrt" "D:/a/dkml-c-probe/dkml-c-probe/_opam/lib/ocaml\libmsvcrt.lib" "D:/a/dkml-c-probe/dkml-c-probe/_opam/lib/ocaml\libmsvcrt.dll.a" "D:/a/dkml-c-probe/dkml-c-probe/_opam/lib/ocaml\libmsvcrt.a" "D:/a/dkml-c-probe/dkml-c-probe/_opam/lib/ocaml\flexdll\libmsvcrt" "D:/a/dkml-c-probe/dkml-c-probe/_opam/lib/ocaml\flexdll\libmsvcrt.lib" "D:/a/dkml-c-probe/dkml-c-probe/_opam/lib/ocaml\flexdll\libmsvcrt.dll.a" "D:/a/dkml-c-probe/dkml-c-probe/_opam/lib/ocaml\flexdll\libmsvcrt.a" "/usr/lib/gcc/x86_64-w64-mingw32/11/libmsvcrt" "/usr/lib/gcc/x86_64-w64-mingw32/11/libmsvcrt.lib" "/usr/lib/gcc/x86_64-w64-mingw32/11/libmsvcrt.dll.a" "/usr/lib/gcc/x86_64-w64-mingw32/11/libmsvcrt.a" "/usr/x86_64-w64-mingw32/lib/x86_64-w64-mingw32/11/libmsvcrt" "/usr/x86_64-w64-mingw32/lib/x86_64-w64-mingw32/11/libmsvcrt.lib" "/usr/x86_64-w64-mingw32/lib/x86_64-w64-mingw32/11/libmsvcrt.dll.a" "/usr/x86_64-w64-mingw32/lib/x86_64-w64-mingw32/11/libmsvcrt.a" "/usr/x86_64-w64-mingw32/lib/libmsvcrt" "/usr/x86_64-w64-mingw32/lib/libmsvcrt.lib" "/usr/x86_64-w64-mingw32/lib/libmsvcrt.dll.a" "/usr/x86_64-w64-mingw32/lib/libmsvcrt.a" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib/x86_64-w64-mingw32/11/libmsvcrt" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib/x86_64-w64-mingw32/11/libmsvcrt.lib" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib/x86_64-w64-mingw32/11/libmsvcrt.dll.a" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib/x86_64-w64-mingw32/11/libmsvcrt.a" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib/libmsvcrt" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib/libmsvcrt.lib" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib/libmsvcrt.dll.a" "/usr/x86_64-w64-mingw32/sys-root/mingw/lib/libmsvcrt.a" | |
# # File "caml_startup", line 1: | |
# # Error: Error during linking (exit code 2) | |
# # make: *** [Makefile:24: cygwin-install.exe] Error 2 | |
continue-on-error: ${{ startsWith(matrix.os, 'windows-') }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Hack Git CRLF for ocaml/setup-ocaml issue no. 529 | |
if: ${{ startsWith(matrix.os, 'windows-') }} | |
run: | | |
& "C:\Program Files\Git\bin\git.exe" config --system core.autocrlf input | |
- name: OCaml ${{ matrix.ocaml-compiler }} with Dune cache | |
uses: ocaml/setup-ocaml@v2 | |
if: ${{ !startsWith(matrix.os, 'windows-') }} | |
with: | |
ocaml-compiler: ${{ matrix.ocaml-compiler }} | |
dune-cache: true | |
- name: OCaml ${{ matrix.ocaml-compiler }} without Dune cache | |
uses: ocaml/setup-ocaml@v2 | |
if: ${{ startsWith(matrix.os, 'windows-') }} | |
with: | |
ocaml-compiler: ${{ matrix.ocaml-compiler }} | |
dune-cache: false | |
cache-prefix: v3 | |
- name: Install Opam dependencies | |
run: opam install . --deps-only --with-test --yes | |
- name: Build OCaml | |
run: opam exec -- dune build --display=short | |
- name: Test OCaml | |
run: opam exec -- dune runtest --display=short | |
- name: Install dkml-c-probe | |
run: opam exec -- dune install | |
- name: Display probe | |
run: opam exec -- sh -c 'cat samples/show_abi.ml | ocaml' | |
setup-dkml: | |
uses: "diskuv/dkml-workflows/.github/workflows/setup-dkml.yml@v0" | |
permissions: | |
# By explicitly setting at least one permission, all other permissions | |
# are set to none. setup-dkml.yml does not need access to your code! | |
# Verify in 'Set up job > GITHUB_TOKEN permissions'. | |
actions: none | |
with: | |
ocaml-compiler: 4.12.1 | |
test-with-setup-dkml: | |
needs: setup-dkml | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: windows-2019 | |
abi-pattern: win32-windows_x86 | |
dkml-host-abi: windows_x86 | |
opam-root: D:/.opam | |
default_shell: msys2 {0} | |
msys2_system: MINGW32 | |
msys2_packages: mingw-w64-i686-pkg-config | |
bits: "32" | |
- os: windows-2019 | |
abi-pattern: win32-windows_x86_64 | |
dkml-host-abi: windows_x86_64 | |
opam-root: D:/.opam | |
default_shell: msys2 {0} | |
msys2_system: CLANG64 | |
msys2_packages: mingw-w64-clang-x86_64-pkg-config | |
bits: "64" | |
- os: macos-latest | |
abi-pattern: macos-darwin_all | |
dkml-host-abi: darwin_x86_64 | |
crosscompile-toolchain: darwin_arm64 | |
crosscompile-dune-context: | | |
(context (default (targets native darwin_arm64))) | |
default_shell: sh | |
opam-root: /Users/runner/.opam | |
bits: "64" | |
- os: ubuntu-latest | |
abi-pattern: manylinux2014-linux_x86 | |
bits: "32" | |
default_shell: sh | |
dkml-host-abi: linux_x86 | |
opam-root: .ci/opamroot # local directory of $GITHUB_WORKSPACE so available to dockcross | |
- os: ubuntu-latest | |
abi-pattern: manylinux2014-linux_x86_64 | |
bits: "64" | |
default_shell: sh | |
dkml-host-abi: linux_x86_64 | |
opam-root: .ci/opamroot # local directory of $GITHUB_WORKSPACE so available to dockcross | |
runs-on: ${{ matrix.os }} | |
name: test-dkml / ${{ matrix.abi-pattern }} | |
defaults: | |
run: | |
shell: ${{ matrix.default_shell }} | |
env: | |
OPAMROOT: ${{ matrix.opam-root }} | |
COMPONENT: dkml-component-staging-opam${{ matrix.bits }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
with: | |
path: .ci/dist | |
- name: Install MSYS2 (Windows) | |
if: startsWith(matrix.dkml-host-abi, 'windows_') | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: ${{ matrix.msys2_system }} | |
update: true | |
install: >- | |
${{ matrix.msys2_packages }} | |
wget | |
make | |
rsync | |
diffutils | |
patch | |
unzip | |
git | |
tar | |
- name: Import build environments from setup-dkml | |
run: | | |
${{ needs.setup-dkml.outputs.import_func }} | |
import ${{ matrix.abi-pattern }} | |
- name: Cache Opam downloads by host | |
uses: actions/cache@v3 | |
with: | |
path: ${{ matrix.opam-root }}/download-cache | |
key: ${{ matrix.dkml-host-abi }} | |
- name: Dune-ify non-Dune Opam dependencies | |
run: | | |
opamrun repository add dune-universe git+https://github.com/dune-universe/opam-overlays.git#master | |
opamrun pin astring --no-action --yes -k version 0.8.5+dune | |
opamrun pin cmdliner --no-action --yes -k version 1.1.1+dune | |
opamrun pin fmt --no-action --yes -k version 0.8.9+dune | |
opamrun pin logs --no-action --yes -k version 0.7.0+dune2 | |
opamrun pin seq --no-action --yes -k version base+dune | |
- name: Cache Opam binaries | |
uses: actions/cache@v3 | |
with: | |
path: _opambin | |
key: ${{ matrix.dkml-host-abi }} | |
- name: Configure Opam for cross-compilation | |
if: matrix.crosscompile-dune-context | |
run: | | |
projectrundir=$(opamrun exec -- pwd) | |
# Create / cache opam-installer which is not always present from setup-dkml.yml | |
if [ ! -x _opambin/bin/opam-installer ] && [ ! -x _opambin/bin/opam-installer.exe ]; then | |
# Get the binary | |
opamrun install opam-installer --yes | |
opaminstaller="$(opamrun var opam-installer:bin)/opam-installer" | |
# Copy the binary | |
install -d _opambin/bin | |
if [ -x "$opaminstaller.exe" ]; then | |
install "$opaminstaller.exe" _opambin/bin/opam-installer.exe | |
else | |
install "$opaminstaller" _opambin/bin/opam-installer | |
fi | |
# Remove all packages which just got installed (is there any easy way to do that?); | |
# technically we only need to remove those that should cross-compiled later. | |
# But for consistency between cache hit and cache miss, better to remove everything | |
# installed during `opam install opam-installer`. | |
opamrun remove cmdliner cppo ocamlgraph opam-file-format re seq stdlib-shims --yes | |
opamrun list | |
fi | |
opaminstaller=$projectrundir/_opambin/bin/opam-installer | |
# Install ocamlfind since without it opam-installer can give errors trying | |
# to find the `ocamlfind` executable | |
opamrun install ocamlfind --yes | |
opamrun remove cmdliner seq --yes | |
# Inject [dune-workspace] into almost all Opam packages | |
dunecontext='${{ matrix.crosscompile-dune-context }}' | |
option_args=$(printf 'pre-build-commands=["%s" "%s" "%s" "%s"]' \ | |
"$projectrundir/samples/crosscompiling-workspace-generator.sh" \ | |
'%{name}%' \ | |
'%{_:build}%/dune-workspace' \ | |
"$dunecontext" \ | |
) | |
opamrun option "$option_args" | |
# Add [dune-workspace] to dkml-c-probe (this package) | |
"$projectrundir/samples/crosscompiling-workspace-generator.sh" \ | |
"dkml-c-probe" \ | |
"dune-workspace" \ | |
"$dunecontext" | |
# Each Opam package must install its cross-compiled libraries into Opam switch | |
option_args=$(printf 'post-install-commands=["%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s"]' \ | |
"$projectrundir/samples/crosscompiling-opam-installer.sh" \ | |
"$opaminstaller" \ | |
"%{name}%-${{ matrix.crosscompile-toolchain }}.install" \ | |
"%{name}%" \ | |
"%{lib}%" \ | |
"%{man}%" \ | |
"%{prefix}%" \ | |
"%{stublibs}%" \ | |
"%{toplevel}%" \ | |
) | |
opamrun option "$option_args" | |
# Diagnostics: Show the options | |
opamrun option | |
- name: Install Opam dependencies | |
run: opamrun install . --deps-only --with-test --yes | |
- name: Build OCaml | |
run: opamrun exec -- dune build --display=short | |
- name: Test OCaml | |
run: opamrun exec -- dune runtest --display=short | |
- name: Install dkml-c-probe | |
run: opamrun install . --yes | |
- name: Display probe of default toolchain | |
run: opamrun exec -- sh -c 'cat samples/show_abi.ml | ocaml' | |
- name: Display source for cross-compiled toolchain | |
if: matrix.crosscompile-toolchain | |
run: | | |
prefix=$(opamrun var prefix) | |
opamrun exec -- cat "$prefix/${{ matrix.crosscompile-toolchain }}-sysroot/lib/dkml-c-probe/c_abi.ml" |