Skip to content

Commit 96b3bfa

Browse files
committed
ci(local-action): use native github actions log groups in standalone mode
1 parent 6555b6f commit 96b3bfa

File tree

1 file changed

+37
-28
lines changed

1 file changed

+37
-28
lines changed

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

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -129,42 +129,51 @@ function createGitHubApiClient(): ProviderAPIClient {
129129
};
130130
}
131131

132+
function setupOptions(): Options {
133+
const isMonorepo = process.env['MODE'] === 'monorepo';
134+
135+
if (isMonorepo) {
136+
return {
137+
jobId: 'monorepo-mode',
138+
monorepo: 'nx',
139+
nxProjectsFilter: '--with-target=code-pushup --exclude=workspace',
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}',
151+
},
152+
}),
153+
},
154+
};
155+
}
156+
157+
// tsx importer need to resolve plugin runner scripts
158+
// eslint-disable-next-line functional/immutable-data
159+
process.env['NODE_OPTIONS'] = '--import=tsx';
160+
161+
return {
162+
jobId: 'standalone-mode',
163+
// run without Nx to demonstrate native GitHub Actions log groups
164+
bin: 'node packages/cli/src/index.ts',
165+
};
166+
}
167+
132168
async function run(): Promise<void> {
133169
try {
134170
if (core.isDebug()) {
135171
logger.setVerbose(true);
136172
}
137173

138-
const isMonorepo = process.env['MODE'] === '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-
}),
158-
},
159-
}
160-
: {
161-
jobId: 'standalone-mode',
162-
bin: 'npx nx code-pushup --',
163-
};
164-
165174
const gitRefs = parseGitRefs();
166-
167175
const apiClient = createGitHubApiClient();
176+
const options = setupOptions();
168177

169178
const result = await runInCI(gitRefs, apiClient, options);
170179

0 commit comments

Comments
 (0)