From b0ae523b03287eee58bc6a1386947998fc9faf45 Mon Sep 17 00:00:00 2001 From: Kate Date: Wed, 10 Sep 2025 14:39:59 +0100 Subject: [PATCH 1/2] GHA: Ensure curl's exit status to be non-zero on failure --- .github/scripts/cygwin.cmd | 4 ++-- .github/scripts/main/ocaml-cache.sh | 10 +++++----- .github/scripts/main/opam-bs-cache.sh | 2 +- .github/scripts/main/upgrade.sh | 2 +- .github/scripts/scripts/hygiene.sh | 2 +- master_changes.md | 1 + 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/scripts/cygwin.cmd b/.github/scripts/cygwin.cmd index c60835be74a..cfc9ee38a52 100644 --- a/.github/scripts/cygwin.cmd +++ b/.github/scripts/cygwin.cmd @@ -83,10 +83,10 @@ md %CYGWIN_ROOT% :: Download the required setup program: the mingw-w64 compilers are only :: installed with Cygwin64. if "%1" equ "x86_64-pc-cygwin" ( - curl -sLo %CYGWIN_ROOT%\setup.exe https://cygwin.com/setup-x86_64.exe + curl -fsSLo %CYGWIN_ROOT%\setup.exe https://cygwin.com/setup-x86_64.exe set CYGWIN_PACKAGES=,mingw64-i686-gcc-core=14.3.0-0.1,mingw64-x86_64-gcc-core=14.3.0-0.1,mingw64-i686-gcc-g++=14.3.0-0.1,mingw64-x86_64-gcc-g++=14.3.0-0.1 ) else ( - curl -sLo %CYGWIN_ROOT%\setup.exe https://cygwin.com/setup-x86.exe + curl -fsSLo %CYGWIN_ROOT%\setup.exe https://cygwin.com/setup-x86.exe set CYGWIN_PACKAGES= ) diff --git a/.github/scripts/main/ocaml-cache.sh b/.github/scripts/main/ocaml-cache.sh index cec7b04d376..4c35ba91a6d 100644 --- a/.github/scripts/main/ocaml-cache.sh +++ b/.github/scripts/main/ocaml-cache.sh @@ -42,10 +42,10 @@ esac FLEXDLL_VERSION=0.44 MINGW_W64_VERSION=12.0.0 -curl -sLO "https://github.com/ocaml/ocaml/archive/refs/tags/${OCAML_VERSION}.tar.gz" +curl -fsSLO "https://github.com/ocaml/ocaml/archive/refs/tags/${OCAML_VERSION}.tar.gz" if [[ $PLATFORM = 'Windows' ]] ; then - curl -sLO "https://github.com/ocaml/flexdll/archive/refs/tags/$FLEXDLL_VERSION.tar.gz" - curl -sLO "https://github.com/mingw-w64/mingw-w64/archive/refs/tags/v${MINGW_W64_VERSION}.tar.gz" + curl -fsSLO "https://github.com/ocaml/flexdll/archive/refs/tags/$FLEXDLL_VERSION.tar.gz" + curl -fsSLO "https://github.com/mingw-w64/mingw-w64/archive/refs/tags/v${MINGW_W64_VERSION}.tar.gz" fi tar -xzf "$OCAML_VERSION.tar.gz" @@ -61,7 +61,7 @@ esac cd "ocaml-$OCAML_VERSION" for sha in $PATCHES; do - curl -sL "https://github.com/ocaml/ocaml/commit/$sha.patch" -o "../$sha.patch" + curl -fsSL "https://github.com/ocaml/ocaml/commit/$sha.patch" -o "../$sha.patch" patch -p1 -i "../$sha.patch" done @@ -97,7 +97,7 @@ if [[ $OPAM_TEST -ne 1 ]] ; then if [[ -e configure.ac ]]; then CONFIGURE_SWITCHES="--disable-debugger --disable-debug-runtime --disable-ocamldoc --disable-installing-bytecode-programs --disable-installing-source-artifacts" if [[ $OCAML_BRANCH -eq 408 ]]; then - curl -L https://github.com/ocaml/ocaml/commit/c8ee39b320207717135d88cad67fb65d0901d6b6.patch -o pr8858.patch + curl -fsSL https://github.com/ocaml/ocaml/commit/c8ee39b320207717135d88cad67fb65d0901d6b6.patch -o pr8858.patch patch -p1 -i pr8858.patch CONFIGURE_SWITCHES="$CONFIGURE_SWITCHES --disable-graph-lib" fi diff --git a/.github/scripts/main/opam-bs-cache.sh b/.github/scripts/main/opam-bs-cache.sh index 8db122194c5..dd723be07c6 100644 --- a/.github/scripts/main/opam-bs-cache.sh +++ b/.github/scripts/main/opam-bs-cache.sh @@ -12,7 +12,7 @@ if [ "$os" = "darwin" ] ; then os=macos fi -curl -sL -o $OPAM_LOCAL/bin/opam-bootstrap \ +curl -fsSL -o $OPAM_LOCAL/bin/opam-bootstrap \ "https://github.com/ocaml/opam/releases/download/$OPAMBSVERSION/opam-$OPAMBSVERSION-$(uname -m)-$os" cp -f $OPAM_LOCAL/bin/opam-bootstrap $OPAM_LOCAL/bin/opam chmod a+x $OPAM_LOCAL/bin/opam diff --git a/.github/scripts/main/upgrade.sh b/.github/scripts/main/upgrade.sh index 7435f698b57..2d8731dc4e6 100644 --- a/.github/scripts/main/upgrade.sh +++ b/.github/scripts/main/upgrade.sh @@ -16,7 +16,7 @@ if [[ ! -f $OPAM12 ]]; then if [ "$RUNNER_OS" = "macOS" ]; then os="Darwin" fi - curl -sL "https://github.com/ocaml/opam/releases/download/1.2.2/opam-1.2.2-x86_64-$os" -o $OPAM12 + curl -fsSL "https://github.com/ocaml/opam/releases/download/1.2.2/opam-1.2.2-x86_64-$os" -o $OPAM12 chmod +x $OPAM12 fi export OPAMROOT=/tmp/opamroot diff --git a/.github/scripts/scripts/hygiene.sh b/.github/scripts/scripts/hygiene.sh index 2d41b6c3fca..8c7a8ed811e 100644 --- a/.github/scripts/scripts/hygiene.sh +++ b/.github/scripts/scripts/hygiene.sh @@ -32,7 +32,7 @@ if [[ $GITHUB_EVENT_NAME = 'pull_request' ]]; then fi URL="$OPAM_BIN_URL_BASE$tag/opam-$tag-$platform" echo "Downloading $URL" - check=$(curl -Ls "$URL" | sha512sum | cut -d' ' -f1) + check=$(curl -fsSL "$URL" | sha512sum | cut -d' ' -f1) if [[ $check = $sha ]] ; then echo " as expected ($sha)" else diff --git a/master_changes.md b/master_changes.md index b363b744b91..d7d49c57a28 100644 --- a/master_changes.md +++ b/master_changes.md @@ -118,6 +118,7 @@ users) ## Github Actions * Add OCaml 5.4 to the test matrix [#6732 @kit-ty-kate] + * Ensure `curl`'s exit status to be non-zero on failure [#6684 @kit-ty-kate] ## Doc From fb1dbd01cebbe4b5fc55f172f601751d081a9203 Mon Sep 17 00:00:00 2001 From: Kate Date: Thu, 6 Nov 2025 19:03:55 +0000 Subject: [PATCH 2/2] GHA: Add OCaml trunk to the CI matrix The job is allowed to fail as bugs and uncaught unwanted behaviours are common at this point --- .github/scripts/main/ocaml-cache.sh | 5 +++-- .github/workflows/ci.ml | 18 ++++++++++-------- .github/workflows/lib.ml | 3 ++- .github/workflows/main.yml | 10 +++++++++- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/scripts/main/ocaml-cache.sh b/.github/scripts/main/ocaml-cache.sh index 4c35ba91a6d..d33d7cee9b5 100644 --- a/.github/scripts/main/ocaml-cache.sh +++ b/.github/scripts/main/ocaml-cache.sh @@ -42,7 +42,8 @@ esac FLEXDLL_VERSION=0.44 MINGW_W64_VERSION=12.0.0 -curl -fsSLO "https://github.com/ocaml/ocaml/archive/refs/tags/${OCAML_VERSION}.tar.gz" +curl -fsSLO "https://github.com/ocaml/ocaml/archive/refs/tags/${OCAML_VERSION}.tar.gz" || \ +curl -fsSLO "https://github.com/ocaml/ocaml/archive/refs/heads/${OCAML_VERSION}.tar.gz" if [[ $PLATFORM = 'Windows' ]] ; then curl -fsSLO "https://github.com/ocaml/flexdll/archive/refs/tags/$FLEXDLL_VERSION.tar.gz" curl -fsSLO "https://github.com/mingw-w64/mingw-w64/archive/refs/tags/v${MINGW_W64_VERSION}.tar.gz" @@ -96,7 +97,7 @@ OCAML_BRANCH="${OCAML_BRANCH/./}" if [[ $OPAM_TEST -ne 1 ]] ; then if [[ -e configure.ac ]]; then CONFIGURE_SWITCHES="--disable-debugger --disable-debug-runtime --disable-ocamldoc --disable-installing-bytecode-programs --disable-installing-source-artifacts" - if [[ $OCAML_BRANCH -eq 408 ]]; then + if [[ $OCAML_BRANCH = 408 ]]; then curl -fsSL https://github.com/ocaml/ocaml/commit/c8ee39b320207717135d88cad67fb65d0901d6b6.patch -o pr8858.patch patch -p1 -i pr8858.patch CONFIGURE_SWITCHES="$CONFIGURE_SWITCHES --disable-graph-lib" diff --git a/.github/workflows/ci.ml b/.github/workflows/ci.ml index c54cfb959fd..4c7f35e4fd9 100644 --- a/.github/workflows/ci.ml +++ b/.github/workflows/ci.ml @@ -15,15 +15,20 @@ open Lib let latest_ocaml4 = "4.14.2" let latest_ocaml5 = "5.4.0" (* Add this number to ocamls below when the next version comes out *) +let trunk = "trunk" let ocamls = [ (* Fully supported versions *) "4.08.1"; "4.09.1"; "4.10.2"; "4.11.2"; "4.12.1"; "4.13.1"; "5.0.0"; "5.1.1"; "5.2.1"; "5.3.0"; + (* Optionally supported versions *) + trunk; + (* The last elements of the list after 4.14 will be used as default versions *) latest_ocaml4; latest_ocaml5; ] -let start_latests_ocaml = (4, 14) +let start_latests_ocaml = latest_ocaml4 +let oldest_ocamlv = List.hd ocamls (* Entry point for the workflow. Workflows are specified as continuations where each job is passed as a continuation to the [workflow], terminated with @@ -69,12 +74,9 @@ jobs: let end_workflow ~oc:_ ~workflow:_ = () -let ocamls = - List.map (fun v -> Scanf.sscanf v "%u.%u.%u" (fun major minor _ -> ((major, minor), v))) ocamls - let platform_ocaml_matrix ?(dir=List.drop_while) ~fail_fast start_version = (fail_fast, - [("ocamlv", List.map snd (dir (fun ocaml -> fst ocaml <> start_version) ocamls))], + [("ocamlv", dir (fun ocaml -> not (String.equal ocaml start_version)) ocamls)], []) let git_lf_checkouts ?(title="Configure Git") ?cond ?shell () = @@ -347,8 +349,8 @@ let main_build_job ~analyse_job ~cygwin_job ?section runner start_version ~oc ~w ++ only_on Windows (unpack_cygwin "${{ matrix.build }}" "${{ matrix.host }}") ++ only_on Windows (run "Cygwin info" ["uname -a"]) ++ build_cache OCaml platform "${{ matrix.ocamlv }}" host - ++ run "Build" ["bash -exu .github/scripts/main/main.sh " ^ host] - ++ not_on Windows (run "Test (basic)" ["bash -exu .github/scripts/main/test.sh"]) + ++ run ~id:"build" ~continue_on_error:(Printf.sprintf "${{ matrix.ocamlv == '%s' }}" trunk) "Build" ["bash -exu .github/scripts/main/main.sh " ^ host] + ++ not_on Windows (run ~cond:(Predicate(false, Compare("steps.build.outcome", "failure"))) "Test (basic)" ["bash -exu .github/scripts/main/test.sh"]) ++ only_on Windows (run ~cond:(Predicate(false, EndsWith("matrix.host", "-pc-cygwin"))) "Test \"static\" binaries on Windows" ["ldd ./opam.exe | test \"$(grep -v -F /cygdrive/c/Windows/)\" = ''"]) ++ only_on Windows (uses "Upload opam binaries for Windows" @@ -574,7 +576,7 @@ let main oc : unit = workflow ~oc ~env "Builds, tests & co" ++ analyse_job ~keys ~platforms:[Linux] @@ fun analyse_job -> cygwin_job ~analyse_job - @@ fun cygwin_job -> main_build_job ~analyse_job ~cygwin_job ~section:"Build" Linux (4, 08) + @@ fun cygwin_job -> main_build_job ~analyse_job ~cygwin_job ~section:"Build" Linux oldest_ocamlv @@ fun build_linux_job -> main_build_job ~analyse_job ~cygwin_job Windows start_latests_ocaml @@ fun build_windows_job -> main_build_job ~analyse_job ~cygwin_job MacOS start_latests_ocaml @@ fun build_macOS_job -> main_test_job ~analyse_job ~build_linux_job ~build_windows_job ~build_macOS_job ~section:"Opam tests" Linux diff --git a/.github/workflows/lib.ml b/.github/workflows/lib.ml index 98bb2f7bb56..5004c95cc29 100644 --- a/.github/workflows/lib.ml +++ b/.github/workflows/lib.ml @@ -203,10 +203,11 @@ let emit_condition ~oc ~indent = let convert cond = fprintf oc "%sif: %s\n" indent (to_yaml cond) in Option.iter convert -let run name ?id ?cond ?shell ?env run ~oc ~workflow ~job f = +let run name ?id ?continue_on_error ?cond ?shell ?env run ~oc ~workflow ~job f = fprintf oc " - name: %s\n" name; Option.iter (emit_env ~indent:6 ~oc) env; Option.iter (fprintf oc " id: %s\n") id; + Option.iter (fprintf oc " continue-on-error: %s\n") continue_on_error; emit_condition ~oc ~indent:6 cond; Option.iter (fprintf oc " shell: %s\n") shell; begin match run with diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 29d4c3e1dae..6f45321c4e3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -106,7 +106,7 @@ jobs: needs: Analyse strategy: matrix: - ocamlv: [ 4.08.1, 4.09.1, 4.10.2, 4.11.2, 4.12.1, 4.13.1, 5.0.0, 5.1.1, 5.2.1, 5.3.0, 4.14.2, 5.4.0 ] + ocamlv: [ 4.08.1, 4.09.1, 4.10.2, 4.11.2, 4.12.1, 4.13.1, 5.0.0, 5.1.1, 5.2.1, 5.3.0, trunk, 4.14.2, 5.4.0 ] fail-fast: true steps: - name: Install bubblewrap @@ -134,8 +134,11 @@ jobs: if: steps.ocaml-cache.outputs.cache-hit != 'true' run: bash -exu .github/scripts/main/ocaml-cache.sh ${{ runner.os }} ${{ matrix.ocamlv }} - name: Build + id: build + continue-on-error: ${{ matrix.ocamlv == 'trunk' }} run: bash -exu .github/scripts/main/main.sh x86_64-pc-linux-gnu - name: Test (basic) + if: steps.build.outcome != 'failure' run: bash -exu .github/scripts/main/test.sh Build-Windows: @@ -214,6 +217,8 @@ jobs: if: steps.ocaml-cache.outputs.cache-hit != 'true' run: bash -exu .github/scripts/main/ocaml-cache.sh ${{ runner.os }} ${{ matrix.ocamlv }} ${{ matrix.host }} - name: Build + id: build + continue-on-error: ${{ matrix.ocamlv == 'trunk' }} run: bash -exu .github/scripts/main/main.sh ${{ matrix.host }} - name: Test "static" binaries on Windows if: endsWith(matrix.host, '-pc-cygwin') == false @@ -280,8 +285,11 @@ jobs: if: steps.ocaml-cache.outputs.cache-hit != 'true' run: bash -exu .github/scripts/main/ocaml-cache.sh ${{ runner.os }} ${{ matrix.ocamlv }} - name: Build + id: build + continue-on-error: ${{ matrix.ocamlv == 'trunk' }} run: bash -exu .github/scripts/main/main.sh x86_64-apple-darwin - name: Test (basic) + if: steps.build.outcome != 'failure' run: bash -exu .github/scripts/main/test.sh ####