remove the dependency patch when the JUnit root-layout fix is released:

Offen Anfängerfreundlich
#694 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
73/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
github-actions, javascript, node.js
Bereich
ci-cd, testing

Rechercherichtung

Beginne mit actions/quality/prepare-ci-reports/src/TestReports.js und untersuche die Abhängigkeit junit-to-ctrf sowie den verknüpften Fix für das Root-Layout, Pull Request 93. Prüfe, ob dieser Fix veröffentlicht wurde und wie der Patch für die Abhängigkeit angewendet wird; entferne den Patch, sobald das Release verfügbar ist. Bestätige, dass der Konverter weiterhin JUnit-Berichte verarbeitet und einen gültigen, nicht leeren CTRF-Bericht erzeugt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug need-fix

https://github\.com/ctrf\-io/junit\-to\-ctrf/pull/93

https://github.com/hoverkraft-tech/ci-github-common/blob/3d85e6252a0c3c45c34d6f5d50db140944f61b85/actions/quality/prepare-ci-reports/src/TestReports.js#L4-L5


import fs from "node:fs";
import { validate } from "ctrf";
import { XMLValidator } from "fast-xml-parser";
// FIXME: remove the dependency patch when the JUnit root-layout fix is released:
// https://github.com/ctrf-io/junit-to-ctrf/pull/93
import { convertJUnitToCTRFReport } from "junit-to-ctrf";
import { JestReport } from "./JestReport.js";
import { SourcePaths } from "./SourcePaths.js";

/** Adapt native runner output to the maintained CTRF converters and schema. */
export class TestReports {
	constructor(options) {
		this.options = options;
	}

	async convert(file, target) {
		const options = { ...this.options, output: `${target}.json` };
		const content = fs.readFileSync(file, "utf8");
		let report;
		if (content.trimStart().startsWith("<")) {
			if (
				/<!ENTITY|<!DOCTYPE/i.test(content) ||
				XMLValidator.validate(content) !== true
			)
				throw new Error("Invalid or unsafe JUnit XML.");
			report = await convertJUnitToCTRFReport(file, {
				toolName: options.name,
				log: false,
			});
		} else {
			const value = JSON.parse(content);
			report = value.results
				? value
				: await new JestReport(options).convert(value);
		}
		const result = validate(report);
		if (!result.valid || !report?.results?.tests?.length)
			throw new Error(
				`Expected a nonempty valid test report: ${JSON.stringify(result.errors)}`,
			);
		for (const test of report.results.tests) {
			const source = new SourcePaths(options).resolve(test.filePath);
			if (source) test.filePath = source;
			else delete test.filePath;
		}
		report.results.environment = {
			...report.results.environment,
			appName: options.project,
			buildName: options.name,
		};
		report.results.extra = {
			...report.results.extra,
			variant: options.variant,
		};
		fs.writeFileSync(options.output, JSON.stringify(report));
		return { file: options.output, summary: report.results.summary };
	}
}

Vorherrschende Sprache
JavaScript
Sterne
5
Forks
1
Ø Merge
5 Std. 25 Min.
Gemergte PRs (30 T.)
60

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus hoverkraft-tech/ci-github-common

Alle Issues in hoverkraft-tech/ci-github-common

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.