From 515ed9c9696fd277553a1c734f13b295adb0cf5f Mon Sep 17 00:00:00 2001 From: "Petter A. Urkedal" Date: Fri, 6 Sep 2024 10:06:31 +0200 Subject: [PATCH] Add CI based testing, with related fix. Fix missing version for the dune dependency. --- .github/workflows/workflow.yml | 78 ++++++++++++++++++++++++++++++++++ mariadb.opam | 2 +- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/workflow.yml diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..6b1eb05 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -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 diff --git a/mariadb.opam b/mariadb.opam index 373c5d4..965f243 100644 --- a/mariadb.opam +++ b/mariadb.opam @@ -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}