Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update generate & Add template for GitHub container action #26

Merged
merged 12 commits into from
May 1, 2020
Merged
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ mustache meta.yml ../templates/default.nix.mustache > default.nix
mustache meta.yml ../templates/README.md.mustache > README.md
mustache meta.yml ../templates/.travis.yml.mustache > .travis.yml
mustache meta.yml ../templates/coq.opam.mustache > coq-aac-tactics.opam
mkdir -p .github/workflows
mustache meta.yml ../templates/coq-action.yml.mustache > .github/workflows/coq-action.yml
erikmd marked this conversation as resolved.
Show resolved Hide resolved
```
Other projects using the templates in a similar way include
[Chapar](https://github.com/coq-community/chapar) and
Expand Down
34 changes: 34 additions & 0 deletions coq-action.yml.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
# the OS must be GNU/Linux to be able to use the docker-coq-action
runs-on: ubuntu-latest
strategy:
matrix:
coq_version:
{{# tested_coq_opam_versions }}
- {{ version }}
{{/ tested_coq_opam_versions }}
ocaml_version: ['minimal']
steps:
- uses: actions/checkout@v2
- uses: coq-community/docker-coq-action@v1
with:
opam_file: 'coq-{{ shortname }}.opam'
{{! Change delimiters to avoid the next two lines being parsed as mustache syntax. }}
{{=<% %>=}}
erikmd marked this conversation as resolved.
Show resolved Hide resolved
coq_version: ${{ matrix.coq_version }}
ocaml_version: ${{ matrix.ocaml_version }}

# See also:
# https://github.com/coq-community/docker-coq-action#readme
# https://github.com/erikmd/docker-coq-github-action-demo
21 changes: 19 additions & 2 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@

srcdir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )

function ask1() { local yn; echo -n "$* [Y/n] "; read -r -n 1 yn; [[ "$yn" =~ [Yy] ]] && echo && return 0; [ -z "$yn" ] && return 0; echo; return 1; }

for f in "$srcdir"/{,.}*.mustache; do
echo "Generating $(basename "$f" .mustache)..."
mustache meta.yml "$f" > "$(basename "$f" .mustache)"
target=$(basename "$f" .mustache)
case "$target" in
coq.opam)
shortname=$(grep -e "^shortname:" meta.yml | sed -e 's/^shortname:\s\+//')
erikmd marked this conversation as resolved.
Show resolved Hide resolved
[ -n "$shortname" ] && target=${target/coq/coq-$shortname}
;;
extracted.opam)
extracted_shortname=$(grep -e "^\s\+extracted_shortname:" meta.yml | sed -e 's/^\s\+extracted_shortname:\s\+//')
[ -n "$extracted_shortname" ] && target=${target/extracted/$extracted_shortname}
;;
coq-action.yml)
ask1 "Do you want to create a .github/workflows subfolder for coq-action.yml?" &&
erikmd marked this conversation as resolved.
Show resolved Hide resolved
{ mkdir -p .github/workflows; target=".github/workflows/$target"; }
;;
esac
echo "Generating $target..."
mustache meta.yml "$f" > "$target"
done