Skip to content

Commit fbaf009

Browse files
committed
Merge branch 'add-plugin-targets' into cp-targets
# Conflicts: # .github/workflows/code-pushup-fork.centralized.yml # .github/workflows/code-pushup.centralized.yml # code-pushup.preset.ts # packages/plugin-coverage/src/lib/nx/coverage-paths.ts # project.json
2 parents c71ccf8 + ff016c4 commit fbaf009

File tree

13 files changed

+353
-132
lines changed

13 files changed

+353
-132
lines changed

.github/workflows/code-pushup-fork.centralized.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Code PushUp - Centralized/No Cache (fork)
1+
name: Code PushUp - Standalone Mode (fork)
22

33
# separated from code-pushup.yml for security reasons
44
# => requires permissions to create PR comment
@@ -20,19 +20,23 @@ permissions:
2020
jobs:
2121
code-pushup:
2222
runs-on: ubuntu-latest
23-
name: Run central layout no cache
23+
name: Run Code PushUp (fork)
2424
if: github.event.pull_request.head.repo.fork
2525
steps:
2626
- name: Checkout repository
2727
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
2830
- name: Set up Node.js
2931
uses: actions/setup-node@v4
3032
with:
3133
node-version-file: .nvmrc
3234
cache: npm
35+
- name: Set base and head for Nx affected commands
36+
uses: nrwl/nx-set-shas@v4
3337
- name: Install dependencies
3438
run: npm ci
3539
- name: Run Code PushUp action
3640
uses: code-pushup/github-action@v0
3741
with:
38-
bin: npx nx code-pushup-central --
42+
bin: npx nx code-pushup --nx-bail --

.github/workflows/code-pushup.centralized.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Code PushUp - Centralized/No Cache
1+
name: Code PushUp - Standalone Mode
22

33
on:
44
push:
@@ -16,7 +16,7 @@ permissions:
1616
jobs:
1717
code-pushup:
1818
runs-on: ubuntu-latest
19-
name: Run central layout no cache
19+
name: Run Code PushUp
2020
# ignore PRs from forks, handled by code-pushup-fork.yml
2121
if: ${{ !github.event.pull_request.head.repo.fork }}
2222
env:
@@ -27,14 +27,18 @@ jobs:
2727
steps:
2828
- name: Checkout repository
2929
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
3032
- name: Set up Node.js
3133
uses: actions/setup-node@v4
3234
with:
3335
node-version-file: .nvmrc
3436
cache: npm
37+
- name: Set base and head for Nx affected commands
38+
uses: nrwl/nx-set-shas@v4
3539
- name: Install dependencies
3640
run: npm ci
3741
- name: Run Code PushUp action
3842
uses: code-pushup/github-action@v0
3943
with:
40-
bin: npx nx code-pushup-central --
44+
bin: npx nx code-pushup --nx-bail --

code-pushup.config.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,22 @@
11
import 'dotenv/config';
2-
import { z } from 'zod';
32
import {
43
jsPackagesCoreConfig,
54
lighthouseCoreConfig,
65
} from './code-pushup.preset.js';
76
import type { CoreConfig } from './packages/models/src/index.js';
87
import { mergeConfigs } from './packages/utils/src/index.js';
98

10-
// load upload configuration from environment
11-
const envSchema = z.object({
12-
CP_SERVER: z.string().url(),
13-
CP_API_KEY: z.string().min(1),
14-
CP_ORGANIZATION: z.string().min(1),
15-
CP_PROJECT: z.string().min(1),
16-
});
17-
const { data: env } = await envSchema.safeParseAsync(process.env);
9+
const project = process.env['NX_TASK_TARGET_PROJECT'] || 'cli-workspace';
1810

1911
const config: CoreConfig = {
20-
...(env && {
12+
...(process.env['CP_API_KEY'] && {
2113
upload: {
22-
server: env.CP_SERVER,
23-
apiKey: env.CP_API_KEY,
24-
organization: env.CP_ORGANIZATION,
25-
project: 'cli-workspace',
14+
project,
15+
organization: 'code-pushup',
16+
server: 'https://api.staging.code-pushup.dev/graphql',
17+
apiKey: process.env['CP_API_KEY'],
2618
},
2719
}),
28-
2920
plugins: [],
3021
};
3122

code-pushup.preset.ts

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import coveragePlugin, {
1313
} from './packages/plugin-coverage/src/index.js';
1414
import eslintPlugin, {
1515
eslintConfigFromAllNxProjects,
16-
eslintConfigFromNxProject,
1716
} from './packages/plugin-eslint/src/index.js';
1817
import jsPackagesPlugin from './packages/plugin-js-packages/src/index.js';
1918
import jsDocsPlugin from './packages/plugin-jsdocs/src/index.js';
@@ -33,51 +32,6 @@ import typescriptPlugin, {
3332
getCategories,
3433
} from './packages/plugin-typescript/src/index.js';
3534

36-
/**
37-
* Helper function to load and validate Code PushUp environment variables for upload configuration
38-
*/
39-
export async function loadEnv(
40-
projectName: string | undefined = process.env.NX_TASK_TARGET_PROJECT,
41-
): Promise<Partial<CoreConfig>> {
42-
if (projectName == null || projectName === '') {
43-
throw new Error(
44-
'loadEnv failed! Project name is not defined. Please run code pushup fit Nx or provide a projectName.',
45-
);
46-
}
47-
const envSchema = z.object({
48-
CP_SERVER: z.string().url(),
49-
CP_API_KEY: z.string().min(1),
50-
CP_ORGANIZATION: z.string().min(1),
51-
CP_PROJECT: z.string().optional(),
52-
});
53-
54-
const { data: env, success } = await envSchema.safeParseAsync(process.env);
55-
56-
if (!success || !env) {
57-
return {};
58-
}
59-
const uploadConfig = {
60-
apiKey: env.CP_API_KEY,
61-
server: env.CP_SERVER,
62-
organization: env.CP_ORGANIZATION,
63-
...(env.CP_PROJECT
64-
? { project: env.CP_PROJECT }
65-
: { project: projectName }),
66-
};
67-
return uploadConfig.apiKey ? { upload: uploadConfig } : {};
68-
}
69-
70-
/**
71-
* Common exclusion patterns for JSDoc coverage
72-
*/
73-
export const jsDocsExclusionPatterns = [
74-
'!packages/**/node_modules',
75-
'!packages/**/{mocks,mock}',
76-
'!**/*.{spec,test}.ts',
77-
'!**/implementation/**',
78-
'!**/internal/**',
79-
];
80-
8135
export const jsPackagesCategories: CategoryConfig[] = [
8236
{
8337
slug: 'security',
@@ -217,7 +171,10 @@ export const eslintCoreConfigNx = async (
217171
): Promise<CoreConfig> => ({
218172
plugins: [
219173
projectName
220-
? await eslintPlugin(`packages/${projectName}/eslint.config.js`)
174+
? await eslintPlugin({
175+
eslintrc: `packages/${projectName}/eslint.config.js`,
176+
patterns: ['.'],
177+
})
221178
: await eslintPlugin(await eslintConfigFromAllNxProjects()),
222179
],
223180
categories: eslintCategories,

0 commit comments

Comments
 (0)