Skip to content

Commit

Permalink
feat: Allow automatic install of system dependencies (needs opam 2.1) (
Browse files Browse the repository at this point in the history
…#74)

* feat(action.yml): Add `apt-get update -y -q` command to deps install step

* feat(action.yml): Change from `yes` to `unsafe-yes` to allow depexts install

* docs(README.md): Document `--confirm-level=unsafe-yes` for deps install step

* docs(README.md): Comment-out the now-redundant `apt-get update` in example of before_script step

* test(coq-demo.yml): Add unit test for automatic install of depexts

Co-authored-by: Erik Martin-Dorel <[email protected]>
  • Loading branch information
palmskog and erikmd authored Apr 9, 2022
1 parent e717ad9 commit e8a69bd
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
40 changes: 36 additions & 4 deletions .github/workflows/coq-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,42 @@ jobs:
OPAMWITHTEST: 'true'
ex_var: 'ex_value'

# The following job illustrates the installation of additional Debian packages.
# The following two jobs illustrate the installation of system packages.

demo-6:
name: custom_image / docker-coq / opam / apt-get
name: custom_image / docker-coq / opam / auto install depexts
runs-on: ubuntu-latest
strategy:
matrix:
image:
- 'coqorg/coq:dev'
fail-fast: false # don't stop jobs if one fails
steps:
################################################################
# Begin GHA_TEST_ENV # You should remove this GHA_TEST_ENV block
# # if you copy this demo workflow elsewhere!
- uses: actions/checkout@v2
with:
repository: 'erikmd/docker-coq-github-action-demo'
ref: 'master'
- uses: actions/checkout@v2
with:
path: 'docker-coq-action'
- uses: './docker-coq-action'
# End GHA_TEST_ENV
##################
# - uses: actions/checkout@v2
# - uses: coq-community/docker-coq-action@v1
with:
opam_file: 'coq-depexts-test.opam'
custom_image: ${{ matrix.image }}
after_script: |
startGroup "Post-test"
gappa --version
endGroup
demo-7:
name: custom_image / docker-coq / opam / apt-get install more
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -270,7 +302,7 @@ jobs:
before_script: |
startGroup "Install APT dependencies"
cat /etc/os-release
sudo apt-get update -y -q
# sudo apt-get update -y -q # this mandatory command is already run in install step by default
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -q --no-install-recommends \
emacs \
tree # for instance
Expand All @@ -284,7 +316,7 @@ jobs:
# The following job illustrates the upload of generated artifacts.

demo-7:
demo-8:
name: custom_image / docker-coq / opam+make / upload-artifacts
runs-on: ubuntu-latest
strategy:
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,21 @@ it will run (by default) the following commands:

```bash
opam config list; opam repo list; opam list
sudo apt-get update -y -q
opam pin add -n -y -k path coq-proj folder
opam update -y
opam install -y -j 2 coq-proj --deps-only
opam install --confirm-level=unsafe-yes -j 2 coq-proj --deps-only
opam list
opam install -y -v -j 2 coq-proj
opam list
opam remove coq-proj
```

The `apt-get` command and the `--confirm-level=unsafe-yes` opam option
are necessary for automatic installation of system packages
that may be required by `coq-proj.opam`, as described in the
[opam 2.1 release notes](https://opam.ocaml.org/blog/opam-2-1-0/#Seamless-integration-of-System-dependencies-handling-a-k-a-quot-depexts-quot).

## Using the GitHub Action

Using a [GitHub Action](https://docs.github.com/en/actions)
Expand Down Expand Up @@ -218,9 +224,10 @@ Default:

```bash
startGroup "Install dependencies"
sudo apt-get update -y -q
opam pin add -n -y -k path $PACKAGE $WORKDIR
opam update -y
opam install -y -j 2 $PACKAGE --deps-only
opam install --confirm-level=unsafe-yes -j 2 $PACKAGE --deps-only
endGroup
```

Expand Down Expand Up @@ -660,7 +667,7 @@ steps:
before_script: |
startGroup "Install APT dependencies"
cat /etc/os-release # Print the Debian OS version
sudo apt-get update -y -q # Mandatory
# sudo apt-get update -y -q # this mandatory command is already run in install step by default
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -q --no-install-recommends \
emacs \
tree # for instance
Expand Down
3 changes: 2 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ inputs:
description: 'Customizable script to install the opam dependencies.'
default: |
startGroup "Install dependencies"
sudo apt-get update -y -q
opam pin add -n -y -k path $PACKAGE $WORKDIR
opam update -y
opam install -y -j 2 $PACKAGE --deps-only
opam install --confirm-level=unsafe-yes -j 2 $PACKAGE --deps-only
endGroup
after_install:
description: 'Customizable script run after "install".'
Expand Down

0 comments on commit e8a69bd

Please sign in to comment.