Skip to content

Commit

Permalink
fix(platform-server): fix github check runs
Browse files Browse the repository at this point in the history
  • Loading branch information
EYHN committed Aug 31, 2022
1 parent cd72fda commit b93226c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function renderBundleOutput(
title: string
summary: string
} {
const bundleBasicContent = `### **Bundle [#${artifact.iid}](${link})}**\n\n\n`
const bundleBasicContent = `### **[Bundle ${artifact.name}](${link})**\n\n\n`
if (artifact.failed()) {
return {
title: 'Bundle Analysis Job Failed',
Expand Down Expand Up @@ -144,7 +144,7 @@ function bundleSizeDiffTable(update: BundleJobUpdate, artifact: Artifact, baseli
if (entry.warnings.length) {
table += `#~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Warnings ~~~~~~~~~~~~~~~~~~~~~~~~~~~#\n`
for (const warning of entry.warnings) {
table += `! ${padEnd(truncate(warning.rule, { length: 64 }), 65, ' ')}\`
table += `! ${padEnd(truncate(warning.rule, { length: 64 }), 65, ' ')}\n`
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ export class GithubCheckSuiteProvider implements CheckSuiteProvider {
if (!this.github.available) {
return
}
const checkId = `${action.project.id}-${action.commitHash}-${action.type}`
const checkName = action.type === CheckType.Bundle ? `${action.type} - ${action.artifact.name}` : action.type
const checkId = `${action.project.id}-${action.commitHash}-${checkName}`

const installation = await this.github.getInstallationByRepository(action.project.namespace, action.project.name)
const accessToken = await this.github.getInstallationAccessToken(installation.id)

const params: GithubCheckRunParameters = {
name: `${action.project.name} - ${action.type}`,
name: `${action.project.slug} - ${checkName}`,
external_id: action.runId.toString(),
status: this.convertStatus(action.status),
conclusion: this.convertConclusion(action.conclusion),
Expand Down Expand Up @@ -97,15 +98,15 @@ export class GithubCheckSuiteProvider implements CheckSuiteProvider {
action.project.namespace,
action.project.name,
existedCommentId,
mergeComment(existedComment.body, commentBody, action.type, action.project.slug),
mergeComment(existedComment.body, commentBody, checkName, action.project.slug),
accessToken,
)
} else {
const comment = await this.github.createIssueComment(
action.project.namespace,
action.project.name,
pr.number,
mergeComment('', commentBody, action.type, action.project.name),
mergeComment('', commentBody, checkName, action.project.slug),
accessToken,
)
await GithubPullRequestsAssociation.insert({
Expand Down Expand Up @@ -172,7 +173,7 @@ export class GithubCheckSuiteProvider implements CheckSuiteProvider {
}
}

function mergeComment(oldContent: string, newContent: string, type: CheckType, sectionName: string): string {
function mergeComment(oldContent: string, newContent: string, type: string, sectionName: string): string {
const cleanup = (md: string) => {
return md.replace(/(\r\n|\n){3,}/g, '\r\n\r\n')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function renderLabOutput(
title: string
summary: string
} {
const title = `### **Snapshot [#${action.snapshot.iid}](${link})**\n\n\n`
const title = `### **[${action.snapshot.title ? `Lab ${action.snapshot.title}` : 'Lab'}](${link})**\n\n\n`

return {
title: 'Performance Issue Scanning completed',
Expand Down
2 changes: 1 addition & 1 deletion packages/platform-server/src/modules/checksuite/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class CheckSuiteService {
commitHash: artifact.hash,
runId: artifact.id,
status: CheckStatus.completed,
conclusion: artifact.succeeded() ? CheckConclusion.Failure : CheckConclusion.Success,
conclusion: artifact.succeeded() ? CheckConclusion.Success : CheckConclusion.Failure,
completedAt: new Date(),
type: CheckType.Bundle,
detailsUrl: this.url.projectUrl(pathFactory.project.bundle.detail, {
Expand Down
5 changes: 5 additions & 0 deletions packages/platform-server/src/modules/snapshot/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ export class SnapshotService implements OnApplicationBootstrap {
snapshotId: snapshot.id,
hash,
})

await this.checkSuite.startLabCheck(project, snapshot)
}

return snapshot
Expand Down Expand Up @@ -482,6 +484,9 @@ export class SnapshotService implements OnApplicationBootstrap {
status: SnapshotStatus.Running,
startedAt: new Date(),
})

const project = await Project.findOneByOrFail({ id: snapshot.projectId })
await this.checkSuite.runLabCheck(project, snapshot)
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/cli/take-snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ You can filter the pages by appending page names to the command.`,
}

const client = new Client({
accessToken: 'u0JlRvD+XDt+fwAJ90DfWyamjuywoqLjff6ZSUvwrNAU=',
accessToken: accessToken,
host: this.server || process.env.PERFSEE_PLATFORM_HOST || 'https://perfsee.com',
})

Expand Down Expand Up @@ -123,7 +123,7 @@ You can filter the pages by appending page names to the command.`,
})
this.context.stdout.write(`Profiles: ${profileIds}\n`)

const snapshot = await client.takeSnapshot(this.project, pageIds, profileIds, envIds, hash, this.title)
const snapshot = await client.takeSnapshot(this.project, pageIds, profileIds, envIds, this.title, hash)

this.context.stdout.write(`Created snapshot #${snapshot.id}\n`)

Expand Down

0 comments on commit b93226c

Please sign in to comment.