Skip to content

Latest commit

 

History

History
179 lines (144 loc) · 4.35 KB

examples.md

File metadata and controls

179 lines (144 loc) · 4.35 KB

Examples

Using the strategy matrix

strategy:
  fail-fast: false
  matrix:
    os:
      - macos-latest
      - ubuntu-latest
    ocaml-compiler:
      - ocaml-base-compiler.4.12.0
    include:
      - os: windows-latest
        ocaml-compiler: ocaml-variants.4.12.0+mingw64c

runs-on: ${{ matrix.os }}

steps:
  - name: Checkout code
    uses: actions/checkout@v2

  - name: Use OCaml ${{ matrix.ocaml-compiler }}
    uses: avsm/setup-ocaml@v2
    with:
      ocaml-compiler: ${{ matrix.ocaml-compiler }}

Using several conditional setup steps

steps:
  - name: Checkout code
    uses: actions/checkout@v2

  - name: Use OCaml on Windows
    uses: avsm/setup-ocaml@v2
    if: runner.os == 'Windows'
    with:
      ocaml-repositories: |
        default: https://github.com/fdopen/opam-repository-mingw.git#opam2

  - name: Use OCaml on Unix
    uses: avsm/setup-ocaml@v2
    if: runner.os != 'Windows'
    with:
      opam-repositories: |
        default: https://github.com/ocaml/opam-repository.git

Using a custom step to choose between the values

steps:
  - name: Checkout code
    uses: actions/checkout@v2

  - name: Set opam repository url
    id: repository
    shell: bash
    run: |
      if [ "$RUNNER_OS" == "Windows" ]; then
        echo "::set-output name=url::https://github.com/fdopen/opam-repository-mingw.git#opam2"
      elif [ "$RUNNER_OS" == "macOS" ]; then
        echo "::set-output name=url::https://github.com/custom/opam-repository.git#macOS"
      else
        echo "::set-output name=url::https://github.com/ocaml/opam-repository.git"
      fi

  - name: Use OCaml with repository ${{ steps.repository.url }}
    uses: avsm/setup-ocaml@v2
    with:
      opam-repositories: |
        default: ${{ steps.repository.url }}

Using glob patterns to filter local packages

See @actions/glob for supported patterns.

steps:
  - name: Checkout code
    uses: actions/checkout@v2

  - name: Use OCaml ${{ matrix.ocaml-compiler }}
    uses: avsm/setup-ocaml@v2
    with:
      ocaml-compiler: ${{ matrix.ocaml-compiler }}
      opam-local-packages: |
        *.opam
        !exclude.opam

Using with Containers

strategy:
  fail-fast: false
  matrix:
    container:
      - debian:latest
      - ubuntu:latest
    ocaml-compiler:
      - ocaml-base-compiler.4.12.0

container: ${{ matrix.container }}

runs-on: ubuntu-latest

steps:
  - name: Checkout code
    uses: actions/checkout@v2

  - name: Retrieve new lists of system packages
    run: apt-get update

  - name: Install system packages
    run: apt-get install bubblewrap curl darcs gcc git m4 make mercurial patch rsync sudo unzip --yes

  - name: Use OCaml ${{ matrix.ocaml-compiler }}
    uses: avsm/setup-ocaml@v2
    with:
      ocaml-compiler: ${{ matrix.ocaml-compiler }}
      cache-prefix: v1-${{ matrix.container }}
      opam-disable-sandboxing: true

Using opam-dune-lint to lint the opam files

steps:
  - name: Checkout code
    uses: actions/checkout@v2

  - name: Use OCaml ${{ matrix.ocaml-compiler }}
    uses: avsm/setup-ocaml@v2
    with:
      ocaml-compiler: ${{ matrix.ocaml-compiler }}

  - run: opam depext opam-dune-lint --install

  - run: opam exec -- opam-dune-lint

Using OCamlFormat and dune @fmt alias to check if your files are formatted

steps:
  - name: Checkout code
    uses: actions/checkout@v2

  - name: Use OCaml ${{ matrix.ocaml-compiler }}
    uses: avsm/setup-ocaml@v2
    with:
      ocaml-compiler: ${{ matrix.ocaml-compiler }}
      dune-cache: true

  - run: opam depext ocamlformat=$(grep 'version' .ocamlformat | awk -F '=' '{ print $2 }') --install

  - run: opam exec -- dune build @fmt