From e8a69bdb47e9ca5f1b736a940ba3d8f3a21faa2e Mon Sep 17 00:00:00 2001 From: Karl Palmskog Date: Sat, 9 Apr 2022 20:58:26 +0200 Subject: [PATCH] feat: Allow automatic install of system dependencies (needs opam 2.1) (#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 --- .github/workflows/coq-demo.yml | 40 ++++++++++++++++++++++++++++++---- README.md | 13 ++++++++--- action.yml | 3 ++- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/.github/workflows/coq-demo.yml b/.github/workflows/coq-demo.yml index ecc1c52..6bc9e48 100644 --- a/.github/workflows/coq-demo.yml +++ b/.github/workflows/coq-demo.yml @@ -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: @@ -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 @@ -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: diff --git a/README.md b/README.md index c10f58c..9d90be3 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 ``` @@ -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 diff --git a/action.yml b/action.yml index 3f1aca7..d6811b6 100644 --- a/action.yml +++ b/action.yml @@ -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".'