From f602690290e55bfc881f1f099a5a21cb3b3b8403 Mon Sep 17 00:00:00 2001 From: Nikos Saravanos Date: Tue, 24 Feb 2026 15:44:35 +0200 Subject: [PATCH] add test workflow --- .github/workflows/test.yml | 38 ++++++++++++++++++++++++++++++++++++++ .gitignore | 2 +- docker-compose.yml | 24 +++++++++++------------- package.json | 4 ++-- 4 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..10d4409 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,38 @@ +name: Run tests + +on: + push: + +jobs: + build: + runs-on: ubuntu-latest + timeout-minutes: 10 + + strategy: + matrix: + node-version: [20.x, 22.x, 24.x] + rabbit-version: [3.12.5, 4.2.1] + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v6 + with: + node-version: ${{ matrix.node-version }} + + - name: Start services + run: docker compose up -d --wait + env: + RABBITMQ_VERSION: ${{ matrix.rabbit-version }} + + - name: Run tests + run: | + npm install + npm test + + - name: Stop services + if: always() + run: docker compose down -v + diff --git a/.gitignore b/.gitignore index 2310625..7c9a6be 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ node_modules coverage typings js -.* +.nyc_output diff --git a/docker-compose.yml b/docker-compose.yml index b11eff8..713a528 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,15 +1,13 @@ -version: '2.2' services: - rabbit-queue: - image: node:14 - working_dir: /code - volumes: - - .:/code - links: - - rabbit - environment: - RABBIT_URL: 'amqp://rabbit' - rabbit: - image: rabbitmq + rabbitmq: + image: rabbitmq:${RABBITMQ_VERSION:-4.1.2}-management + container_name: rabbitmq ports: - - '5672:5672' + - 5672:5672 + - 15672:15672 + healthcheck: + test: rabbitmq-diagnostics -q ping + timeout: 10s + interval: 5s + retries: 5 + diff --git a/package.json b/package.json index 6f1148b..1852937 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "prepublishOnly": "npm run build && npm run test-docker", "pretest": "tslint --project ./ts/ && tslint ./test/**/*.ts && npm run build", "test": "nyc mocha", - "test-docker": "docker-compose run rabbit-queue npm run test", - "prepare": "npm run build" + "deps:up": "docker compose up -d --wait", + "deps:down": "docker compose down" }, "lint-staged": { "*.{ts,js}": [