Skip to content

Commit cc69176

Browse files
committed
Improve OS coverage by containerizing the main CI job.
1 parent 515ed9c commit cc69176

File tree

1 file changed

+43
-30
lines changed

1 file changed

+43
-30
lines changed

Diff for: .github/workflows/workflow.yml

+43-30
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
services:
1313
mariadb:
1414
image: mariadb:latest
15-
ports: ["3306:3306"]
1615
env:
1716
MARIADB_USER: testuser
1817
MARIADB_PASSWORD: testpw
@@ -23,56 +22,70 @@ jobs:
2322
fail-fast: false
2423
matrix:
2524
os:
26-
- ubuntu-latest
27-
# ubuntu-20.04 has the same MariaDB client library options as latest
28-
# macos-latest does not work since we're using a service container
25+
# The main aim is to target different kinds of MariaDB client
26+
# libraries; see the OPAM specification of conf-mariadb.
27+
- "alpine" # MariaDB C connector
28+
- "ubuntu" # libmariadb
29+
# "ubuntu-18.04" has libmariadbclient but has too old libc for node.js
2930
ocaml-compiler:
30-
- 5
31-
- 4.07
31+
- "5.0"
32+
#- "4.07"
3233

33-
runs-on: ${{ matrix.os }}
34+
runs-on: ubuntu-latest
35+
container:
36+
image: "ocaml/opam:${{ matrix.os }}-ocaml-${{ matrix.ocaml-compiler }}"
37+
# Currently needed for the GitHub Actions, use sudo for other steps.
38+
options: "--user root"
3439

3540
steps:
3641
- name: Check out source code
3742
uses: actions/checkout@v4
3843

39-
- name: Set up OCaml
40-
uses: ocaml/setup-ocaml@v3
41-
with:
42-
ocaml-compiler: ${{ matrix.ocaml-compiler }}
44+
- name: Install system dependencies (alpine)
45+
if: "${{ matrix.os == 'alpine' }}"
46+
run: "apk add --no-cache linux-headers mariadb-connector-c-dev"
47+
48+
- name: Install system dependencies (ubuntu)
49+
if: "${{ matrix.os == 'ubuntu' }}"
50+
run: "apt-get update && apt-get install -y pkg-config libmariadb-dev"
4351

4452
- name: Restore cached dependencies
4553
uses: actions/cache@v3
4654
with:
47-
key: ${{ runner.os }}-ocaml-${{ matrix.ocaml-compiler }}-deps-${{ hashFiles('*.opam') }}
48-
path: ~/.opam
55+
# Since we use docker tag aliases we compute a digest of relevant
56+
# files on the system instead of using the matrix here.
57+
key: "${{ hashFiles('/etc/*-release', '.opam/config', '*.opam') }}"
58+
path: /home/opam/.opam
59+
60+
- name: Give opem access to the workspace
61+
run: "chown -Rh opam: ."
4962

5063
- name: Install dependencies
51-
run: opam install . --deps-only -t
64+
run: "sudo -u opam opam install -y --deps-only -t ."
5265

5366
- name: Build
54-
run: opam exec -- dune build
67+
run: "sudo -u opam opam exec -- dune build"
5568

5669
- name: Run tests
57-
run: opam exec -- dune runtest
70+
run: "sudo -u opam -E opam exec -- dune runtest"
5871
env:
59-
OCAML_MARIADB_HOST: 127.0.0.1
72+
OCAML_MARIADB_HOST: mariadb
6073
OCAML_MARIADB_PORT: 3306
6174
OCAML_MARIADB_USER: testuser
6275
OCAML_MARIADB_PASS: testpw
6376
OCAML_MARIADB_DB: testdb
6477
OCAML_MARIADB_QUERY: "SELECT 'hello ' || ?"
6578

66-
lint-opam:
67-
runs-on: ubuntu-latest
68-
steps:
69-
- name: Check out source code
70-
uses: actions/checkout@v4
71-
72-
- name: Set up OCaml
73-
uses: ocaml/setup-ocaml@v3
74-
with:
75-
ocaml-compiler: 5
76-
77-
- name: Lint OPAM package descriptions
78-
uses: ocaml/setup-ocaml/lint-opam@v3
79+
# lint-opam:
80+
# runs-on: ubuntu-latest
81+
# steps:
82+
# - name: Check out source code
83+
# uses: actions/checkout@v4
84+
#
85+
# - name: Set up OCaml
86+
# uses: ocaml/setup-ocaml@v3
87+
# with:
88+
# ocaml-compiler: 5
89+
#
90+
# - name: Lint OPAM package descriptions
91+
# uses: ocaml/setup-ocaml/lint-opam@v3

0 commit comments

Comments
 (0)