Skip to content

Commit

Permalink
feat: Support more compilers & Remove useless 'opam switch $COMPILER_…
Browse files Browse the repository at this point in the history
…EDGE'

* This patch is a backward-compatible change

* Related:
- coq-community/docker-coq#7
- coq-community/docker-coq#12 (comment)
  • Loading branch information
erikmd committed Dec 11, 2020
1 parent 5ede7d7 commit 141e422
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ install all the `*.opam` packages stored in this directory.
#### `ocaml_version`

*Optional* The version of OCaml. Default `"minimal"`.
Among `"minimal"`, `"4.07-flambda"`, `"4.09-flambda"`.
Among `"minimal"` (*deprecated, to be removed on 14 December 2020*),
`"default"`, `"4.02"`, `"4.05"`, `"4.07-flambda"`,
`"4.08-flambda"`, `"4.09-flambda"`, `"4.10-flambda"`, `"4.11-flambda"`.

The supported compilers w.r.t. each version of Coq are documented in the
[Supported tags](https://github.com/coq-community/docker-coq/wiki#supported-tags) section of the `docker-coq` wiki.

#### `before_install`

Expand Down
4 changes: 3 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ inputs:
description: '"8.X", "latest", or "dev".'
default: 'latest'
ocaml_version:
description: 'minimal, 4.07-flambda, or 4.09-flambda'
description: 'minimal (deprecated), default, 4.02, 4.05, 4.07-flambda, 4.08-flambda, 4.09-flambda, 4.10-flambda, or 4.11-flambda'
default: 'minimal'
# TODO: uncomment this at the end of the one-switch docker-coq migration
# default: 'default'
before_install:
description: 'Customizable script run before "install", empty by default.'
default: |
Expand Down
28 changes: 10 additions & 18 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ if test -z "$INPUT_CUSTOM_IMAGE"; then

# TODO: validation of INPUT_COQ_VERSION, INPUT_OCAML_VERSION
COQ_IMAGE="coqorg/coq:$INPUT_COQ_VERSION"

# TODO: uncomment this at the end of the one-switch docker-coq migration
# if [ "$INPUT_OCAML_VERSION" = 'minimal' ]; then
# echo "ERROR: 'ocaml_version: minimal' is not supported anymore."
# exit 1
# fi
if [ "$INPUT_OCAML_VERSION" != 'default' ] \
&& [ "$INPUT_OCAML_VERSION" != 'minimal' ]; then
COQ_IMAGE="${COQ_IMAGE}-ocaml-${INPUT_OCAML_VERSION}"
fi
else
COQ_IMAGE="$INPUT_CUSTOM_IMAGE"
fi
Expand Down Expand Up @@ -146,30 +156,13 @@ if test -z "$INPUT_CUSTOM_SCRIPT_EXPANDED"; then
exit 1
fi

# todo: update this after the one-switch docker-coq migration
OCAML407="false"
if [ "$INPUT_OCAML_VERSION" = '4.09-flambda' ]; then
COQ_IMAGE="${COQ_IMAGE}-ocaml-4.09-flambda"
elif [ "$INPUT_OCAML_VERSION" = '4.07-flambda' ]; then
OCAML407="true"
# else Assume "$INPUT_OCAML_VERSION" = 'minimal'
fi
echo OCAML407="$OCAML407"

startGroup "Pull docker-coq image"

echo COQ_IMAGE="$COQ_IMAGE"
docker pull "$COQ_IMAGE"

endGroup

if [ "$OCAML407" = "true" ]; then
# shellcheck disable=SC2016
_OCAML407_COMMAND='startGroup Change opam switch; opam switch ${COMPILER_EDGE}; eval $(opam env); endGroup'
else
_OCAML407_COMMAND=''
fi

cp /app/coq.json "$HOME/coq.json"
echo "::add-matcher::$HOME/coq.json"

Expand All @@ -180,7 +173,6 @@ docker run -i --init --rm --name=COQ $( [ -n "$INPUT_EXPORT" ] && printf -- "-e
"$COQ_IMAGE" /bin/bash --login -c "
exec 2>&1 ; endGroup () { { init_opts=\"\$-\"; set +x ; } 2> /dev/null; if [ -n \"\$startTime\" ]; then endTime=\$(date -u +%s); echo \"::endgroup::\"; printf \"\"; date -u -d \"@\$((endTime - startTime))\" '+%-Hh %-Mm %-Ss'; echo; unset startTime; else echo 'Error: missing startGroup command.'; case \"\$init_opts\" in *x*) set -x ;; esac; return 1; fi; case \"\$init_opts\" in *x*) set -x ;; esac; } ; startGroup () { { init_opts=\"\$-\"; set +x ; } 2> /dev/null; if [ -n \"\$startTime\" ]; then endGroup; fi; if [ \$# -ge 1 ]; then groupTitle=\"\$*\"; else groupTitle=\"Unnamed group\"; fi; echo; echo \"::group::\$groupTitle\"; startTime=\$(date -u +%s); case \"\$init_opts\" in *x*) set -x ;; esac; } # generated from helper.sh
export PS4='+ \e[33;1m(\$0 @ line \$LINENO) \$\e[0m '; set -ex
$_OCAML407_COMMAND
$INPUT_CUSTOM_SCRIPT_EXPANDED" script

echo "::remove-matcher owner=coq-problem-matcher::"

0 comments on commit 141e422

Please sign in to comment.