Skip to content

Commit a6e311d

Browse files
committed
ci(local-action): separate standalone and monorepo code-pushup jobs
1 parent 138fe3d commit a6e311d

File tree

4 files changed

+86
-22
lines changed

4 files changed

+86
-22
lines changed

.github/actions/code-pushup/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ inputs:
66
description: GitHub token for API access
77
required: true
88
default: ${{ github.token }}
9+
monorepo:
10+
description: Is monorepo mode, or standalone?
11+
required: true
12+
default: false
913

1014
runs:
1115
using: composite

.github/actions/code-pushup/src/runner.ts

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function createAnnotationsFromIssues(issues: SourceFileIssue[]): void {
8787
}
8888

8989
function createGitHubApiClient(): ProviderAPIClient {
90-
const token = process.env.GH_TOKEN;
90+
const token = core.getInput('token');
9191

9292
if (!token) {
9393
throw new Error('No GitHub token found');
@@ -135,23 +135,32 @@ async function run(): Promise<void> {
135135
logger.setVerbose(true);
136136
}
137137

138-
const options: Options = {
139-
monorepo: true,
140-
configPatterns: {
141-
persist: {
142-
...DEFAULT_PERSIST_CONFIG,
143-
outputDir: '.code-pushup/{projectName}',
144-
},
145-
...(process.env['CP_API_KEY'] && {
146-
upload: {
147-
server: 'https://api.staging.code-pushup.dev/graphql',
148-
apiKey: process.env['CP_API_KEY'],
149-
organization: 'code-pushup',
150-
project: 'cli-{projectName}',
138+
const isMonorepo = core.getBooleanInput('monorepo');
139+
140+
const options: Options = isMonorepo
141+
? {
142+
jobId: 'monorepo-mode',
143+
monorepo: 'nx',
144+
nxProjectsFilter: '--with-target=code-pushup --exclude=workspace',
145+
configPatterns: {
146+
persist: {
147+
...DEFAULT_PERSIST_CONFIG,
148+
outputDir: '.code-pushup/{projectName}',
149+
},
150+
...(process.env['CP_API_KEY'] && {
151+
upload: {
152+
server: 'https://api.staging.code-pushup.dev/graphql',
153+
apiKey: process.env['CP_API_KEY'],
154+
organization: 'code-pushup',
155+
project: 'cli-{projectName}',
156+
},
157+
}),
151158
},
152-
}),
153-
},
154-
};
159+
}
160+
: {
161+
jobId: 'standalone-mode',
162+
bin: 'npx nx code-pushup --',
163+
};
155164

156165
const gitRefs = parseGitRefs();
157166

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

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

33
# separated from code-pushup.yml for security reasons
44
# => requires permissions to create PR comment
@@ -18,9 +18,9 @@ permissions:
1818
pull-requests: write
1919

2020
jobs:
21-
code-pushup:
21+
standalone:
2222
runs-on: ubuntu-latest
23-
name: Run Code PushUp (fork)
23+
name: Standalone mode (fork)
2424
if: github.event.pull_request.head.repo.fork
2525
steps:
2626
- name: Checkout repository
@@ -40,3 +40,27 @@ jobs:
4040
uses: ./.github/actions/code-pushup
4141
with:
4242
token: ${{ secrets.GITHUB_TOKEN }}
43+
44+
monorepo:
45+
runs-on: ubuntu-latest
46+
name: Monorepo mode (fork)
47+
if: github.event.pull_request.head.repo.fork
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
with:
52+
fetch-depth: 0
53+
- name: Set up Node.js
54+
uses: actions/setup-node@v4
55+
with:
56+
node-version-file: .node-version
57+
cache: npm
58+
- name: Set base and head for Nx affected commands
59+
uses: nrwl/nx-set-shas@v4
60+
- name: Install dependencies
61+
run: npm ci
62+
- name: Run Code PushUp action
63+
uses: ./.github/actions/code-pushup
64+
with:
65+
token: ${{ secrets.GITHUB_TOKEN }}
66+
monorepo: true

.github/workflows/code-pushup.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ permissions:
1414
pull-requests: write
1515

1616
jobs:
17-
code-pushup:
17+
standalone:
1818
runs-on: ubuntu-latest
19-
name: Run Code PushUp
19+
name: Standalone mode
2020
# ignore PRs from forks, handled by code-pushup-fork.yml
2121
if: ${{ !github.event.pull_request.head.repo.fork }}
2222
env:
@@ -39,3 +39,30 @@ jobs:
3939
uses: ./.github/actions/code-pushup
4040
with:
4141
token: ${{ secrets.GITHUB_TOKEN }}
42+
43+
monorepo:
44+
runs-on: ubuntu-latest
45+
name: Monorepo mode
46+
# ignore PRs from forks, handled by code-pushup-fork.yml
47+
if: ${{ !github.event.pull_request.head.repo.fork }}
48+
env:
49+
CP_API_KEY: ${{ secrets.CP_API_KEY }}
50+
steps:
51+
- name: Checkout repository
52+
uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 0
55+
- name: Set up Node.js
56+
uses: actions/setup-node@v4
57+
with:
58+
node-version-file: .node-version
59+
cache: npm
60+
- name: Set base and head for Nx affected commands
61+
uses: nrwl/nx-set-shas@v4
62+
- name: Install dependencies
63+
run: npm ci
64+
- name: Run Code PushUp action
65+
uses: ./.github/actions/code-pushup
66+
with:
67+
token: ${{ secrets.GITHUB_TOKEN }}
68+
monorepo: true

0 commit comments

Comments
 (0)