From b4e2515fc8006bb26e0687da8a2fadf670e6d902 Mon Sep 17 00:00:00 2001 From: Erik Martin-Dorel Date: Sun, 19 Jun 2022 03:09:10 +0200 Subject: [PATCH] feat: Adapt to PR coq-community/docker-coq#47 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Document the support of coq_version: '…-native' * Add more links, to the ocaml-version-policy of Docker-Coq * Deprecate the value of ocaml_version: 'minimal' * Add a GHA warning for this deprecated value. * Add a GHA warning for (coq_version: '…-native', ocaml_version != 'default') * Remove the now-unneeded `opam switch ${COMPILER_EDGE)` command --- .github/workflows/coq-demo.yml | 3 +- README.md | 15 +++-- action.yml | 6 +- entrypoint.sh | 104 +++++++++++++++++++++++---------- 4 files changed, 87 insertions(+), 41 deletions(-) diff --git a/.github/workflows/coq-demo.yml b/.github/workflows/coq-demo.yml index 6bc9e48..103f5f1 100644 --- a/.github/workflows/coq-demo.yml +++ b/.github/workflows/coq-demo.yml @@ -26,8 +26,9 @@ jobs: # see https://github.com/coq-community/docker-coq/wiki#supported-tags coq_version: - 'latest' + - 'latest-native' - 'dev' - ocaml_version: ['4.07-flambda'] + ocaml_version: ['default'] fail-fast: false # don't stop jobs if one fails steps: ################################################################ diff --git a/README.md b/README.md index 9d90be3..9d48410 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,11 @@ Default: `"latest"` (= latest stable version). Append the `-native` suffix if the version is `>= 8.13` (or `dev`) *and* you are interested in the image that contains the [`coq-native`](https://opam.ocaml.org/packages/coq-native/) package. -E.g., `"dev-native"`. In this case, the `ocaml_version` must be `"4.07"`. +E.g., `"8.13-native"`, `"latest-native"`, `"dev-native"`. + +If the `coq_version` value contains the `-native` suffix, +the `ocaml_version` value is ignored (as `coq-native` images only come with a single OCaml version). +Still, a warning is raised if `ocaml_version` is nonempty and different from `"default"`. #### `ocaml_version` @@ -189,14 +193,15 @@ E.g., `"dev-native"`. In this case, the `ocaml_version` must be `"4.07"`. The version of OCaml. -Default: `"minimal"`. +Default: `"default"` (= Docker-Coq's default OCaml version for the given Coq version). -Among `"minimal"`, `"4.07-flambda"`, `"4.07"`, `"4.08-flambda"`, -`"4.09-flambda"`, `"4.10-flambda"`, `"4.11-flambda"`, `"4.12-flambda"`. +Among `"minimal"` (*deprecated, to be removed after 27 June 2022 AOE*), +`"default"`, `"4.02"`, `"4.05"`, `"4.07"`, `"4.07-flambda"`, `"4.08-flambda"`, `"4.09"`, `"4.09-flambda"`, `"4.10-flambda"`, `"4.11-flambda"`, `"4.12-flambda"`, `"4.13-flambda"`, `"4.14-flambda"`… **Warning!** not all OCaml versions are available with all Coq versions. -For details, see: +The supported compilers w.r.t. each version of Coq are documented in the +[OCaml-versions policy](https://github.com/coq-community/docker-coq/wiki#ocaml-versions-policy) section of the `docker-coq` wiki. #### `before_install` diff --git a/action.yml b/action.yml index d6811b6..80854d9 100644 --- a/action.yml +++ b/action.yml @@ -9,11 +9,11 @@ inputs: description: 'The path of the .opam file (or a directory), relative to the repo root.' default: '.' coq_version: - description: '"8.X", "latest", or "dev".' + description: '"8.X", "latest", "dev", "8.X-native", "latest-native", or "dev-native"' default: 'latest' ocaml_version: - description: '"minimal", "4.XX", or "4.XX-flambda", see https://github.com/coq-community/docker-coq/wiki#supported-tags' - default: 'minimal' + description: '"minimal" (deprecated), "default", "4.XX", or "4.XX-flambda", see https://github.com/coq-community/docker-coq/wiki#ocaml-versions-policy' + default: 'default' before_install: description: 'Customizable script run before "install".' default: | diff --git a/entrypoint.sh b/entrypoint.sh index 03bf45c..c45e5a4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,6 +18,10 @@ fi startGroup "Print runner configuration" echo "GITHUB_WORKFLOW=$GITHUB_WORKFLOW" +echo "GITHUB_RUN_ID=$GITHUB_RUN_ID" +echo "GITHUB_RUN_NUMBER=$GITHUB_RUN_NUMBER" +# echo "GITHUB_ACTION=$GITHUB_ACTION" # useless (and slash missing) +echo "GITHUB_REPOSITORY=$GITHUB_REPOSITORY" echo "RUNNER_OS=$RUNNER_OS" echo "RUNNER_TEMP=$RUNNER_TEMP" echo "RUNNER_WORKSPACE=$RUNNER_WORKSPACE" @@ -68,6 +72,9 @@ INPUT_EXPORT: the space-separated list of env variables to export EOF } +cp /app/coq.json "$HOME/coq.json" +echo "::add-matcher::$HOME/coq.json" + ## Parse options OPTIND=1 # Reset is necessary if getopts was used previously in the script. It is a good idea to make this local in a function. while getopts "h" opt; do @@ -88,37 +95,84 @@ if test $# -gt 0; then echo "Warning: Arguments ignored: $*" fi +# TODO: character validation of INPUT_COQ_VERSION, INPUT_OCAML_VERSION + if test -z "$INPUT_CUSTOM_IMAGE"; then + if test -z "$INPUT_COQ_VERSION"; then echo "ERROR: No Coq version specified." usage exit 1 fi - if test -z "$INPUT_OCAML_VERSION"; then - echo "ERROR: No OCaml version specified." - usage - exit 1 - fi + if [ "$INPUT_OCAML_VERSION" = 'default' ]; then + + COQ_IMAGE="coqorg/coq:$INPUT_COQ_VERSION" + + elif printf "%s" "$INPUT_COQ_VERSION" | grep -e '.-native$' -q; then - # TODO: validation of INPUT_COQ_VERSION, INPUT_OCAML_VERSION - COQ_IMAGE="coqorg/coq:$INPUT_COQ_VERSION" + COQ_IMAGE="coqorg/coq:$INPUT_COQ_VERSION" + + if test -n "$INPUT_OCAML_VERSION"; then + # HERE, "ocaml_version" is nonempty and different from 'default' + # HERE, "coq_version" ends in '…-native' + + # Warning: coq-native enabled: ocaml_version SHOULD be '' or 'default'. + + # Rely on line 'echo "::add-matcher::$HOME/coq.json"' above. + cat <&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::"