diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 63d9282..0cb880e 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -55,6 +55,18 @@ jobs: build: runs-on: ${{ inputs.runner }} + services: + mongodb: + # set empty image to disable service, as described in docs: + # https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idservicesservice_idimage + # todo: use ${{ inputs.db-version }} when mongodb fixes incompatibility with linux kernel + image: ${{ inputs.db-type == 'mongodb' && startsWith(inputs.runner, 'ubuntu') && 'mongo:8.2.12' || '' }} + # https://docs.docker.com/reference/cli/docker/container/create/#options + options: >- + --health-cmd "mongosh --quiet --eval \"db.adminCommand('ping')\" || exit 1" + ports: + - 27017:27017 + steps: - # https://github.com/actions/checkout name: Clone repository @@ -93,15 +105,6 @@ jobs: run: | ${{ inputs.db-version < 6 && 'mongo' || 'mongosh' }} --eval "db.version()" - - # on ubuntu we can simply use docker to set up mongodb - name: Set up MongoDB and check connection (ubuntu) - if: inputs.db-type == 'mongodb' && startsWith(inputs.runner, 'ubuntu') - # todo: revert to ${{ inputs.db-version }} once mongodb fixes incompatibility with linux kernel - # https://jira.mongodb.org/browse/SERVER-125742 - run: | - export MONGO_VERSION=8.2.12 - docker compose -f compose.mongo.yaml up -d - - # https://github.com/actions/setup-java name: Setup Java uses: actions/setup-java@v6 diff --git a/compose.mongo.yaml b/compose.mongo.yaml deleted file mode 100644 index 18b0802..0000000 --- a/compose.mongo.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# this file sets up mongodb for use in the maven-verify workflow -services: - mongo: - image: "mongo:${MONGO_VERSION}" - restart: no - ports: - - "127.0.0.1:27017:27017" - healthcheck: - test: | - [ $(mongosh --quiet --host localhost:27017 --eval "db.runCommand('ping').ok") = 1 ] || exit 1 - start_interval: 3s - start_period: 30s - mongosh: - image: alpine/mongosh - restart: no - depends_on: - mongo: - condition: service_healthy - command: - - mongosh - - --eval "db.version()"