Skip to content

Commit 958d9be

Browse files
committed
ci: Debug ci
1 parent e2a6ecb commit 958d9be

File tree

7 files changed

+98
-11
lines changed

7 files changed

+98
-11
lines changed

.github/workflows/bump-version.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ jobs:
1515
fetch-depth: 0
1616
- name: Npm install
1717
uses: ./.github/actions
18-
- run: npx nx affected -t test build --parallel=3 --exclude='json-api-front,json-api-server,json-api-server-e2e,json-shared-type,database,@nestjs-json-api/source' --base=origin/master
18+
- run: npx nx affected -t test build upload-badge --parallel=3 --exclude='json-api-front,json-api-server,json-api-server-e2e,json-shared-type,database,@nestjs-json-api/source' --base=origin/master
19+
env:
20+
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
NPM_CONFIG_PROVENANCE: true
1923
# - run: npm nx affected -t e2e-ci --parallel=1
2024
# - run: npm nx affected -t deploy --no-agents
2125

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
<p align='center'>
2-
<a href="https://www.npmjs.com/package/json-api-nestjs" target="_blank"><img src="https://img.shields.io/npm/v/json-api-nestjs.svg" alt="NPM Version" /></a>
3-
<a href="https://www.npmjs.com/package/json-api-nestjs" target="_blank"><img src="https://img.shields.io/npm/l/json-api-nestjs.svg" alt="Package License" /></a>
4-
<a href="https://www.npmjs.com/package/json-api-nestjs" target="_blank"><img src="https://img.shields.io/npm/dm/json-api-nestjs.svg" alt="NPM Downloads" /></a>
5-
<a href="http://commitizen.github.io/cz-cli/" target="_blank"><img src="https://img.shields.io/badge/commitizen-friendly-brightgreen.svg" alt="Commitizen friendly" /></a>
6-
<img src="https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/klerick/397d521f54660656f2fd6195ec482581/raw/coverage-json-api.json" alt="Coverage Badge" />
7-
</p>
8-
91
<p align="center">
102
Json API plugins for
113
<a href="http://nestjs.com/" target="blank">NestJS</a>

libs/json-api/json-api-nestjs-sdk/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<p align='center'>
2+
<a href="https://www.npmjs.com/package/json-api-nestjs-sdk" target="_blank"><img src="https://img.shields.io/npm/v/json-api-nestjs-sdk.svg" alt="NPM Version" /></a>
3+
<a href="https://www.npmjs.com/package/json-api-nestjs-sdk" target="_blank"><img src="https://img.shields.io/npm/l/json-api-nestjs-sdk.svg" alt="Package License" /></a>
4+
<a href="https://www.npmjs.com/package/json-api-nestjs-sdk" target="_blank"><img src="https://img.shields.io/npm/dm/json-api-nestjs-sdk.svg" alt="NPM Downloads" /></a>
5+
<a href="http://commitizen.github.io/cz-cli/" target="_blank"><img src="https://img.shields.io/badge/commitizen-friendly-brightgreen.svg" alt="Commitizen friendly" /></a>
6+
<img src="https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/klerick/397d521f54660656f2fd6195ec482581/raw/coverage-json-api.json" alt="Coverage Badge" />
7+
</p>
8+
19
# json-api-nestjs-sdk
210

311
The plugin of Angular for help work with JSON API over [json-api-nestjs](https://www.npmjs.com/package/json-api-nestjs)

libs/json-api/json-api-nestjs-sdk/project.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,25 @@
6666
"executor": "@nx/jest:jest",
6767
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
6868
"options": {
69-
"jestConfig": "libs/json-api/json-api-nestjs-sdk/jest.config.ts"
69+
"jestConfig": "libs/json-api/json-api-nestjs-sdk/jest.config.ts",
70+
"codeCoverage": true,
71+
"coverageReporters": ["json-summary"]
72+
}
73+
},
74+
"upload-badge": {
75+
"executor": "nx:run-commands",
76+
"dependsOn": [
77+
{
78+
"target": "test"
79+
}
80+
],
81+
"options": {
82+
"outputPath": "libs/json-api/json-api-nestjs-sdk",
83+
"commands": [
84+
"node tools/scripts/upload-badge.mjs json-api-nestjs-sdk"
85+
],
86+
"cwd": "./",
87+
"parallel": false
7088
}
7189
}
7290
},

