Skip to content

Commit 83fcc84

Browse files
committed
setup Code PushUp
1 parent 33528ba commit 83fcc84

File tree

10 files changed

+11848
-8012
lines changed

10 files changed

+11848
-8012
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CP_API_KEY="cp_42858fd467d094364e7577a3daf8613258da53e77e0195dffbff66c300dcf2cb"

.github/workflows/code-pushup.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Code PushUp
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
actions: read
12+
pull-requests: write
13+
14+
env:
15+
CP_API_KEY: ${{ secrets.CP_API_KEY }}
16+
17+
jobs:
18+
code_pushup:
19+
runs-on: ubuntu-latest
20+
name: Code PushUp
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version-file: .nvmrc
29+
cache: npm
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Code PushUp
35+
uses: code-pushup/github-action@v0
36+
with:
37+
retention: 14

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ Thumbs.db
4242
.nx/workspace-data
4343

4444
.angular
45+
.env
46+
.code-pushup

apps/ng-demo-e2e/eslint.config.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
const playwright = require('eslint-plugin-playwright');
2-
const baseConfig = require('../../eslint.config.js');
1+
import tsESLint from 'typescript-eslint';
2+
import baseConfig from '../../eslint.config.js';
33

4-
module.exports = [
5-
playwright.configs['flat/recommended'],
6-
...baseConfig,
7-
{
8-
files: ['**/*.ts', '**/*.js'],
9-
// Override or add rules here
10-
rules: {},
4+
export default tsESLint.config(...baseConfig, {
5+
files: ['**/*.ts'],
6+
languageOptions: {
7+
parserOptions: {
8+
projectService: true,
9+
tsconfigRootDir: import.meta.dirname,
10+
},
1111
},
12-
];
12+
});

apps/ng-demo/eslint.config.js

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,19 @@
1-
const nx = require('@nx/eslint-plugin');
2-
const baseConfig = require('../../eslint.config.js');
1+
import angular from '@code-pushup/eslint-config/angular';
2+
import storybook from '@code-pushup/eslint-config/storybook';
3+
import tsESLint from 'typescript-eslint';
4+
import baseConfig from '../../eslint.config.js';
35

4-
module.exports = [
6+
export default tsESLint.config(
57
...baseConfig,
6-
...nx.configs['flat/angular'],
7-
...nx.configs['flat/angular-template'],
8+
...angular,
9+
...storybook,
810
{
911
files: ['**/*.ts'],
10-
rules: {
11-
'@angular-eslint/directive-selector': [
12-
'error',
13-
{
14-
type: 'attribute',
15-
prefix: 'app',
16-
style: 'camelCase',
17-
},
18-
],
19-
'@angular-eslint/component-selector': [
20-
'error',
21-
{
22-
type: 'element',
23-
prefix: 'app',
24-
style: 'kebab-case',
25-
},
26-
],
12+
languageOptions: {
13+
parserOptions: {
14+
projectService: true,
15+
tsconfigRootDir: import.meta.dirname,
16+
},
2717
},
28-
},
29-
{
30-
files: ['**/*.html'],
31-
// Override or add rules here
32-
rules: {},
33-
},
34-
];
18+
}
19+
);

code-pushup.config.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import coveragePlugin, {
2+
getNxCoveragePaths,
3+
} from '@code-pushup/coverage-plugin';
4+
import eslintPlugin, {
5+
eslintConfigFromAllNxProjects,
6+
} from '@code-pushup/eslint-plugin';
7+
import jsPackagesPlugin from '@code-pushup/js-packages-plugin';
8+
import { mergeConfigs } from '@code-pushup/utils';
9+
import type { CoreConfig } from '@code-pushup/models';
10+
import 'dotenv/config';
11+
12+
const esLintConfig: CoreConfig = {
13+
plugins: [await eslintPlugin(await eslintConfigFromAllNxProjects())],
14+
categories: [
15+
{
16+
slug: 'bug-prevention',
17+
title: 'Bug prevention',
18+
refs: [{ type: 'group', plugin: 'eslint', slug: 'problems', weight: 1 }],
19+
},
20+
{
21+
slug: 'code-style',
22+
title: 'Code style',
23+
refs: [
24+
{ type: 'group', plugin: 'eslint', slug: 'suggestions', weight: 1 },
25+
],
26+
},
27+
],
28+
};
29+
30+
const coverageConfig: CoreConfig = {
31+
plugins: [
32+
await coveragePlugin({
33+
coverageToolCommand: {
34+
command: 'npx',
35+
args: ['nx', 'run-many', '-t', 'test', '--coverage', '--skipNxCache'],
36+
},
37+
reports: await getNxCoveragePaths(['test']),
38+
}),
39+
],
40+
categories: [
41+
{
42+
slug: 'coverage',
43+
title: 'Coverage',
44+
refs: [
45+
{ type: 'group', plugin: 'coverage', slug: 'coverage', weight: 1 },
46+
],
47+
},
48+
],
49+
};
50+
51+
const jsPackagesConfig: CoreConfig = {
52+
plugins: [await jsPackagesPlugin({ packageManager: 'npm' })],
53+
categories: [
54+
{
55+
slug: 'security',
56+
title: 'Security',
57+
refs: [
58+
{ type: 'group', plugin: 'js-packages', slug: 'npm-audit', weight: 1 },
59+
],
60+
},
61+
{
62+
slug: 'updates',
63+
title: 'Updates',
64+
refs: [
65+
{
66+
type: 'group',
67+
plugin: 'js-packages',
68+
slug: 'npm-outdated',
69+
weight: 1,
70+
},
71+
],
72+
},
73+
],
74+
};
75+
76+
const portalUploadConfig = process.env.CP_API_KEY
77+
? {
78+
upload: {
79+
server: 'https://api.code-pushup.dev/graphql',
80+
apiKey: process.env.CP_API_KEY,
81+
organization: 'demos',
82+
project: 'ng-demo',
83+
},
84+
}
85+
: {};
86+
87+
export default mergeConfigs(
88+
esLintConfig,
89+
jsPackagesConfig,
90+
coverageConfig,
91+
portalUploadConfig
92+
);

eslint.config.js

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,37 @@
1-
const nx = require('@nx/eslint-plugin');
1+
import jest from '@code-pushup/eslint-config/jest';
2+
import typescript from '@code-pushup/eslint-config/typescript';
3+
import nxESLintPlugin from '@nx/eslint-plugin';
4+
import tsESLint from 'typescript-eslint';
25

3-
module.exports = [
4-
...nx.configs['flat/base'],
5-
...nx.configs['flat/typescript'],
6-
...nx.configs['flat/javascript'],
6+
export default tsESLint.config(
7+
...typescript,
8+
...jest,
9+
{ plugins: { '@nx': nxESLintPlugin } },
10+
{
11+
settings: {
12+
'import/resolver': {
13+
typescript: {
14+
alwaysTryTypes: true,
15+
project: ['tsconfig.base.json', 'node_modules/rxjs/tsconfig.json'],
16+
},
17+
},
18+
},
19+
},
20+
{
21+
ignores: [
22+
'/dist',
23+
'/tools',
24+
'**/*.md',
25+
'**/*.scss',
26+
'**/*.less',
27+
'**/assets',
28+
'**/*.ico',
29+
'**/*.yml',
30+
'**/*.yaml',
31+
'**/Dockerfile',
32+
'**/nginx.conf',
33+
],
34+
},
735
{
836
ignores: ['**/dist'],
937
},
@@ -30,4 +58,4 @@ module.exports = [
3058
// Override or add rules here
3159
rules: {},
3260
},
33-
];
61+
);

jest.preset.cjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
const nxPreset = require('@nx/jest/preset').default;
22

3-
module.exports = { ...nxPreset };
3+
module.exports = {
4+
...nxPreset,
5+
collectCoverageFrom: ['src/**/*.ts'],
6+
coveragePathIgnorePatterns: [String.raw`\.spec\.ts$`, 'generated'],
7+
coverageReporters: ['text', 'lcov', 'html'],
8+
};

0 commit comments

Comments
 (0)