Skip to content

Commit

Permalink
Fix updating ocaml-cache.sh in PRs on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dra27 committed Dec 1, 2022
1 parent c1eb5ed commit acf5ad7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 32 deletions.
37 changes: 37 additions & 0 deletions .github/scripts/main/create-ocaml-cache.sh
Original file line number Diff line number Diff line change
@@ -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
34 changes: 5 additions & 29 deletions .github/scripts/main/ocaml-cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion .github/workflows/ci.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down

0 comments on commit acf5ad7

Please sign in to comment.