Skip to content

Commit 50a9d85

Browse files
committed
ci: Fix overhead measurements runs on default branch
1 parent 8a5e0c3 commit 50a9d85

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

packages/overhead-metrics/configs/ci/process.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import fs from 'fs-extra';
12
import path from 'path';
23

34
import { ResultsAnalyzer } from '../../src/results/analyzer.js';
@@ -11,9 +12,16 @@ import { artifactName, baselineResultsDir, latestResultFile, previousResultsDir
1112
const latestResult = Result.readFromFile(latestResultFile);
1213
const branch = await Git.branch;
1314
const baseBranch = await Git.baseBranch;
15+
const branchIsBase = await Git.branchIsBase;
1416

1517
await GitHub.downloadPreviousArtifact(baseBranch, baselineResultsDir, artifactName);
16-
await GitHub.downloadPreviousArtifact(branch, previousResultsDir, artifactName);
18+
19+
if (branchIsBase) {
20+
await GitHub.downloadPreviousArtifact(branch, previousResultsDir, artifactName);
21+
} else {
22+
// Copy over same results
23+
await fs.copy(baselineResultsDir, previousResultsDir);
24+
}
1725

1826
GitHub.writeOutput('artifactName', artifactName);
1927
GitHub.writeOutput('artifactPath', path.resolve(previousResultsDir));

packages/overhead-metrics/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"axios": "^1.2.2",
2727
"extract-zip": "^2.0.1",
2828
"filesize": "^10.0.6",
29+
"fs-extra": "^11.1.0",
2930
"p-timeout": "^6.0.0",
3031
"playwright": "^1.31.1",
3132
"playwright-core": "^1.29.1",

packages/overhead-metrics/src/util/git.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ export const Git = {
5353
}
5454
},
5555

56+
get branchIsBase(): Promise<boolean> {
57+
return (async () => {
58+
const branch = await this.branch;
59+
const baseBranch = await this.baseBranch;
60+
61+
return branch === baseBranch;
62+
})();
63+
},
64+
5665
get hash(): Promise<GitHash> {
5766
return (async () => {
5867
let gitHash = await git.revparse('HEAD');

packages/overhead-metrics/src/util/github.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async function tryAddOrUpdateComment(commentBuilder: PrCommentBuilder): Promise<
6060
console.log(
6161
`Determined PR number ${prNumber} based on GITHUB_REF environment variable: '${process.env.GITHUB_REF}'`,
6262
);
63-
} else {
63+
} else if (!(await Git.branchIsBase)) {
6464
prNumber = (
6565
await octokit.rest.pulls.list({
6666
...defaultArgs,

0 commit comments

Comments
 (0)