Skip to content

Commit 161b7cb

Browse files
Alexander Kharkoveyklerick
authored andcommitted
chore(json-api-nestjs): add ci/cd utils
1 parent 160ab51 commit 161b7cb

File tree

6 files changed

+23209
-13046
lines changed

6 files changed

+23209
-13046
lines changed

.github/workflows/CI.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
env:
7+
BEFORE_SHA: ${{ github.event.before }}
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
node-version: [14.x]
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v1
21+
with:
22+
node-version: 14
23+
- uses: actions/cache@v2
24+
with:
25+
path: ~/.npm
26+
key: ${{ runner.os }}-node-${{ hashFiles('./package-lock.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-node-
29+
- name: Install dependencies
30+
run: npm ci
31+
- name: Test
32+
run: npm run nx affected:test -- --base=remotes/origin/master
33+
env:
34+
CI: true

.github/workflows/Release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- master
6+
env:
7+
BEFORE_SHA: ${{ github.event.before }}
8+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
10+
jobs:
11+
release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v1
21+
with:
22+
node-version: 14
23+
- uses: actions/cache@v2
24+
with:
25+
path: ~/.npm
26+
key: ${{ runner.os }}-node-${{ hashFiles('./package-lock.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-node-
29+
- name: Install dependencies
30+
run: npm ci
31+
- name: Test
32+
run: |
33+
npm run nx run-many -- --target=test --all --code-coverage --coverage --reporters=default --reporters=default --coverageReporters=cobertura,html,json
34+
SUMMARY=$(node ./tools/utils/merge-codecoverage/index.js | grep "All files" | awk '{print $4}')
35+
echo "COVERAGE=$(echo ${SUMMARY})" >> $GITHUB_ENV
36+
- name: Cretae Badge
37+
uses: schneegans/dynamic-badges-action@v1.0.0
38+
with:
39+
auth: ${{ secrets.GIST_SECRET }}
40+
gistID: ${{ secrets.GIST_ID }}
41+
filename: coverage-json-api.json
42+
label: Test Coverage
43+
message: ${{ env.COVERAGE }}
44+
color: green
45+
namedLogo: jest
46+
- name: Deploy
47+
run: npm run nx affected -- --target=deploy --base=$BEFORE_SHA
48+

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

libs/json-api-nestjs/project.json

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,39 @@
44
"sourceRoot": "libs/json-api-nestjs/src",
55
"projectType": "library",
66
"targets": {
7+
"deploy": {
8+
"executor": "@ng-builders/semrel:release",
9+
"dependsOn": [{ "projects": "self", "target": "release" }],
10+
"options": {
11+
"npm": {
12+
"pkgRoot": "./dist/libs/json-api-nestjs"
13+
}
14+
}
15+
},
16+
"release": {
17+
"executor": "nx:run-commands",
18+
"dependsOn": [{ "projects": "self", "target": "build" }],
19+
"options": {
20+
"commands": [
21+
"echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}'>./dist/libs/json-api-nestjs/.npmrc"
22+
],
23+
"cwd": "./",
24+
"parallel": false
25+
}
26+
},
727
"build": {
828
"executor": "@nrwl/js:tsc",
9-
"outputs": ["{options.outputPath}"],
29+
"outputs": [
30+
"{options.outputPath}"
31+
],
1032
"options": {
1133
"outputPath": "dist/libs/json-api-nestjs",
1234
"tsConfig": "libs/json-api-nestjs/tsconfig.lib.json",
1335
"packageJson": "libs/json-api-nestjs/package.json",
1436
"main": "libs/json-api-nestjs/src/index.ts",
15-
"assets": ["libs/json-api-nestjs/*.md"]
37+
"assets": [
38+
"libs/json-api-nestjs/*.md"
39+
]
1640
}
1741
},
1842
"publish": {
@@ -29,14 +53,20 @@
2953
},
3054
"lint": {
3155
"executor": "@nrwl/linter:eslint",
32-
"outputs": ["{options.outputFile}"],
56+
"outputs": [
57+
"{options.outputFile}"
58+
],
3359
"options": {
34-
"lintFilePatterns": ["libs/json-api-nestjs/**/*.ts"]
60+
"lintFilePatterns": [
61+
"libs/json-api-nestjs/**/*.ts"
62+
]
3563
}
3664
},
3765
"test": {
3866
"executor": "@nrwl/jest:jest",
39-
"outputs": ["coverage/libs/json-api-nestjs"],
67+
"outputs": [
68+
"coverage/libs/json-api-nestjs"
69+
],
4070
"options": {
4171
"jestConfig": "libs/json-api-nestjs/jest.config.ts",
4272
"passWithNoTests": true

0 commit comments

Comments
 (0)