Skip to content

Commit

Permalink
final
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbou committed Jul 6, 2023
1 parent cce417f commit 3333edc
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 9 deletions.
5 changes: 0 additions & 5 deletions .github/scripts/common/hygiene-preamble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
r=$?
done
set -e
git show $BASE_REF_SHA
git show HEAD -q
git log -3
git show $PR_REF_SHA -q
git diff $BASE_REF_SHA..$PR_REF_SHA --name-only
fi

set +x
Expand Down
114 changes: 110 additions & 4 deletions .github/scripts/main/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,65 @@

set -xue

. .github/scripts/main/preamble.sh

unset-dev-version () {
# disable git versioning to allow OPAMYES use for upgrade
touch src/client/no-git-version
}

export OCAMLRUNPARAM=b

(set +x ; echo -en "::group::build opam\r") 2>/dev/null
if [[ $OPAM_TEST -eq 1 ]] || [[ $OPAM_DOC -eq 1 ]] ; then
export OPAMROOT=$OPAMBSROOT
# If the cached root is newer, regenerate a binary compatible root
opam env || { rm -rf $OPAMBSROOT; init-bootstrap; }
eval $(opam env)
fi

case "$1" in
*-pc-windows|*-w64-mingw32)
CONFIGURE_PREFIX='D:\Local'
PREFIX="$(cygpath "$CONFIGURE_PREFIX")";;
*)
PREFIX=~/local
CONFIGURE_PREFIX="$PREFIX";;
esac

if [ -e "$OCAML_LOCAL/_build" ]; then
cp -a "$OCAML_LOCAL/_build" .
fi

./configure --prefix $CONFIGURE_PREFIX --with-vendored-deps --with-mccs
if [ "$OPAM_TEST" != "1" ]; then
echo 'DUNE_PROFILE=dev' >> Makefile.config
fi

if [ $OPAM_UPGRADE -eq 1 ]; then
unset-dev-version
fi
# Disable implicit transitive deps
sed -i -e '/(implicit_transitive_deps /s/true/false/' dune-project
make all admin
sed -i -e '/(implicit_transitive_deps /s/false/true/' dune-project

rm -f "$PREFIX/bin/opam"
make install
(set +x ; echo -en "::endgroup::build opam\r") 2>/dev/null

export PATH="$PREFIX/bin:$PATH"
opam --version

if [ "$OPAM_DOC" = "1" ]; then
rm -rf src_ext/
make -C doc html man-html pages

if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
. .github/scripts/common/hygiene-preamble.sh
set -x
set +e
diff="git diff $BASE_REF_SHA..$PR_REF_SHA"
$diff --name-only --diff-filter=A
$diff --name-only --diff-filter=A | grep 'src/.*mli'
files="`$diff --name-only --diff-filter=A | grep 'src/.*mli'`"
files=`$diff --name-only --diff-filter=A | grep 'src/.*mli'`
if [ -n "$files" ]; then
echo '::group::new module added - checking it'
if $diff --name-only --exit-code -- doc/index.html ; then
Expand All @@ -26,3 +74,61 @@ if [ "$OPAM_DOC" = "1" ]; then
fi
fi
fi

if [ "$OPAM_TEST" = "1" ]; then
# test if an upgrade is needed
set +e
opam list 2> /dev/null
rcode=$?
if [ $rcode -eq 10 ]; then
echo "Recompiling for an opam root upgrade"
(set +x ; echo -en "::group::rebuild opam\r") 2>/dev/null
unset-dev-version
make all admin
rm -f "$PREFIX/bin/opam"
make install
opam list 2> /dev/null
rcode=$?
set -e
if [ $rcode -ne 10 ]; then
echo -e "\e[31mBad return code $rcode, should be 10\e[0m";
exit $rcode
fi
(set +x ; echo -en "::endgroup::rebuild opam\r") 2>/dev/null
fi
set -e

# Note: these tests require a "system" compiler and will use the one in $OPAMBSROOT
make tests

make distclean

# Compile and run opam-rt
(set +x ; echo -en "::group::opam-rt\r") 2>/dev/null
opamrt_url="https://github.com/ocaml-opam/opam-rt"
if [ ! -d $CACHE/opam-rt ]; then
git clone $opamrt_url $CACHE/opam-rt
fi
cd $CACHE/opam-rt
git fetch origin
if git ls-remote --exit-code origin $BRANCH ; then
if git branch | grep -q $BRANCH; then
git checkout $BRANCH
git reset --hard origin/$BRANCH
else
git checkout -b $BRANCH origin/$BRANCH
fi
else
git checkout master
git reset --hard origin/master
fi

test -d _opam || opam switch create . --no-install --formula '"ocaml-system"'
eval $(opam env)
opam pin $GITHUB_WORKSPACE -yn --with-version to-test
# opam lib pins defined in opam-rt are ignored as there is a local pin
opam pin . -yn --ignore-pin-depends
opam install opam-rt --deps-only opam-devel.to-test
make || { opam reinstall opam-client -y; make; }
(set +x ; echo -en "::endgroup::opam-rt\r") 2>/dev/null
fi
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,35 @@ jobs:
run: sudo apt install man2html
- name: Checkout tree
uses: actions/checkout@v3
- name: src_ext/archives and opam-repository Cache
id: archives
uses: ocaml-opam/cache@opam
with:
path: |
src_ext/archives
~/opam-repository
key: ${{ needs.Analyse.outputs.archives }}
force-gzip: true
- name: OCaml ${{ matrix.ocamlv }} Cache
id: ocaml-cache
uses: actions/cache@v3
with:
path: ~/.cache/ocaml-local/**
key: ${{ runner.os }}-ocaml-${{ matrix.ocamlv }}-${{ needs.Analyse.outputs.ocaml-cache }}
- name: Create OCaml ${{ matrix.ocamlv }} cache
if: steps.ocaml-cache.outputs.cache-hit != 'true'
run: bash -exu .github/scripts/main/ocaml-cache.sh ${{ runner.os }} ${{ matrix.ocamlv }}
- name: opam bootstrap Cache
id: opam-bootstrap
uses: actions/cache@v3
with:
path: |
${{ env.OPAMBSROOT }}/**
~/.cache/opam-local/bin/**
key: opamdoc-${{ runner.os }}-${{ env.OPAMBSVERSION }}-${{ matrix.ocamlv }}-${{ env.OPAM_REPO_SHA }}-${{ needs.Analyse.outputs.opam-bs-cache }}
- name: Create opam bootstrap cache
if: steps.opam-bootstrap.outputs.cache-hit != 'true'
run: bash -exu .github/scripts/main/opam-bs-cache.sh
- name: Compile
env:
BASE_REF_SHA: ${{ github.event.pull_request.base.sha }}
Expand Down
1 change: 1 addition & 0 deletions src/client/opamClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1733,3 +1733,4 @@ end




0 comments on commit 3333edc

Please sign in to comment.