|
| 1 | +name: Build, test, and lint |
| 2 | + |
| 3 | +on: |
| 4 | + - push |
| 5 | + - pull_request |
| 6 | + |
| 7 | +permissions: read-all |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-and-test: |
| 11 | + |
| 12 | + services: |
| 13 | + mariadb: |
| 14 | + image: mariadb:latest |
| 15 | + ports: ["3306:3306"] |
| 16 | + env: |
| 17 | + MARIADB_USER: testuser |
| 18 | + MARIADB_PASSWORD: testpw |
| 19 | + MARIADB_DATABASE: testdb |
| 20 | + MARIADB_RANDOM_ROOT_PASSWORD: 1 |
| 21 | + |
| 22 | + strategy: |
| 23 | + fail-fast: false |
| 24 | + matrix: |
| 25 | + os: |
| 26 | + - ubuntu-latest |
| 27 | + # ubuntu-20.40 has the same MariaDB client library options as latest |
| 28 | + # macos-latest does not work since we're using a service container |
| 29 | + ocaml-compiler: |
| 30 | + - 5 |
| 31 | + - 4.07 |
| 32 | + |
| 33 | + runs-on: ${{ matrix.os }} |
| 34 | + |
| 35 | + steps: |
| 36 | + - name: Check out source code |
| 37 | + uses: actions/checkout@v4 |
| 38 | + |
| 39 | + - name: Set up OCaml |
| 40 | + uses: ocaml/setup-ocaml@v3 |
| 41 | + with: |
| 42 | + ocaml-compiler: ${{ matrix.ocaml-compiler }} |
| 43 | + |
| 44 | + - name: Restore cached dependencies |
| 45 | + uses: actions/cache@v3 |
| 46 | + with: |
| 47 | + key: ${{ runner.os }}-ocaml-${{ matrix.ocaml-compiler }}-deps-${{ hashFiles('*.opam') }} |
| 48 | + path: ~/.opam |
| 49 | + |
| 50 | + - name: Install dependencies |
| 51 | + run: opam install . --deps-only -t |
| 52 | + |
| 53 | + - name: Build |
| 54 | + run: opam exec -- dune build |
| 55 | + |
| 56 | + - name: Check that MariaDB is running |
| 57 | + run: ss -tl |
| 58 | + |
| 59 | + - name: Run tests |
| 60 | + run: opam exec -- dune runtest |
| 61 | + env: |
| 62 | + OCAML_MARIADB_HOST: 127.0.0.1 |
| 63 | + OCAML_MARIADB_PORT: 3306 |
| 64 | + OCAML_MARIADB_USER: testuser |
| 65 | + OCAML_MARIADB_PASS: testpw |
| 66 | + OCAML_MARIADB_DB: testdb |
| 67 | + OCAML_MARIADB_QUERY: "SELECT 'hello ' || ?" |
| 68 | + |
| 69 | + lint-opam: |
| 70 | + runs-on: ubuntu-latest |
| 71 | + steps: |
| 72 | + - name: Check out source code |
| 73 | + uses: actions/checkout@v4 |
| 74 | + |
| 75 | + - name: Set up OCaml |
| 76 | + uses: ocaml/setup-ocaml@v3 |
| 77 | + with: |
| 78 | + ocaml-compiler: 5 |
| 79 | + |
| 80 | + - name: Lint OPAM package descriptions |
| 81 | + uses: ocaml/setup-ocaml/lint-opam@v3 |
0 commit comments