Skip to content

Commit

Permalink
Merge pull request #27 from coq-community/optional-opam-file
Browse files Browse the repository at this point in the history
feat: Make opam_file optional
  • Loading branch information
Zimmi48 authored Sep 21, 2020
2 parents 89fce4f + b83ae26 commit 1747b70
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,25 @@ See also the [example repo](https://github.com/erikmd/docker-coq-github-action-d
#### `opam_file`

**Required** the path of the `.opam` file, relative to the repo root.
*Optional* the path of the `.opam` file (or a directory), relative to the repo root.
Default `"."` (if the argument is omitted or an empty string).

*Note:* relying on the value of this `INPUT_OPAM_FILE` variable, the
*Note-1:* relying on the value of this `INPUT_OPAM_FILE` variable, the
following two variables are exported when running the `custom_script`:

```bash
WORKDIR=$(dirname "$INPUT_OPAM_FILE")
PACKAGE=$(basename "$INPUT_OPAM_FILE" .opam)
if [ -z "$INPUT_OPAM_FILE" ] || [ -d "$INPUT_OPAM_FILE" ]; then
WORKDIR=""
PACKAGE=${INPUT_OPAM_FILE:-.}
else
WORKDIR=$(dirname "$INPUT_OPAM_FILE")
PACKAGE=$(basename "$INPUT_OPAM_FILE" .opam)
fi
```

See also the
[`custom_script` default value](#custom_script).
*Note-2:* if this value is a directory (e.g., `.`), relying on the
[`custom_script` default value](#custom_script), the action will
install all the `*.opam` packages stored in this directory.

#### `coq_version`

Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ description: 'GitHub Action using Docker-Coq'
author: 'Erik Martin-Dorel'
inputs:
opam_file:
description: 'The path of the .opam file, relative to the repo root.'
required: true
description: 'The path of the .opam file (or a directory), relative to the repo root.'
default: '.'
coq_version:
description: '"8.X", "latest", or "dev".'
default: 'latest'
Expand Down
24 changes: 8 additions & 16 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ timegroup_file="/app/timegroup.sh"
# shellcheck source=./timegroup.sh
. "$timegroup_file"

WORKDIR=$(dirname "$INPUT_OPAM_FILE")
PACKAGE=$(basename "$INPUT_OPAM_FILE" .opam)
if [ -z "$INPUT_OPAM_FILE" ] || [ -d "$INPUT_OPAM_FILE" ]; then
WORKDIR=""
PACKAGE=${INPUT_OPAM_FILE:-.}
else
WORKDIR=$(dirname "$INPUT_OPAM_FILE")
PACKAGE=$(basename "$INPUT_OPAM_FILE" .opam)
fi

startGroup Print runner configuration

Expand Down Expand Up @@ -52,7 +57,7 @@ Usage:
$0
Options:
INPUT_OPAM_FILE: the path of the .opam file, relative to the repo root
INPUT_OPAM_FILE: the path of the .opam file (or a directory), relative to the repo root
INPUT_COQ_VERSION: the version of Coq (without patch-level)
INPUT_OCAML_VERSION: the version of OCaml (minimal, 4.07-flambda, 4.09-flambda)
INPUT_CUSTOM_SCRIPT: the main script run in the container
Expand Down Expand Up @@ -80,19 +85,6 @@ if test $# -gt 0; then
echo "Warning: Arguments ignored: $*"
fi

if test -z "$INPUT_OPAM_FILE"; then
echo "ERROR: No opam_file specified."
usage
exit 1
fi

case "$INPUT_OPAM_FILE" in
*.opam)
:;;
*)
echo "Warning: the opam_file argument should have the '.opam' suffix.";;
esac

if test -z "$INPUT_CUSTOM_IMAGE"; then
if test -z "$INPUT_COQ_VERSION"; then
echo "ERROR: No Coq version specified."
Expand Down

0 comments on commit 1747b70

Please sign in to comment.