diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99ca46b..4a6d4f0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,14 +18,11 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: Start docker-compose - run: docker-compose up -d - - name: Install dependencies run: npm install - name: Run tests - run: npm test + run: npm run test:docker lint: uses: adonisjs/.github/.github/workflows/lint.yml@main diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..95a18f1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM node:20-alpine as build-deps + +RUN apk update && apk upgrade && \ + apk add --update git && \ + apk add --update openssh && \ + apk add --update bash && \ + apk add --update wget + +ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait /wait +RUN chmod +x /wait + +WORKDIR /usr/src/app + +COPY package*.json ./ +RUN npm install + +COPY . . diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml new file mode 100644 index 0000000..9138887 --- /dev/null +++ b/docker-compose.ci.yml @@ -0,0 +1,22 @@ +version: '3.4' +services: + tests: + image: adonis-redis + network_mode: host + build: + context: . + environment: + REDIS_HOST: 0.0.0.0 + REDIS_PORT: 7007 + REDIS_CLUSTER_PORTS: '7000,7001,7002' + WAIT_HOSTS: 0.0.0.0:7000, 0.0.0.0:7001, 0.0.0.0:7002, 0.0.0.0:7003, 0.0.0.0:7004, 0.0.0.0:7005, 0.0.0.0:7006, 0.0.0.0:7007 + depends_on: + - redis + command: sh -c "/wait && FORCE_COLOR=true npm run test" + redis: + network_mode: host + image: grokzen/redis-cluster + environment: + REDIS_CLUSTER_IP: 0.0.0.0 + IP: 0.0.0.0 + STANDALONE: 'true' diff --git a/package.json b/package.json index 63de13b..fa908c8 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "scripts": { "pretest": "npm run lint", "test": "c8 npm run quick:test", + "test:docker": "docker-compose -f docker-compose.ci.yml run --rm tests", "quick:test": "node --enable-source-maps --loader=ts-node/esm ./bin/test.ts", "clean": "del-cli build", "copy:templates": "copyfiles \"stubs/**/**/*.stub\" build",