Skip to content

Commit

Permalink
CI cleanup (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
lfportal authored Jan 23, 2020
1 parent fcda68c commit 63a4895
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 78 deletions.
124 changes: 49 additions & 75 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,111 +1,85 @@
version: 2.1
job_configuration: &job_configuration
docker:
- image: circleci/node:10-stretch
working_directory: ~/repo
jobs:
build-and-test:
<<: *job_configuration
resource_class: xlarge

orbs:
node: circleci/[email protected]

executors:
node-executor:
docker:
- image: circleci/node:13-buster
working_directory: ~/repo

commands:
prepare-repository:
description: Convenience command to checkout the repository and install dependencies
steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v3-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v3-dependencies-

- run: yarn install --frozen-lockfile

- v3-dependencies
- run:
name: Install dependencies
command: yarn install --frozen-lockfile
- save_cache:
paths:
- node_modules
key: v3-dependencies-{{ checksum "package.json" }}

- run:
name: Run tests
command: yarn test

- run:
name: Compile
command: yarn pack

- run: ./bin/run --version

- run: ./bin/run --help

lint-check:
<<: *job_configuration
jobs:
test:
executor: node-executor
resource_class: xlarge
parallelism: 8
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: yarn lint:check
- prepare-repository
- node/with-splitting:
glob-path: lib/**/*.spec.ts
timings-type: classname
steps:
- run:
name: Run tests
command: yarn ci:test $TESTFILES
environment:
JEST_JUNIT_OUTPUT_DIR: ./test-reports/jest
JEST_JUNIT_OUTPUT_NAME: results.xml
JEST_JUNIT_CLASSNAME: "{filepath}"
- store_test_results:
path: ./test-reports

validate-contracts:
<<: *job_configuration
lint-check:
executor: node-executor
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: yarn build
- run: ./bin/run validate ./lib/src/validation-server/spots/api.ts
- prepare-repository
- run:
name: Run lint checker
command: yarn lint:check

publish:
<<: *job_configuration
executor: node-executor
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- prepare-repository
- run:
name: Authenticate with registry
name: Authenticate with NPM registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
- run:
- deploy:
name: Publish
command: |
npm publish --access=public
command: npm publish --access=public

workflows:
build-and-test:
jobs:
- build-and-test:
- test:
filters:
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
- lint-check:
filters:
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
- validate-contracts:
filters:
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
- publish:
requires:
- build-and-test
- test
- lint-check
filters:
tags:
Expand Down
5 changes: 5 additions & 0 deletions jest.ci.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
reporters: ["default", "jest-junit"]
};
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["**/?(*.)+(spec).ts"]
testMatch: ["**/?(*.)+(spec).ts"],
testPathIgnorePatterns: ["<rootDir>/node_modules/"]
};
7 changes: 7 additions & 0 deletions lib/src/validation-server/server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
recordedResponseToUserInputResponse,
runValidationServer
} from "./server";
import { parse } from "../parser";

const DUMMY_BODY = { dummy: "helloworld" };
const DUMMY_PORT = 5907;
Expand Down Expand Up @@ -143,6 +144,12 @@ describe("Validation Server", () => {
});
});
});

describe("SPOT contract", () => {
it("should be valid", () => {
expect(() => parse(`${__dirname}/spots/api.ts`)).not.toThrowError();
});
});
});

describe("Transformation functions", () => {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"css-loader": "^3.4.2",
"html-webpack-plugin": "^3.2.0",
"jest": "^24.9.0",
"jest-junit": "^10.0.0",
"mini-css-extract-plugin": "^0.9.0",
"mobx": "^5.15.2",
"nock": "^11.7.2",
Expand All @@ -60,7 +61,7 @@
"webpack-cli": "^3.3.10"
},
"engines": {
"node": ">=8.0.0"
"node": ">=12.0.0"
},
"files": [
"bin",
Expand Down Expand Up @@ -88,7 +89,8 @@
"build:watch": "tsc --watch",
"postpack": "rm -f oclif.manifest.json",
"prepack": "rm -rf build; tsc && oclif-dev manifest && yarn build-docs && oclif-dev readme",
"test": "jest -w 2 --testPathIgnorePatterns '<rootDir>/node_modules/'",
"test": "jest -w 4",
"ci:test": "jest --config=jest.ci.config.js --ci -w 4",
"lint:check": "yarn prettier:check && yarn tslint:check",
"tslint:check": "tslint -p .",
"prettier:check": "prettier --list-different \"**/*.js\" \"**/*.jsx\" \"**/*.ts\" \"**/*.tsx\"",
Expand Down
21 changes: 21 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4227,6 +4227,17 @@ jest-jasmine2@^24.9.0:
pretty-format "^24.9.0"
throat "^4.0.0"

jest-junit@^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/jest-junit/-/jest-junit-10.0.0.tgz#c94b91c24920a327c9d2a075e897b2dba4af494b"
integrity sha512-dbOVRyxHprdSpwSAR9/YshLwmnwf+RSl5hf0kCGlhAcEeZY9aRqo4oNmaT0tLC16Zy9D0zekDjWkjHGjXlglaQ==
dependencies:
jest-validate "^24.9.0"
mkdirp "^0.5.1"
strip-ansi "^5.2.0"
uuid "^3.3.3"
xml "^1.0.1"

jest-leak-detector@^24.9.0:
version "24.9.0"
resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-24.9.0.tgz#b665dea7c77100c5c4f7dfcb153b65cf07dcf96a"
Expand Down Expand Up @@ -7622,6 +7633,11 @@ uuid@^3.3.2:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.3.tgz#4568f0216e78760ee1dbf3a4d2cf53e224112866"
integrity sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==

uuid@^3.3.3:
version "3.4.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==

[email protected]:
version "2.0.3"
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.0.3.tgz#00f7494d2ae2b688cfe2899df6ed2c54bef91dbe"
Expand Down Expand Up @@ -7885,6 +7901,11 @@ xml-name-validator@^3.0.0:
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
integrity sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==

xml@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-2.0.0.tgz#52a63e56ca0b84a7f3a5f3d61872f126ad7a5943"
Expand Down

0 comments on commit 63a4895

Please sign in to comment.