From 1897dab6e1a8ce4ee453e51f70f6aae0091ca476 Mon Sep 17 00:00:00 2001 From: Nathan Curtis Date: Mon, 16 Sep 2024 16:03:50 -0700 Subject: [PATCH] [TM-1271] Set up lint / test / build CI action --- .github/workflows/{ci.yml => pull-request.yml} | 15 ++++++++++----- README.md | 3 +++ docker-compose.yml | 15 +++++++++++++++ docker/mariadb.Dockerfile | 3 +++ docker/override.cnf | 10 ++++++++++ 5 files changed, 41 insertions(+), 5 deletions(-) rename .github/workflows/{ci.yml => pull-request.yml} (57%) create mode 100644 docker-compose.yml create mode 100644 docker/mariadb.Dockerfile create mode 100644 docker/override.cnf diff --git a/.github/workflows/ci.yml b/.github/workflows/pull-request.yml similarity index 57% rename from .github/workflows/ci.yml rename to .github/workflows/pull-request.yml index a4d6a76..b8c2665 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/pull-request.yml @@ -15,10 +15,18 @@ jobs: with: fetch-depth: 0 + - uses: KengoTODA/actions-setup-docker-compose@v1 + with: + version: '2.29.1' + # This enables task distribution via Nx Cloud # Run this command as early as possible, before dependencies are installed # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun - - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="build" + # Note: this isn't currently working with this repo and distribution just isn't that necessary + # yet, with such a small codebase. + # - run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="build" + + - run: docker-compose up -d # Cache node_modules - uses: actions/setup-node@v4 @@ -29,7 +37,4 @@ jobs: - run: npm ci --legacy-peer-deps - uses: nrwl/nx-set-shas@v4 - # Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud - # - run: npx nx-cloud record -- echo Hello World - # Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected - - run: npx nx affected -t lint test build + - run: npx nx affected -t lint 'test --coverage --passWithNoTests' build diff --git a/README.md b/README.md index fdce0d1..b682664 100644 --- a/README.md +++ b/README.md @@ -38,3 +38,6 @@ schema: // test runs (the only time we let TypeORM modify the DB schema). ``` +This codebase connects to the database running in the `wri-terramatch-api` docker container. The docker-compose +file included in this repo is used only for setting up the database needed for running unit tests in Github Actions. + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3f99ac5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +version: "3" +services: + mariadb: + build: + context: "." + dockerfile: "docker/mariadb.Dockerfile" + ports: + - "3360:3306" + networks: + - "default" + environment: + MYSQL_ROOT_PASSWORD: "root" + MYSQL_DATABASE: "terramatch_microservices_test" + MYSQL_USER: "wri" + MYSQL_PASSWORD: "wri" diff --git a/docker/mariadb.Dockerfile b/docker/mariadb.Dockerfile new file mode 100644 index 0000000..0301945 --- /dev/null +++ b/docker/mariadb.Dockerfile @@ -0,0 +1,3 @@ +# MARIADB +FROM mariadb:10.3 AS mariadb +COPY docker/override.cnf /etc/mysql/mariadb.conf.d/override.cnf diff --git a/docker/override.cnf b/docker/override.cnf new file mode 100644 index 0000000..4b75bb5 --- /dev/null +++ b/docker/override.cnf @@ -0,0 +1,10 @@ +[client] +default-character-set=utf8mb4 + +[mysql] +default-character-set=utf8mb4 + +[mysqld] +collation-server = utf8mb4_unicode_520_ci +init-connect='SET NAMES utf8mb4' +character-set-server = utf8mb4