Skip to content

Commit 48fc647

Browse files
ci() add npm install before integration tests and samples
ci() add npm install before integration tests and sampels ci() add machine option to integraiton tests ci() setup remote docker for integration tests ci() add unit tests mixin function ci() add unit tests mixin function ci() fix working directory for integration tests ci() rename unit tests function ci() use reusable run-unit-tests config ci() update naming, add coveralls ci() add alias for unit tests ci() add aliases (circleci) ci() remove run command from aliases ci() fix aliases ci(): fix restore cache alias ci() add list containers step to integration tests integration() bind urls and hosts to 0.0.0.0 ci() add waiting for mysql task ci() hotfix, move tasks order (integration) ci() wait for mysql - change hostname, increase sleep time ci() add sleep after docker-compose up (integration) ci() add sleep after docker-compose up fix (seconds) ci() switch to machine mode (integration tests) ci() use nvm to switch default node version ci() hotfix, wrong indentation (integration tests) ci() add ls-remove (nvm) and node version check ci() fix install npm task ci() wip use nvm to run integration tests ci() remove NPM upgrade task
1 parent 09c84e2 commit 48fc647

9 files changed

Lines changed: 106 additions & 25 deletions

File tree

.circleci/config.yml

Lines changed: 77 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
11
version: 2
2+
3+
aliases:
4+
- &restore-cache
5+
restore_cache:
6+
key: dependency-cache-{{ checksum "package.json" }}
7+
- &install-deps
8+
run:
9+
name: Install dependencies
10+
command: npm ci
11+
- &build-packages
12+
run:
13+
name: Build
14+
command: npm run build
15+
- &run-unit-tests
16+
run:
17+
name: Test
18+
command: npm run test
19+
20+
unit-tests-template: &unit-tests-template
21+
working_directory: ~/nest
22+
steps:
23+
- checkout
24+
- *restore-cache
25+
- *install-deps
26+
- *build-packages
27+
- *run-unit-tests
28+
229
jobs:
330
build:
431
working_directory: ~/nest
@@ -22,53 +49,72 @@ jobs:
2249
name: Build
2350
command: npm run build
2451

25-
test:
52+
test_node_12:
2653
working_directory: ~/nest
2754
docker:
2855
- image: circleci/node:12
2956
steps:
3057
- checkout
31-
- restore_cache:
32-
name: Restore node_modules cache
33-
key: dependency-cache-{{ checksum "package.json" }}
34-
- run:
35-
name: Install dependencies
36-
command: npm ci
37-
- run:
38-
name: Build (dev)
39-
command: npm run build
40-
- run:
41-
name: Test
42-
command: npm run test
58+
- *restore-cache
59+
- *install-deps
60+
- *build-packages
61+
- *run-unit-tests
4362
- run:
4463
name: Collect coverage
4564
command: npm run coverage
65+
- store_artifacts:
66+
path: coverage
67+
68+
test_node_10:
69+
<<: *unit-tests-template
70+
docker:
71+
- image: circleci/node:10
72+
73+
test_node_8:
74+
<<: *unit-tests-template
75+
docker:
76+
- image: circleci/node:8
4677

4778
lint:
4879
working_directory: ~/nest
4980
docker:
5081
- image: circleci/node:12
5182
steps:
5283
- checkout
53-
- restore_cache:
54-
name: Restore node_modules cache
55-
key: dependency-cache-{{ checksum "package.json" }}
56-
- run:
57-
name: Install dependencies
58-
command: npm ci
84+
- *restore-cache
85+
- *install-deps
5986
- run:
6087
name: Lint
6188
command: npm run lint
6289

