diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f32691fe..cf1b7950 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,9 +22,9 @@ jobs: submodules: true - name: Build docker image - run: docker compose --file docker-compose.test.yml build + run: docker compose build - name: Run tests - run: docker compose --file docker-compose.test.yml run sut + run: docker compose run test scripts/test_and_cover.sh env: GITHUB_TOKEN: ${{ secrets.github_token }} diff --git a/Dockerfile b/Dockerfile index 14e4f47f..e22b9b6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -161,9 +161,6 @@ RUN cpanm --notest \ ENV SDRROOT /htapps/babel ENV ROOTDIR "${SDRROOT}/crms" - -RUN wget -O /usr/local/bin/wait-for https://github.com/eficode/wait-for/releases/download/v2.2.3/wait-for; chmod +x /usr/local/bin/wait-for - RUN mkdir -p $ROOTDIR COPY . $ROOTDIR WORKDIR $ROOTDIR diff --git a/Makefile.PL b/Makefile.PL deleted file mode 100755 index 006e8da2..00000000 --- a/Makefile.PL +++ /dev/null @@ -1,11 +0,0 @@ -use strict; -use warnings; -use ExtUtils::MakeMaker; - -my ($mm) = $ExtUtils::MakeMaker::VERSION =~ /^([^_]+)/; - -WriteMakefile( - NAME => 'CRMS', - VERSION_FROM => 'lib/CRMS/Version.pm', - test => {RECURSIVE_TEST_FILES => 1} -); diff --git a/README.md b/README.md index b0b1e5f2..298fad3c 100644 --- a/README.md +++ b/README.md @@ -12,18 +12,13 @@ A web app and suite of tools for performing copyright review projects. git submodule init git submodule update docker compose build -docker compose up -d mariadb +docker compose up -d mariadb mariadb-ht docker compose run --rm test ``` -## Running Tests with Coverage - -``` -scripts/cover.sh -``` - -The other coverage script -- `scripts/test_and_cover.sh` -- is used by GitHub actions -to upload results to Coveralls. +By default the `test` service produces a `Devel::Cover` HTML report using +`scripts/test.sh`. The other script, `scripts/test_and_cover.sh`, is for upload to +Coveralls and is used in the GitHub action. ## What is Where @@ -32,7 +27,7 @@ to upload results to Coveralls. - `docker` Database seeds - `lib` Perl modules (new development and refactored modules from `cgi`) - `prep` Destination for some log files and reports -- `scripts` Binaries run as part of development or by GitHub +- `scripts` Testing wrappers run as part of development or by GitHub - `t` Tests - `web` Static assets including images, JS, CSS diff --git a/docker-compose.test.yml b/docker-compose.test.yml deleted file mode 100644 index aed432f2..00000000 --- a/docker-compose.test.yml +++ /dev/null @@ -1,41 +0,0 @@ -version: '3' - -services: - - mariadb: - build: docker/db - restart: always - environment: - MYSQL_RANDOM_ROOT_PASSWORD: 1 - ports: - - 3306:3306 - - mariadb_ht: - image: ghcr.io/hathitrust/db-image:latest - restart: always - environment: - MYSQL_RANDOM_ROOT_PASSWORD: 1 - ports: - - 3307:3306 - - sut: - build: . - volumes: - - .:/htapps/babel/crms - environment: - - SDRROOT=/htapps/babel - - CRMS_DB_HOST=mariadb - - CRMS_DB_HOST_DEVELOPMENT=mariadb - - CRMS_HT_DB_HOST=mariadb_ht - # pass through info needed by coveralls uploader - - GITHUB_TOKEN - - GITHUB_RUN_ID - - GITHUB_EVENT_TOKEN - - GITHUB_EVENT_PATH - - GITHUB_SHA - - GITHUB_REF - - GITHUB_ACTIONS - depends_on: - - mariadb - - mariadb_ht - command: scripts/test_and_cover.sh diff --git a/docker-compose.yml b/docker-compose.yml index 8063b122..8177f0b4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,13 @@ -version: '3' +--- + +x-condition-healthy: &healthy + condition: service_healthy + +x-healthcheck-defaults: &healthcheck-defaults + interval: 5s + timeout: 10s + start_period: 10s + retries: 5 services: @@ -6,17 +15,23 @@ services: build: docker/db restart: always environment: - MYSQL_ROOT_PASSWORD: 'crms' + MYSQL_RANDOM_ROOT_PASSWORD: 1 ports: - 3306:3306 + healthcheck: + <<: *healthcheck-defaults + test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized" ] mariadb_ht: image: ghcr.io/hathitrust/db-image:latest restart: always environment: - MYSQL_ROOT_PASSWORD: 'crms' + MYSQL_RANDOM_ROOT_PASSWORD: 1 ports: - 3307:3306 + healthcheck: + <<: *healthcheck-defaults + test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized" ] test: build: . @@ -27,7 +42,15 @@ services: - CRMS_DB_HOST=mariadb - CRMS_DB_HOST_DEVELOPMENT=mariadb - CRMS_HT_DB_HOST=mariadb_ht + # pass through info needed by coveralls uploader + - GITHUB_TOKEN + - GITHUB_RUN_ID + - GITHUB_EVENT_TOKEN + - GITHUB_EVENT_PATH + - GITHUB_SHA + - GITHUB_REF + - GITHUB_ACTIONS depends_on: - - mariadb - - mariadb_ht + mariadb: *healthy + mariadb_ht: *healthy command: scripts/test.sh diff --git a/docker/db/Dockerfile b/docker/db/Dockerfile index 5038f22d..7cdeac25 100644 --- a/docker/db/Dockerfile +++ b/docker/db/Dockerfile @@ -1,4 +1,4 @@ -FROM mariadb:10.1 +FROM mariadb:10.11 # copy schema files inside COPY sql/* /docker-entrypoint-initdb.d/ diff --git a/scripts/cover.sh b/scripts/cover.sh deleted file mode 100755 index adfd326a..00000000 --- a/scripts/cover.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# This script doesn't do the wait-for song and dance so if there are sporadic database errors, -# try making sure the databases are fully up and running again. -docker compose run --rm test cover -ignore_re '^t/' +ignore_re '^post' -test -make 'prove -r t/; exit $?' diff --git a/scripts/test.sh b/scripts/test.sh index 3142d347..d84952cd 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,6 +1,3 @@ #!/bin/bash -perl /htapps/babel/crms/Makefile.PL -/usr/local/bin/wait-for --timeout=300 mariadb:3306 -/usr/local/bin/wait-for --timeout=30 mariadb_ht:3306 -make test TEST_VERBOSE=1 +cover -test -ignore_re '^t/' +ignore_re '^post' -report html -make 'prove -r t/; exit $?' diff --git a/scripts/test_and_cover.sh b/scripts/test_and_cover.sh index 74a73fac..466fcff9 100755 --- a/scripts/test_and_cover.sh +++ b/scripts/test_and_cover.sh @@ -1,5 +1,3 @@ #!/bin/bash -/usr/local/bin/wait-for --timeout=300 mariadb:3306 -/usr/local/bin/wait-for --timeout=30 mariadb_ht:3306 cover -test -ignore_re '^t/' +ignore_re '^post' -report Coveralls -make 'prove -r t/; exit $?'