Skip to content

ci: Fix overhead measurements runs on default branch #7313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/overhead-metrics/configs/ci/process.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import fs from 'fs-extra';
import path from 'path';

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

await GitHub.downloadPreviousArtifact(baseBranch, baselineResultsDir, artifactName);
await GitHub.downloadPreviousArtifact(branch, previousResultsDir, artifactName);

if (branchIsBase) {
await GitHub.downloadPreviousArtifact(branch, previousResultsDir, artifactName);
} else {
// Copy over same results
await fs.copy(baselineResultsDir, previousResultsDir);
}

GitHub.writeOutput('artifactName', artifactName);
GitHub.writeOutput('artifactPath', path.resolve(previousResultsDir));
Expand Down
1 change: 1 addition & 0 deletions packages/overhead-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"axios": "^1.2.2",
"extract-zip": "^2.0.1",
"filesize": "^10.0.6",
"fs-extra": "^11.1.0",
"p-timeout": "^6.0.0",
"playwright": "^1.31.1",
"playwright-core": "^1.29.1",
Expand Down
9 changes: 9 additions & 0 deletions packages/overhead-metrics/src/util/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ export const Git = {
}
},

get branchIsBase(): Promise<boolean> {
return (async () => {
const branch = await this.branch;
const baseBranch = await this.baseBranch;

return branch === baseBranch;
})();
},

get hash(): Promise<GitHash> {
return (async () => {
let gitHash = await git.revparse('HEAD');
Expand Down
2 changes: 1 addition & 1 deletion packages/overhead-metrics/src/util/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function tryAddOrUpdateComment(commentBuilder: PrCommentBuilder): Promise<
console.log(
`Determined PR number ${prNumber} based on GITHUB_REF environment variable: '${process.env.GITHUB_REF}'`,
);
} else {
} else if (!(await Git.branchIsBase)) {
prNumber = (
await octokit.rest.pulls.list({
...defaultArgs,
Expand Down