Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NO-ISSUE: Fix JUnit reports check at the end of builds #1466

Merged
merged 4 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions .github/workflows/ci_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,21 @@ jobs:

- name: "Check tests result (`main` only)"
if: always() && !cancelled() && steps.setup_build_mode.outputs.mode != 'none' && !github.event.pull_request
uses: mikepenz/action-junit-report@ab07dd7abefd456d92ecbeb22f81392fafe3d528
with:
check_name: "-"
annotate_only: true
fail_on_failure: true
report_paths: |
uses: actions/github-script@v6
env:
KIE_TOOLS_CI__JUNIT_REPORT_RESULTS_PATTERNS: |-
${{ steps.ci_patterns.outputs.tests_reports_patterns }}
${{ steps.ci_patterns.outputs.integration_tests_reports_patterns }}
with:
result-encoding: string
script: |
const patterns = process.env["KIE_TOOLS_CI__JUNIT_REPORT_RESULTS_PATTERNS"]
.split("\n")
.map(p => p.trim())
.filter(p => p);

const script = require("./scripts/check-junit-report-results/src/index.js");
await script({ core, glob, patterns });

- name: "Check hanging uncommitted files (you should commit those!)"
if: always() && !cancelled() && steps.setup_build_mode.outputs.mode != 'none'
Expand All @@ -160,6 +167,8 @@ jobs:
BUILDKITE_BRANCH: ${{ github.ref_name }}
BUILDKITE_MESSAGE: ${{ github.event.commits[0].message }}
run: |
eval "find -P * -type f ${{ steps.ci_patterns.outputs.integration_tests_reports_patterns_for_find }}"
echo "---------------------------- starting upload -----------------------"
eval "find -P * -type f ${{ steps.ci_patterns.outputs.integration_tests_reports_patterns_for_find }}" | xargs -I{} curl -X POST \
-H "Authorization: Token token=\"$BUILDKITE_ANALYTICS_TOKEN\"" \
-F "format=junit" \
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"devDependencies": {
"@kie-tools-scripts/bootstrap": "workspace:*",
"@kie-tools-scripts/build-env": "workspace:*",
"@kie-tools-scripts/check-junit-report-results": "workspace:*",
"@kie-tools-scripts/run-script-if": "workspace:*",
"@kie-tools-scripts/sparse-checkout": "workspace:*",
"@kie-tools-scripts/update-version": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@kie-tools-core/notifications": "workspace:*",
"@kie-tools-core/workspace": "workspace:*",
"axios": "^0.27.2",
"fast-xml-parser": "^3.17.4",
"fast-xml-parser": "^4.1.2",
"portfinder": "^1.0.32",
"semver": "^7.3.5",
"sinon": "^11.1.1"
Expand Down
9 changes: 5 additions & 4 deletions packages/backend/src/node/TestScenarioRunnerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import * as cp from "child_process";
import * as xmlParser from "fast-xml-parser";
import { XMLParser } from "fast-xml-parser";
import * as fs from "fs";
import * as path from "path";
import { CapabilityResponse, Service } from "../api";
Expand Down Expand Up @@ -88,13 +88,14 @@ export class TestScenarioRunnerService implements Service, TestScenarioRunnerCap
}

const resultXmlPath = path.join(baseDir, "target", "surefire-reports", "TEST-" + runnerClass + ".xml");
const attrsMap = xmlParser.getTraversalObj(fs.readFileSync(resultXmlPath).toString(), {
const parser = new XMLParser({
attributeNamePrefix: "",
ignoreNameSpace: true,
removeNSPrefix: true,
ignoreAttributes: false,
parseAttributeValue: true,
trimValues: true,
}).child.testsuite[0].attrsMap;
});
const attrsMap = parser.parse(fs.readFileSync(resultXmlPath).toString()).testsuites.testsuite[0];

resolve(
CapabilityResponse.ok({
Expand Down
78 changes: 53 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions repo/graph.dot
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ digraph G {
edge [ headport = "n", tailport = "s", arrowhead =dot, arrowsize =0.5 ];
"kie-tools-root" [ color = "black", fontcolor = "black", style = "dashed, rounded" ];
"@kie-tools-scripts/bootstrap" [ color = "black", fontcolor = "black", style = "dashed, rounded" ];
"@kie-tools-scripts/check-junit-report-results" [ color = "black", fontcolor = "black", style = "dashed, rounded" ];
"@kie-tools-scripts/run-script-if" [ color = "blue", fontcolor = "blue", style = "rounded" ];
"@kie-tools-scripts/sparse-checkout" [ color = "black", fontcolor = "black", style = "dashed, rounded" ];
"@kie-tools-scripts/update-version" [ color = "black", fontcolor = "black", style = "dashed, rounded" ];
Expand Down Expand Up @@ -128,6 +129,7 @@ digraph G {
"vscode-extension-yard-editor" [ color = "blue", fontcolor = "blue", style = "rounded" ];
"@kie-tools/yard-editor" [ color = "blue", fontcolor = "blue", style = "rounded" ];
"kie-tools-root" -> "@kie-tools-scripts/bootstrap" [ style = "dashed", color = "black" ];
"kie-tools-root" -> "@kie-tools-scripts/check-junit-report-results" [ style = "dashed", color = "black" ];
"kie-tools-root" -> "@kie-tools-scripts/run-script-if" [ style = "dashed", color = "black" ];
"kie-tools-root" -> "@kie-tools-scripts/sparse-checkout" [ style = "dashed", color = "black" ];
"kie-tools-root" -> "@kie-tools-scripts/update-version" [ style = "dashed", color = "black" ];
Expand Down
3 changes: 3 additions & 0 deletions repo/graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"nodes": [
{ "id": "kie-tools-root" },
{ "id": "@kie-tools-scripts/bootstrap" },
{ "id": "@kie-tools-scripts/check-junit-report-results" },
{ "id": "@kie-tools-scripts/run-script-if" },
{ "id": "@kie-tools-scripts/sparse-checkout" },
{ "id": "@kie-tools-scripts/update-version" },
Expand Down Expand Up @@ -129,6 +130,7 @@
],
"links": [
{ "source": "kie-tools-root", "target": "@kie-tools-scripts/bootstrap", "weight": 1 },
{ "source": "kie-tools-root", "target": "@kie-tools-scripts/check-junit-report-results", "weight": 1 },
{ "source": "kie-tools-root", "target": "@kie-tools-scripts/run-script-if", "weight": 1 },
{ "source": "kie-tools-root", "target": "@kie-tools-scripts/sparse-checkout", "weight": 1 },
{ "source": "kie-tools-root", "target": "@kie-tools-scripts/update-version", "weight": 1 },
Expand Down Expand Up @@ -968,6 +970,7 @@
["@kie-tools/yard-editor", "packages/yard-editor"],
["@kie-tools-scripts/bootstrap", "scripts/bootstrap"],
["@kie-tools-scripts/build-env", "scripts/build-env"],
["@kie-tools-scripts/check-junit-report-results", "scripts/check-junit-report-results"],
["@kie-tools-scripts/run-script-if", "scripts/run-script-if"],
["@kie-tools-scripts/sparse-checkout", "scripts/sparse-checkout"],
["@kie-tools-scripts/update-version", "scripts/update-version"]
Expand Down
Loading