Skip to content

Commit 3e0e878

Browse files
committed
ci: add Nx target for running Code PushUp commands on whole repo
1 parent a59d3f1 commit 3e0e878

5 files changed

Lines changed: 56 additions & 16 deletions

File tree

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# for uploading to portal
2+
CP_SERVER=
3+
CP_API_KEY=
4+
CP_ORGANIZATION=
5+
CP_PROJECT=

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,10 @@ jobs:
179179
cache: npm
180180
- name: Install dependencies
181181
run: npm ci
182-
- name: Build CLI and ESLint plugin
183-
run: npx nx run-many -t build -p cli,plugin-eslint,examples-plugins --parallel=3
184182
- name: Collect Code PushUp report
185-
run: npx dist/packages/cli --config code-pushup.config.ts collect
183+
run: npx nx run-collect
186184
- name: Upload Code PushUp report to portal
187-
run: npx dist/packages/cli --config code-pushup.config.ts upload
185+
run: npx nx run-upload
188186
- name: Save report files as workflow artifact
189187
uses: actions/upload-artifact@v3
190188
with:

CONTRIBUTORS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ npx nx build cli
3636

3737
# lint projects affected by changes (compared to main branch)
3838
npx nx affected:lint
39+
40+
# run Code PushUp command on this repository
41+
npx nx run-collect
3942
```
4043

4144
## Git

code-pushup.config.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ import eslintPlugin, {
1414
import type { CoreConfig } from './packages/models/src';
1515

1616
// load upload configuration from environment
17-
const envSchema = z.object({
18-
CP_SERVER: z.string().url(),
19-
CP_API_KEY: z.string().min(1),
20-
CP_ORGANIZATION: z.string().min(1),
21-
CP_PROJECT: z.string().min(1),
22-
});
17+
const envSchema = z
18+
.object({
19+
CP_SERVER: z.string().url(),
20+
CP_API_KEY: z.string().min(1),
21+
CP_ORGANIZATION: z.string().min(1),
22+
CP_PROJECT: z.string().min(1),
23+
})
24+
.partial();
2325
const env = await envSchema.parseAsync(process.env);
2426

2527
const config: CoreConfig = {
@@ -29,12 +31,17 @@ const config: CoreConfig = {
2931
format: ['json', 'md'],
3032
},
3133

32-
upload: {
33-
server: env.CP_SERVER,
34-
apiKey: env.CP_API_KEY,
35-
organization: env.CP_ORGANIZATION,
36-
project: env.CP_PROJECT,
37-
},
34+
...(env.CP_SERVER &&
35+
env.CP_API_KEY &&
36+
env.CP_ORGANIZATION &&
37+
env.CP_PROJECT && {
38+
upload: {
39+
server: env.CP_SERVER,
40+
apiKey: env.CP_API_KEY,
41+
organization: env.CP_ORGANIZATION,
42+
project: env.CP_PROJECT,
43+
},
44+
}),
3845

3946
plugins: [
4047
await eslintPlugin(await eslintConfigFromNxProjects()),

project.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,33 @@
2727
"tag": "{tag}",
2828
"notes": "{notes}"
2929
}
30+
},
31+
"run-collect": {
32+
"command": "npx dist/packages/cli collect --config=code-pushup.config.ts",
33+
"dependsOn": [
34+
{
35+
"projects": ["cli", "plugin-eslint", "examples-plugins"],
36+
"target": "build"
37+
}
38+
]
39+
},
40+
"run-upload": {
41+
"command": "npx dist/packages/cli upload --config=code-pushup.config.ts",
42+
"dependsOn": [
43+
{
44+
"projects": ["cli", "plugin-eslint", "examples-plugins"],
45+
"target": "build"
46+
}
47+
]
48+
},
49+
"run-autorun": {
50+
"command": "npx dist/packages/cli autorun --config=code-pushup.config.ts",
51+
"dependsOn": [
52+
{
53+
"projects": ["cli", "plugin-eslint", "examples-plugins"],
54+
"target": "build"
55+
}
56+
]
3057
}
3158
}
3259
}

0 commit comments

Comments
 (0)