fix: markdown report publishing (#35500)
This commit is contained in:
parent
878e56c87e
commit
0acedf1ca2
|
@ -20,7 +20,6 @@ import * as core from '@actions/core';
|
||||||
import MarkdownReporter from './markdownReporter';
|
import MarkdownReporter from './markdownReporter';
|
||||||
|
|
||||||
import type { MetadataWithCommitInfo } from 'playwright/src/isomorphic/types';
|
import type { MetadataWithCommitInfo } from 'playwright/src/isomorphic/types';
|
||||||
import type { FullConfig } from '@playwright/test';
|
|
||||||
|
|
||||||
function getGithubToken() {
|
function getGithubToken() {
|
||||||
const token = process.env.GITHUB_TOKEN || core.getInput('github-token');
|
const token = process.env.GITHUB_TOKEN || core.getInput('github-token');
|
||||||
|
@ -36,8 +35,6 @@ const octokit = getOctokit(getGithubToken());
|
||||||
const magicComment = '<!-- Generated by Playwright markdown reporter -->';
|
const magicComment = '<!-- Generated by Playwright markdown reporter -->';
|
||||||
|
|
||||||
class GHAMarkdownReporter extends MarkdownReporter {
|
class GHAMarkdownReporter extends MarkdownReporter {
|
||||||
declare config: FullConfig;
|
|
||||||
|
|
||||||
override async publishReport(report: string) {
|
override async publishReport(report: string) {
|
||||||
core.info('Publishing report to PR.');
|
core.info('Publishing report to PR.');
|
||||||
const { prNumber, prHref } = this.pullRequestFromMetadata();
|
const { prNumber, prHref } = this.pullRequestFromMetadata();
|
||||||
|
@ -89,7 +86,7 @@ class GHAMarkdownReporter extends MarkdownReporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private pullRequestFromMetadata() {
|
private pullRequestFromMetadata() {
|
||||||
const metadata = this.config.metadata as MetadataWithCommitInfo;
|
const metadata = this._config.metadata as MetadataWithCommitInfo;
|
||||||
const prHref = metadata.ci?.prHref;
|
const prHref = metadata.ci?.prHref;
|
||||||
return { prNumber: parseInt(prHref?.split('/').pop() ?? '', 10), prHref };
|
return { prNumber: parseInt(prHref?.split('/').pop() ?? '', 10), prHref };
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ type MarkdownReporterOptions = {
|
||||||
class MarkdownReporter implements Reporter {
|
class MarkdownReporter implements Reporter {
|
||||||
private _options: MarkdownReporterOptions;
|
private _options: MarkdownReporterOptions;
|
||||||
private _fatalErrors: TestError[] = [];
|
private _fatalErrors: TestError[] = [];
|
||||||
private _config!: FullConfig;
|
protected _config!: FullConfig;
|
||||||
private _suite!: Suite;
|
private _suite!: Suite;
|
||||||
|
|
||||||
constructor(options: MarkdownReporterOptions) {
|
constructor(options: MarkdownReporterOptions) {
|
||||||
|
|
Loading…
Reference in New Issue