Skip to content

Commit

Permalink
Add CI based testing, with related fix.
Browse files Browse the repository at this point in the history
Fix missing version for the dune dependency.
  • Loading branch information
paurkedal committed Sep 9, 2024
1 parent 0b9c02c commit 515ed9c
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
78 changes: 78 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build, test, and lint

on:
- push
- pull_request

permissions: read-all

jobs:
build-and-test:

services:
mariadb:
image: mariadb:latest
ports: ["3306:3306"]
env:
MARIADB_USER: testuser
MARIADB_PASSWORD: testpw
MARIADB_DATABASE: testdb
MARIADB_RANDOM_ROOT_PASSWORD: 1

strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
# ubuntu-20.04 has the same MariaDB client library options as latest
# macos-latest does not work since we're using a service container
ocaml-compiler:
- 5
- 4.07

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

steps:
- name: Check out source code
uses: actions/checkout@v4

- name: Set up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}

- name: Restore cached dependencies
uses: actions/cache@v3
with:
key: ${{ runner.os }}-ocaml-${{ matrix.ocaml-compiler }}-deps-${{ hashFiles('*.opam') }}
path: ~/.opam

- name: Install dependencies
run: opam install . --deps-only -t

- name: Build
run: opam exec -- dune build

- name: Run tests
run: opam exec -- dune runtest
env:
OCAML_MARIADB_HOST: 127.0.0.1
OCAML_MARIADB_PORT: 3306
OCAML_MARIADB_USER: testuser
OCAML_MARIADB_PASS: testpw
OCAML_MARIADB_DB: testdb
OCAML_MARIADB_QUERY: "SELECT 'hello ' || ?"

lint-opam:
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v4

- name: Set up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: 5

- name: Lint OPAM package descriptions
uses: ocaml/setup-ocaml/lint-opam@v3
2 changes: 1 addition & 1 deletion mariadb.opam
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ depends: [
"ctypes" {>= "0.7.0"}
"conf-mariadb"
"conf-gcc"
"dune"
"dune" {>= "3.15.0"}
"dune-configurator"
"async" {with-test}
"lwt" {with-test}
Expand Down

0 comments on commit 515ed9c

Please # to comment.