Skip to content

Commit f81db3a

Browse files
Merge pull request #73 from Workable/add-test-workflow
Add test workflow
2 parents 1d4089e + f602690 commit f81db3a

4 files changed

Lines changed: 52 additions & 16 deletions

File tree

.github/workflows/test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Run tests
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
timeout-minutes: 10
10+
11+
strategy:
12+
matrix:
13+
node-version: [20.x, 22.x, 24.x]
14+
rabbit-version: [3.12.5, 4.2.1]
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v6
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v6
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
25+
- name: Start services
26+
run: docker compose up -d --wait
27+
env:
28+
RABBITMQ_VERSION: ${{ matrix.rabbit-version }}
29+
30+
- name: Run tests
31+
run: |
32+
npm install
33+
npm test
34+
35+
- name: Stop services
36+
if: always()
37+
run: docker compose down -v
38+

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ node_modules
33
coverage
44
typings
55
js
6-
.*
6+
.nyc_output

docker-compose.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
version: '2.2'
21
services:
3-
rabbit-queue:
4-
image: node:14
5-
working_dir: /code
6-
volumes:
7-
- .:/code
8-
links:
9-
- rabbit
10-
environment:
11-
RABBIT_URL: 'amqp://rabbit'
12-
rabbit:
13-
image: rabbitmq
2+
rabbitmq:
3+
image: rabbitmq:${RABBITMQ_VERSION:-4.1.2}-management
4+
container_name: rabbitmq
145
ports:
15-
- '5672:5672'
6+
- 5672:5672
7+
- 15672:15672
8+
healthcheck:
9+
test: rabbitmq-diagnostics -q ping
10+
timeout: 10s
11+
interval: 5s
12+
retries: 5
13+

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"prepublishOnly": "npm run build && npm run test-docker",
1717
"pretest": "tslint --project ./ts/ && tslint ./test/**/*.ts && npm run build",
1818
"test": "nyc mocha",
19-
"test-docker": "docker-compose run rabbit-queue npm run test",
20-
"prepare": "npm run build"
19+
"deps:up": "docker compose up -d --wait",
20+
"deps:down": "docker compose down"
2121
},
2222
"lint-staged": {
2323
"*.{ts,js}": [

0 commit comments

Comments
 (0)