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

Đang mở Phù hợp với người mới
#694 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
73/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
github-actions, javascript, node.js
Lĩnh vực
ci-cd, testing

Hướng nghiên cứu

Bắt đầu với actions/quality/prepare-ci-reports/src/TestReports.js và kiểm tra dependency junit-to-ctrf cùng bản sửa lỗi root-layout được liên kết, pull request 93. Kiểm tra xem bản sửa lỗi đó đã được phát hành chưa và patch cho dependency được áp dụng như thế nào; gỡ patch sau khi bản phát hành có sẵn. Xác nhận rằng bộ chuyển đổi vẫn xử lý các báo cáo JUnit và tạo ra một báo cáo CTRF hợp lệ, không rỗng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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 };
	}
}

Ngôn ngữ chính
JavaScript
Star
5
Fork
1
Merge trung bình
5 giờ 25 phút
Pull request đã merge (30 ngày)
60

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của hoverkraft-tech/ci-github-common

Tất cả issue của hoverkraft-tech/ci-github-common

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.