Skip to content

Commit 6b42385

Browse files
committed
WIP
1 parent 8cbf552 commit 6b42385

File tree

4 files changed

+64
-13
lines changed

4 files changed

+64
-13
lines changed

.github/workflows/pr.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,38 @@ jobs:
8282
- uses: ./github-actions/bazel/setup
8383
- run: yarn install --immutable
8484
- run: yarn bazel test --sandbox_writable_path="$HOME/Library/Application Support" --test_tag_filters=macos --build_tests_only -- //...
85+
86+
87+
workflow-perf-list:
88+
timeout-minutes: 30
89+
runs-on: ubuntu-latest
90+
steps:
91+
# Because the checkout and setup node action is contained in the dev-infra repo, we must
92+
# checkout the repo to be able to run the action we have created. Other repos will skip
93+
# this step.
94+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
95+
- uses: ./github-actions/npm/checkout-and-setup-node
96+
- uses: ./github-actions/bazel/setup
97+
- run: yarn install --immutable
98+
- id: workflow-list
99+
run: echo 'workflows=$(yarn ng-dev perf workflows --list)' >> "$GITHUB_OUTPUT"
100+
101+
102+
workflow-perf:
103+
timeout-minutes: 30
104+
runs-on: ubuntu-latest
105+
needs: workflow-perf-list
106+
strategy:
107+
matrix:
108+
workflow: ${{ fromJSON(needs.workflow-perf-list.outputs.workflows) }}
109+
steps:
110+
# Because the checkout and setup node action is contained in the dev-infra repo, we must
111+
# checkout the repo to be able to run the action we have created. Other repos will skip
112+
# this step.
113+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
114+
- uses: ./github-actions/npm/checkout-and-setup-node
115+
- uses: ./github-actions/bazel/setup
116+
- run: yarn install --immutable
117+
- run: yarn ng-dev perf workflows --name ${{ matrix.workflow }}
118+
119+

.ng-dev/dx-perf-workflows.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
workflows:
2-
- name: Rerun a test
2+
rerun:
3+
name: Rerun a test
34
prepare:
45
- bazel clean;
56
- bazel build //ng-dev/utils/test;
@@ -10,7 +11,8 @@ workflows:
1011
cleanup:
1112
- git apply -R .ng-dev/perf-tests/test-rerun.diff;
1213

13-
- name: Build Everything
14+
build-everything:
15+
name: Build Everything
1416
prepare:
1517
- bazel clean;
1618
workflow:

ng-dev/perf/workflow/cli.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import {determineRepoBaseDirFromCwd} from '../../utils/repo-directory.js';
1414

1515
interface WorkflowsParams {
1616
configFile: string;
17-
json: boolean;
17+
list: boolean;
18+
name?: string;
1819
}
1920

2021
/** Builds the checkout pull request command. */
@@ -25,25 +26,38 @@ function builder(yargs: Argv) {
2526
type: 'string',
2627
description: 'The path to the workflow definitions in a yml file',
2728
})
28-
.option('json', {
29+
.option('list', {
2930
default: false,
3031
type: 'boolean',
31-
description: 'Whether to output the results as a json object',
32-
});
32+
description: 'Whether to get back a list of workflows that can be executed'
33+
})
34+
.option('name', {
35+
type: 'string',
36+
description: 'A specific workflow to run by name',
37+
})
3338
}
3439

3540
/** Handles the checkout pull request command. */
36-
async function handler({configFile, json}: WorkflowsParams) {
41+
async function handler({configFile, list, name}: WorkflowsParams) {
3742
const workflows = await loadWorkflows(join(determineRepoBaseDirFromCwd(), configFile));
43+
44+
if (list) {
45+
process.stdout.write(JSON.stringify(Object.keys(workflows)));
46+
return;
47+
}
48+
49+
if (name) {
50+
const {duration} = await measureWorkflow(workflows[name]);
51+
process.stdout.write(JSON.stringify({[name]: duration}));
52+
return;
53+
}
54+
3855
const results: {[key: string]: number} = {};
39-
for (const workflow of workflows) {
56+
for (const workflow of Object.values(workflows)) {
4057
const {name, duration} = await measureWorkflow(workflow);
4158
results[name] = duration;
4259
}
43-
44-
if (json) {
45-
process.stdout.write(JSON.stringify(results));
46-
}
60+
process.stdout.write(JSON.stringify(results));
4761
}
4862

4963
/** yargs command module for checking out a PR. */

ng-dev/perf/workflow/loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export interface Workflow {
1010

1111
export async function loadWorkflows(src: string) {
1212
const rawWorkflows = await readFile(src, {encoding: 'utf-8'});
13-
return parse(rawWorkflows).workflows as Workflow[];
13+
return parse(rawWorkflows).workflows as {[key: string]: Workflow};
1414
}

0 commit comments

Comments
 (0)