6390
integration_tests:
6491
working_directory: ~/nest
65-
docker:
66-
- image: circleci/node:12
92+
machine: true
6793
steps:
6894
- checkout
95+
- run:
96+
name: Upgrade Node.js
97+
command: |
98+
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
99+
echo ' [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
100+
nvm install v12
101+
node -v
102+
nvm alias default v12
103+
- run:
104+
name: Install Docker Compose
105+
command: |
106+
curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
107+
chmod +x ~/docker-compose
108+
sudo mv ~/docker-compose /usr/local/bin/docker-compose
109+
- *install-deps
69110
- run:
70111
name: Prepare tests
71-
command: bash ./scripts/prepare.sh
112+
command: |
113+
bash ./scripts/prepare.sh
114+
sleep 10
115+
- run:
116+
name: List containers
117+
command: docker ps
72118
- run:
73119
name: Integration tests
74120
command: npm run integration-test
@@ -79,6 +125,8 @@ jobs:
79125
- image: circleci/node:12
80126
steps:
81127
- checkout
128+
- *restore-cache
129+
- *install-deps
82130
- run:
83131
name: Build all samples
84132
command: npm run build:samples
@@ -88,7 +136,13 @@ workflows:
88136
build-and-test:
89137
jobs:
90138
- build
91-
- test:
139+
- test_node_12:
140+
requires:
141+
- build
142+
- test_node_10:
143+
requires:
144+
- build
145+
- test_node_8:
92146
requires:
93147
- build
94148
- lint:

integration/microservices/e2e/broadcast-mqtt.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ describe('MQTT transport', () => {
1818

1919
app.connectMicroservice({
2020
transport: Transport.MQTT,
21+
options: {
22+
host: '0.0.0.0',
23+
},
2124
});
2225
app.connectMicroservice({
2326
transport: Transport.MQTT,
27+
options: {
28+
host: '0.0.0.0',
29+
},
2430
});
2531
await app.startAllMicroservicesAsync();
2632
await app.init();

integration/microservices/e2e/broadcast-nats.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ describe('NATS transport', () => {
1818

1919
app.connectMicroservice({
2020
transport: Transport.NATS,
21+
options: {
22+
url: 'nats://0.0.0.0:4222',
23+
},
2124
});
2225
app.connectMicroservice({
2326
transport: Transport.NATS,
27+
options: {
28+
url: 'nats://0.0.0.0:4222',
29+
},
2430
});
2531
await app.startAllMicroservicesAsync();
2632
await app.init();

integration/microservices/e2e/broadcast-redis.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ describe('REDIS transport', () => {
1818

1919
app.connectMicroservice({
2020
transport: Transport.REDIS,
21+
options: {
22+
url: 'redis://0.0.0.0:6379',
23+
},
2124
});
2225
app.connectMicroservice({
2326
transport: Transport.REDIS,
27+
options: {
28+
url: 'redis://0.0.0.0:6379',
29+
},
2430
});
2531
await app.startAllMicroservicesAsync();
2632
await app.init();

integration/microservices/e2e/sum-mqtt.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ describe('MQTT transport', () => {
1919

2020
app.connectMicroservice({
2121
transport: Transport.MQTT,
22+
options: {
23+
url: 'mqtt://0.0.0.0:1883',
24+
},
2225
});
2326
await app.startAllMicroservicesAsync();
2427
await app.init();

integration/microservices/e2e/sum-nats.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('NATS transport', () => {
2020
app.connectMicroservice({
2121
transport: Transport.NATS,
2222
options: {
23-
url: 'nats://localhost:4222',
23+
url: 'nats://0.0.0.0:4222',
2424
},
2525
});
2626
await app.startAllMicroservicesAsync();

integration/microservices/e2e/sum-redis.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ describe('REDIS transport', () => {
1919

2020
app.connectMicroservice({
2121
transport: Transport.REDIS,
22+
options: {
23+
url: 'redis://0.0.0.0:6379',
24+
},
2225
});
2326
await app.startAllMicroservicesAsync();
2427
await app.init();

integration/microservices/e2e/sum-rmq.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('RabbitMQ transport', () => {
2020
app.connectMicroservice({
2121
transport: Transport.RMQ,
2222
options: {
23-
urls: [`amqp://localhost:5672`],
23+
urls: [`amqp://0.0.0.0:5672`],
2424
queue: 'test',
2525
queueOptions: { durable: false },
2626
socketOptions: { noDelay: true },

integration/microservices/e2e/sum-rpc.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ describe('RPC transport', () => {
2020

2121
app.connectMicroservice({
2222
transport: Transport.TCP,
23+
options: {
24+
host: '0.0.0.0',
25+
},
2326
});
2427
await app.startAllMicroservicesAsync();
2528
await app.init();

0 commit comments

Comments
 (0)