Skip to content

Commit

Permalink
feat: migrate to CircleCI for unique project pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
dkontorovskyy committed Apr 22, 2020
1 parent 34922d7 commit 4905b6e
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 100 deletions.
171 changes: 159 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ orbs:
win: circleci/windows@2.2.0

defaults: &defaults
environment:
npm_config_loglevel: silent
parameters:
node_version:
type: string
default: ""
working_directory: ~/snyk

windows_defaults: &windows_defaults
environment:
npm_config_loglevel: silent
executor:
name: win/default
working_directory: ~/snyk

commands:
install_deps:
Expand All @@ -36,10 +38,15 @@ commands:
root: .
paths:
- dist/
install_maven:
install_maven_windows:
description: Install maven
steps:
- run: choco install maven
install_maven_unix:
description: Install maven
steps:
- run: sudo apt update
- run: sudo apt install -y maven
install_node_npm:
description: Install correct Node version
parameters:
Expand All @@ -64,11 +71,40 @@ commands:
command: npm --version

jobs:
test-all:
common:
<<: *defaults
docker:
- image: circleci/node:<< parameters.node_version >>
steps:
- show_node_version
- checkout
- attach_workspace:
at: ~/snyk
- install_deps
- build_ts
- run:
name: Run auth
command: npm run snyk-auth
- run:
name: Run tests
command: npm run test:common

danger:
<<: *defaults
docker:
- image: circleci/node:<< parameters.node_version >>
steps:
- checkout
- run:
name: Danger Zone
command: npx danger ci --failOnErrors

test-windows:
<<: *defaults
<<: *windows_defaults
steps:
- run: git config --global core.autocrlf false
- install_maven
- install_maven_windows
- install_node_npm:
node_version: << parameters.node_version >>
- show_node_version
Expand All @@ -86,19 +122,130 @@ jobs:
- run:
name: Run tests
command: npm run test-windows

test-unix:
<<: *defaults
docker:
- image: circleci/node:<< parameters.node_version >>
steps:
- install_maven_unix
- show_node_version
- checkout
- attach_workspace:
at: ~/snyk
- install_deps
- build_ts
- run:
name: npm version
command: npm --version
- run:
name: Run auth
command: npm run snyk-auth
- run:
name: Run tests
command: npm run test:test

release:
<<: *defaults
docker:
- image: circleci/node:<< parameters.node_version >>
resource_class: small
steps:
- install_deps
- run:
name: Publish to GitHub
command: npx semantic-release

workflows:
version: 2
test_and_release:
jobs:
- test-all:
name: Test Node v12
- common:
name: Common
context: nodejs-install
node_version: "8"
filters:
branches:
ignore:
- master
- danger:
name: Danger Zone
node_version: "8"
filters:
branches:
ignore:
- master
- test-windows:
name: Windows Tests for Node v12 support
context: nodejs-install
node_version: "12.0.0"
- test-all:
name: Test Node v10
requires:
- Common
- Danger Zone
filters:
branches:
ignore:
- master
- test-windows:
name: Windows Tests for Node v10 support
context: nodejs-install
node_version: "10.0.0"
- test-all:
name: Test Node v8
requires:
- Common
- Danger Zone
filters:
branches:
ignore:
- master
- test-windows:
name: Windows Tests for Node v8 support
context: nodejs-install
node_version: "8.17.0"
requires:
- Common
- Danger Zone
filters:
branches:
ignore:
- master
- test-unix:
name: Unix Tests for Node v12 support
context: nodejs-install
node_version: "12"
requires:
- Common
- Danger Zone
filters:
branches:
ignore:
- master
- test-unix:
name: Unix Tests for Node v10 support
context: nodejs-install
node_version: "10"
requires:
- Common
- Danger Zone
filters:
branches:
ignore:
- master
- test-unix:
name: Unix Tests for Node v8 support
context: nodejs-install
node_version: "8"
requires:
- Common
- Danger Zone
filters:
branches:
ignore:
- master
- release:
name: Release
context: nodejs-app-release
node_version: "10"
filters:
branches:
only:
- master
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
"find-circular": "npm run build && madge --circular ./dist",
"format": "prettier --write '{src,test,scripts}/**/*.{js,ts}'",
"prepare": "npm run build",
"test:common": "npm run check-tests && npm run build && npm run lint && node --require ts-node/register src/cli test --org=snyk",
"test:common": "npm run check-tests && npm run lint && node --require ts-node/register src/cli test --org=snyk",
"test:acceptance": "tap test/acceptance/**/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register",
"test:system": "tap test/system/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register",
"test:test": "tap test/*.test.* -Rspec --timeout=300 --node-arg=-r --node-arg=ts-node/register",
"test": "npm run test:common && npm run test:acceptance && npm run test:system && npm run test:test",
"test": "npm run test:acceptance && npm run test:system && npm run test:test",
"test-windows": "npm run test:acceptance && npm run test:system && npm run test:test",
"lint": "run-p --aggregate-output lint:*",
"lint:js": "eslint --color --cache 'src/**/*.{js,ts}'",
Expand Down
26 changes: 0 additions & 26 deletions scripts/check_circleci_status.sh

This file was deleted.

14 changes: 0 additions & 14 deletions scripts/travis_after_success.sh

This file was deleted.

20 changes: 18 additions & 2 deletions test/acceptance/cli-test/cli-test.all-projects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const AllProjectsTests: AcceptanceTests = {
utils.chdirWorkspaces();

// mock python plugin becuase CI tooling doesn't have pipenv installed
const mockPlugin = {
const mockPipfile = {
async inspect() {
return {
plugin: {
Expand All @@ -114,12 +114,28 @@ export const AllProjectsTests: AcceptanceTests = {
};
},
};
const mockRequirements = {
async inspect() {
return {
plugin: {
targetFile: 'python-app-with-req-file/requirements.txt',
name: 'snyk-python-plugin',
},
package: {},
};
},
};
const loadPlugin = sinon.stub(params.plugins, 'loadPlugin');
t.teardown(loadPlugin.restore);
// detect pip plugin called only with Pipfile (and not requirement.txt)
loadPlugin
.withArgs('pip', sinon.match.has('file', 'Pipfile'))
.returns(mockPlugin);
.returns(mockPipfile)
.withArgs(
'pip',
sinon.match.has('file', 'python-app-with-req-file/requirements.txt'),
)
.returns(mockRequirements);
loadPlugin.callThrough(); // don't mock other plugins

const result = await params.cli.test('mono-repo-project', {
Expand Down
Loading

0 comments on commit 4905b6e

Please sign in to comment.