summaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: f128e5c9e5639aaf1f485bb584e0b3fc91bfeb1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Build and test vyconf on every PR and push to rolling.
#
# vyos1x-config (the core dependency) is not published to the default opam
# repository, so it is pinned from git before `opam install --deps-only` runs.
# setup-ocaml's automatic local-package pinning is disabled (opam-pin: false)
# so the dependency solve does not run before that git pin is registered.
name: Build and test

on:
  push:
    branches: [rolling]
  pull_request:
    branches: [rolling]

# Cancel superseded runs on the same ref.
concurrency:
  group: build-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest]
        ocaml-compiler: ["4.14", "5.2"]
    runs-on: ${{ matrix.os }}

    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          # Build-only job; do not leave the git token in .git/config for
          # later steps (e.g. the git-pinned vyos1x-config install).
          persist-credentials: false

      - name: Set up OCaml ${{ matrix.ocaml-compiler }}
        uses: ocaml/setup-ocaml@v3
        with:
          ocaml-compiler: ${{ matrix.ocaml-compiler }}
          # Pin vyos1x-config manually below, before the dependency solve.
          opam-pin: false
          dune-cache: true

      - name: Pin vyos1x-config from git
        run: opam pin add --no-action --yes vyos1x-config git+https://github.com/vyos/vyos1x-config.git#rolling

      # vyos1x-config's src/dune links `containers`, but its opam file does not
      # declare it, so the dependency solve for vyos1x-config never pulls it and
      # `dune build -p vyos1x-config` fails with "Library containers not found".
      # Install it explicitly until vyos1x-config.opam is fixed upstream.
      - name: Install vyos1x-config's undeclared build dependency
        run: opam install --yes containers

      - name: Install dependencies
        run: opam install . --deps-only --with-test --yes

      # --ignore-promoted-rules uses the committed src/*_pbt.ml instead of
      # re-running the ocaml-protoc codegen (a (mode promote) rule). This is
      # how the package is built via opam (`dune build -p` implies the same
      # flag), so CI matches: the committed 2.x-generated bindings are used and
      # ocaml-protoc is not invoked for codegen.
      - name: Build
        run: opam exec -- dune build --ignore-promoted-rules

      - name: Run tests
        run: opam exec -- dune runtest --ignore-promoted-rules