libs/json-api/json-api-nestjs/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<p align='center'>
2+
<a href="https://www.npmjs.com/package/json-api-nestjs" target="_blank"><img src="https://img.shields.io/npm/v/json-api-nestjs.svg" alt="NPM Version" /></a>
3+
<a href="https://www.npmjs.com/package/json-api-nestjs" target="_blank"><img src="https://img.shields.io/npm/l/json-api-nestjs.svg" alt="Package License" /></a>
4+
<a href="https://www.npmjs.com/package/json-api-nestjs" target="_blank"><img src="https://img.shields.io/npm/dm/json-api-nestjs.svg" alt="NPM Downloads" /></a>
5+
<a href="http://commitizen.github.io/cz-cli/" target="_blank"><img src="https://img.shields.io/badge/commitizen-friendly-brightgreen.svg" alt="Commitizen friendly" /></a>
6+
<img src="https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/klerick/397d521f54660656f2fd6195ec482581/raw/coverage-json-api.json" alt="Coverage Badge" />
7+
</p>
8+
19
# json-api-nestjs
210

311
This plugin works upon TypeOrm library, which is used as the main database abstraction layer tool. The module

libs/json-api/json-api-nestjs/project.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,25 @@
3030
"executor": "@nx/jest:jest",
3131
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
3232
"options": {
33-
"jestConfig": "libs/json-api/json-api-nestjs/jest.config.ts"
33+
"jestConfig": "libs/json-api/json-api-nestjs/jest.config.ts",
34+
"codeCoverage": true,
35+
"coverageReporters": ["json-summary"]
36+
}
37+
},
38+
"upload-badge": {
39+
"executor": "nx:run-commands",
40+
"dependsOn": [
41+
{
42+
"target": "test"
43+
}
44+
],
45+
"options": {
46+
"outputPath": "libs/json-api/json-api-nestjs-sdk",
47+
"commands": [
48+
"node tools/scripts/upload-badge.mjs json-api-nestjs"
49+
],
50+
"cwd": "./",
51+
"parallel": false
3452
}
3553
}
3654
},

tools/scripts/upload-badge.mjs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { readFileSync, writeFileSync, renameSync, unlinkSync } from 'fs';
2+
import { sep, join } from 'path';
3+
4+
import devkit from '@nx/devkit';
5+
6+
const COVERAGE = 'coverage'
7+
const { readCachedProjectGraph } = devkit;
8+
9+
const [, , name] = process.argv;
10+
11+
const graph = readCachedProjectGraph();
12+
const project = graph.nodes[name];
13+
14+
const outputPath = project.data?.targets['upload-badge']?.options?.outputPath;
15+
16+
17+
process.chdir(join(COVERAGE, outputPath));
18+
19+
const coverage = JSON.parse(readFileSync('coverage-summary.json').toString())
20+
const percentage = coverage['total']['statements']['pct'];
21+
22+
const filename = name
23+
const content = {"schemaVersion":1,"label":"Test Coverage","message":`${percentage}%`,"color":"green","namedLogo":"jest"}
24+
const body = JSON.stringify({ files: { [filename]: { content } } });
25+
26+
const gistUrl = new URL('397d521f54660656f2fd6195ec482581', 'https://api.github.com/gists/');
27+
const headers = new Headers([
28+
["Content-Type", "application/json"],
29+
["Content-Length", new TextEncoder().encode(body).length],
30+
["User-Agent", "Schneegans"],
31+
["Authorization", `token ${process.env['GITHUB_TOKEN']}`],
32+
]);
33+
fetch(gistUrl, {
34+
method: "POST",
35+
headers,
36+
body,
37+
}).then(r => r.json()).then(r => console.log(r));
38+
39+

0 commit comments

Comments
 (0)