Skip to content

Commit 1de1c77

Browse files
authored
fix: parallelize unit and system tests in circleci (CN-940) (#775)
* fix: add separate test:unit and test:system steps * fix: moved tests to system * fix: updated import paths * fix: update resource class to medium to fix OOM
1 parent 562ae18 commit 1de1c77

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

.circleci/config.yml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,30 @@ jobs:
132132
- attach_workspace:
133133
at: ~/snyk-docker-plugin
134134
- run: npm run lint
135-
test:
135+
test_unit:
136+
<<: *defaults
137+
resource_class: medium
138+
steps:
139+
- checkout
140+
- attach_workspace:
141+
at: ~/snyk-docker-plugin
142+
- run: npm run test:unit > test-unit-logs.txt 2>&1
143+
- store_artifacts:
144+
path: test-unit-logs.txt
145+
destination: test-unit-logs
146+
test_system:
136147
<<: *defaults
137148
steps:
138149
- checkout
139150
- setup_remote_docker
140151
- attach_workspace:
141152
at: ~/snyk-docker-plugin
142-
- run: npm run test-jest > test-logs.txt 2>&1
153+
- run:
154+
command: npm run test:system > test-system-logs.txt 2>&1
155+
no_output_timeout: 20m
143156
- store_artifacts:
144-
path: test-logs.txt
145-
destination: test-logs
157+
path: test-system-logs.txt
158+
destination: test-system-logs
146159
test_jest_windows_with_docker:
147160
<<: *windows_big
148161
steps:
@@ -252,8 +265,17 @@ workflows:
252265
context: infrasec_container
253266
post-steps:
254267
- *slack-fail-notify
255-
- test:
256-
name: Test
268+
- test_unit:
269+
name: Unit Test
270+
context:
271+
- nodejs-install
272+
- snyk-bot-slack
273+
requires:
274+
- Build
275+
post-steps:
276+
- *slack-fail-notify
277+
- test_system:
278+
name: System Test
257279
context:
258280
- nodejs-install
259281
- snyk-bot-slack
@@ -303,7 +325,8 @@ workflows:
303325
- Lint
304326
- Build
305327
- Security Scans
306-
- Test
328+
- Unit Test
329+
- System Test
307330
- Test Jest Windows with Docker
308331
- Test Jest Windows no Docker
309332
post-steps:
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import * as tmp from "tmp";
44
import { v4 as uuidv4 } from "uuid";
55

66
import { DockerPullResult } from "@snyk/snyk-docker-pull";
7-
import * as plugin from "../../../lib";
8-
import * as imageInspector from "../../../lib/analyzer/image-inspector";
9-
import { ArchiveResult } from "../../../lib/analyzer/types";
10-
import { Docker } from "../../../lib/docker";
11-
import * as subProcess from "../../../lib/sub-process";
7+
import * as plugin from "../../lib";
8+
import * as imageInspector from "../../lib/analyzer/image-inspector";
9+
import { ArchiveResult } from "../../lib/analyzer/types";
10+
import { Docker } from "../../lib/docker";
11+
import * as subProcess from "../../lib/sub-process";
1212

1313
function rmdirRecursive(customPath: string[]): void {
1414
if (customPath.length < 2) {
@@ -118,7 +118,7 @@ describe("getImageArchive", () => {
118118
const dockerPullSpy = jest.spyOn(Docker.prototype, "pull");
119119
const loadImage = path.join(
120120
__dirname,
121-
"../../fixtures/docker-archives",
121+
"../fixtures/docker-archives",
122122
"docker-save/hello-world.tar",
123123
);
124124
await subProcess.execute("docker", ["load", "--input", loadImage]);

0 commit comments

Comments
 (0)