Add createCheck to display test results in GitHub UI
parent
4e41fc178c
commit
e207201236
File diff suppressed because one or more lines are too long
|
@ -2,6 +2,7 @@ import * as core from '@actions/core';
|
||||||
import * as github from '@actions/github';
|
import * as github from '@actions/github';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as xmljs from 'xml-js';
|
import * as xmljs from 'xml-js';
|
||||||
|
import path from 'path';
|
||||||
import Handlebars from 'handlebars';
|
import Handlebars from 'handlebars';
|
||||||
import ReportConverter from './report-converter';
|
import ReportConverter from './report-converter';
|
||||||
import { RunMeta } from './ts/meta.ts';
|
import { RunMeta } from './ts/meta.ts';
|
||||||
|
@ -10,14 +11,12 @@ class ResultsCheck {
|
||||||
static async publishResults(artifactsPath, githubToken) {
|
static async publishResults(artifactsPath, githubToken) {
|
||||||
// Parse all reports
|
// Parse all reports
|
||||||
const runs = [];
|
const runs = [];
|
||||||
const workspace = process.env.GITHUB_WORKSPACE;
|
|
||||||
const files = fs.readdirSync(artifactsPath);
|
const files = fs.readdirSync(artifactsPath);
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
files.map(async filepath => {
|
files.map(async filepath => {
|
||||||
if (!filepath.endsWith('.xml')) return;
|
if (!filepath.endsWith('.xml')) return;
|
||||||
const filename = filepath.replace(workspace, '');
|
core.startGroup(`Processing file ${filepath}...`);
|
||||||
core.startGroup(`Processing file ${filename}...`);
|
const fileData = await ResultsCheck.parseReport(path.join(artifactsPath, filepath));
|
||||||
const fileData = await ResultsCheck.parseReport(filepath, filename);
|
|
||||||
core.info(fileData.summary);
|
core.info(fileData.summary);
|
||||||
runs.push(fileData);
|
runs.push(fileData);
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
|
@ -46,13 +45,13 @@ class ResultsCheck {
|
||||||
await ResultsCheck.createCheck(githubToken, runs, runSummary, runSummary.extractAnnotations());
|
await ResultsCheck.createCheck(githubToken, runs, runSummary, runSummary.extractAnnotations());
|
||||||
}
|
}
|
||||||
|
|
||||||
static async parseReport(filepath, filename) {
|
static async parseReport(filepath) {
|
||||||
core.info(`Trying to open ${filepath}`);
|
core.info(`Trying to open ${filepath}`);
|
||||||
const file = await fs.promises.readFile(filepath, 'utf8');
|
const file = await fs.promises.readFile(filepath, 'utf8');
|
||||||
const report = xmljs.xml2js(file, { compact: true });
|
const report = xmljs.xml2js(file, { compact: true });
|
||||||
core.info(`File ${filepath} parsed...`);
|
core.info(`File ${filepath} parsed...`);
|
||||||
|
|
||||||
return ReportConverter.convertReport(filename, report);
|
return ReportConverter.convertReport(path.basename(filepath), report);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async createCheck(githubToken, runs, runSummary, annotations) {
|
static async createCheck(githubToken, runs, runSummary, annotations) {
|
||||||
|
|
Loading…
Reference in New Issue