diff --git a/.github/scripts/main/create-ocaml-cache.sh b/.github/scripts/main/create-ocaml-cache.sh new file mode 100755 index 00000000000..16b5e270836 --- /dev/null +++ b/.github/scripts/main/create-ocaml-cache.sh @@ -0,0 +1,37 @@ +#!/bin/bash -xue + +OCAML_BRANCH="$1" +PREFIX="$2" +EXE="$3" +OCAML_LOCAL="$4" +PLATFORM="$5" + +if [[ $OCAML_BRANCH -gt 407 ]]; then + if [[ -n $GITHUB_BASE_REF ]]; then + git tag combak + git fetch origin $GITHUB_BASE_REF + git checkout origin/$GITHUB_BASE_REF + fi + make -C src_ext dune-local.stamp + cd src_ext/dune-local + ocaml bootstrap.ml + cp dune.exe "$PREFIX/bin/dune$EXE" + cd ../.. + + ./configure + make + cp -a _build "$OCAML_LOCAL/" + rm -f "$OCAML_LOCAL/_build/log" + mv "$OCAML_LOCAL/_build/default/src_ext" "$OCAML_LOCAL/_build/" + rm -rf "$OCAML_LOCAL/_build/default"/* "$OCAML_LOCAL/_build/install" + mv "$OCAML_LOCAL/_build/src_ext" "$OCAML_LOCAL/_build/default/" + git clean -dfX + if [[ -n $GITHUB_BASE_REF ]]; then + git checkout combak + fi +fi + +# The Windows BSD tar can't cope with symlinks, so we pre-tar the archive and cache that! +if [[ $PLATFORM = 'Windows' ]]; then + tar -C "$OCAML_LOCAL" -pcf "$OCAML_LOCAL.tar" . +fi diff --git a/.github/scripts/main/ocaml-cache.sh b/.github/scripts/main/ocaml-cache.sh index dd7ed0e2fab..860e51fe2df 100644 --- a/.github/scripts/main/ocaml-cache.sh +++ b/.github/scripts/main/ocaml-cache.sh @@ -144,32 +144,8 @@ EOF chmod +x "$OCAML_LOCAL/bin/ocamldoc" fi -if [[ $OCAML_BRANCH -gt 407 ]]; then - if [[ -n $GITHUB_BASE_REF ]]; then - git tag combak - git fetch origin $GITHUB_BASE_REF - git checkout origin/$GITHUB_BASE_REF - fi - make -C src_ext dune-local.stamp - cd src_ext/dune-local - ocaml bootstrap.ml - cp dune.exe "$PREFIX/bin/dune$EXE" - cd ../.. - - ./configure - make - cp -a _build "$OCAML_LOCAL/" - rm -f "$OCAML_LOCAL/_build/log" - mv "$OCAML_LOCAL/_build/default/src_ext" "$OCAML_LOCAL/_build/" - rm -rf "$OCAML_LOCAL/_build/default"/* "$OCAML_LOCAL/_build/install" - mv "$OCAML_LOCAL/_build/src_ext" "$OCAML_LOCAL/_build/default/" - git clean -dfX - if [[ -n $GITHUB_BASE_REF ]]; then - git checkout combak - fi -fi - -# The Windows BSD tar can't cope with symlinks, so we pre-tar the archive and cache that! -if [[ $PLATFORM = 'Windows' ]]; then - tar -C "$OCAML_LOCAL" -pcf "$OCAML_LOCAL.tar" . -fi +# Hand-over control to a separate script in case the branch being tested +# updates this script, which will fail on Windows (since the script is "open" +# and can't be overwritten) +cp -pf .github/scripts/main/create-ocaml-cache.sh ../create-ocaml-cache.sh +exec ../create-ocaml-cache.sh "$OCAML_BRANCH" "$PREFIX" "$EXE" "$OCAML_LOCAL" "$PLATFORM" diff --git a/.github/workflows/ci.ml b/.github/workflows/ci.ml index 2d4516c99b8..3570c6311ea 100644 --- a/.github/workflows/ci.ml +++ b/.github/workflows/ci.ml @@ -514,7 +514,7 @@ let main oc : unit = let keys = [ ("archives", "archives-1-${{ hashFiles('src_ext/Makefile.sources', 'src_ext/Makefile', '.github/scripts/common/preamble.sh', '.github/scripts/main/preamble.sh', '.github/scripts/main/archives-cache.sh') }}-${{ env.OPAM_REPO_SHA }}"); ("ocaml-secondary-compiler", "legacy-${{ env.OPAM_REPO_SHA }}"); - ("ocaml-cache", "${{ hashFiles('.github/scripts/main/ocaml-cache.sh', '.github/scripts/main/preamble.sh') }}"); + ("ocaml-cache", "${{ hashFiles('.github/scripts/main/ocaml-cache.sh', '.github/scripts/main/preamble.sh', '.github/scripts/main/create-ocaml-cache.sh') }}"); ("cygwin", "${{ hashFiles('.github/scripts/cygwin.cmd') }}-${{ env.CYGWIN_EPOCH }}"); ("opam-bs-cache", "${{ hashFiles('.github/scripts/main/opam-bs-cache.sh', '*.opam', '.github/scripts/main/preamble.sh') }}"); ] in diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index be6b76bab98..3e71b6ee34e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -75,8 +75,8 @@ jobs: echo archives=archives-1-${{ hashFiles('src_ext/Makefile.sources', 'src_ext/Makefile', '.github/scripts/common/preamble.sh', '.github/scripts/main/preamble.sh', '.github/scripts/main/archives-cache.sh') }}-${{ env.OPAM_REPO_SHA }} >> $GITHUB_OUTPUT echo ocaml-secondary-compiler=legacy-${{ env.OPAM_REPO_SHA }} echo ocaml-secondary-compiler=legacy-${{ env.OPAM_REPO_SHA }} >> $GITHUB_OUTPUT - echo ocaml-cache=${{ hashFiles('.github/scripts/main/ocaml-cache.sh', '.github/scripts/main/preamble.sh') }} - echo ocaml-cache=${{ hashFiles('.github/scripts/main/ocaml-cache.sh', '.github/scripts/main/preamble.sh') }} >> $GITHUB_OUTPUT + echo ocaml-cache=${{ hashFiles('.github/scripts/main/ocaml-cache.sh', '.github/scripts/main/preamble.sh', '.github/scripts/main/create-ocaml-cache.sh') }} + echo ocaml-cache=${{ hashFiles('.github/scripts/main/ocaml-cache.sh', '.github/scripts/main/preamble.sh', '.github/scripts/main/create-ocaml-cache.sh') }} >> $GITHUB_OUTPUT echo cygwin=${{ hashFiles('.github/scripts/cygwin.cmd') }}-${{ env.CYGWIN_EPOCH }} echo cygwin=${{ hashFiles('.github/scripts/cygwin.cmd') }}-${{ env.CYGWIN_EPOCH }} >> $GITHUB_OUTPUT echo opam-bs-cache=${{ hashFiles('.github/scripts/main/opam-bs-cache.sh', '*.opam', '.github/scripts/main/preamble.sh') }}