Skip to content

Commit

Permalink
Fix issue where importing pmd would cause CI failures, add some sourc…
Browse files Browse the repository at this point in the history
…emaps

Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed Apr 25, 2024
1 parent 90e3ee1 commit 0d2cdfb
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 127 deletions.
26 changes: 10 additions & 16 deletions actions/checkstyle/dist/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/******/ (() => { // webpackBootstrap
require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({

/***/ 9548:
Expand Down Expand Up @@ -28940,7 +28940,7 @@ var external_fs_ = __nccwpck_require__(7147);
var fxp = __nccwpck_require__(626);
;// CONCATENATED MODULE: ../pmd/src/logProblems.ts

function logProblems(problems) {
function logProblems_logProblems(problems) {
for (const problem of problems) {
(0,core.error)(problem.info !== undefined && problem.info !== null ? problem.info : "", problem);
}
Expand All @@ -28952,7 +28952,7 @@ function logProblems(problems) {
}
}

;// CONCATENATED MODULE: ../pmd/src/action.ts
;// CONCATENATED MODULE: ../pmd/src/pmd.ts



Expand Down Expand Up @@ -28980,7 +28980,7 @@ function parseFile(sourceDirectory, fileData) {
}
function parseData(sourceDirectory, data) {
const alwaysArray = ["pmd.file", "pmd.file.violation"];
const parser = new fxp.XMLParser({
const parser = new XMLParser({
ignoreAttributes: false,
isArray: (name, jpath) => {
return alwaysArray.indexOf(jpath) >= 0;
Expand All @@ -28996,14 +28996,11 @@ function parseData(sourceDirectory, data) {
}
return problems;
}
async function run() {
const pmdFile = (0,core.getInput)("file");
const sourceDir = (0,core.getInput)("src");
const data = (0,external_fs_.readFileSync)(pmdFile);
(0,core.debug)(data.toString());
function run(sourceDir, pmdFile) {
const data = readFileSync(pmdFile);
debug(data.toString());
logProblems(parseData(sourceDir, data));
}
run().catch((err) => (0,core.setFailed)(err));

// EXTERNAL MODULE: external "path"
var external_path_ = __nccwpck_require__(1017);
Expand Down Expand Up @@ -29072,20 +29069,16 @@ function checkstyle_run(checkstyleFile, pathTrim = "") {
(0,core.debug)("checkstyleFile: " + checkstyleFile);
const data = (0,external_fs_.readFileSync)(checkstyleFile);
(0,core.debug)(data.toString());
logProblems(checkstyle_parseData(trim, data));
logProblems_logProblems(checkstyle_parseData(trim, data));
}

;// CONCATENATED MODULE: ./src/action.ts


async function action_run() {
(0,core.debug)("start");
const checkstyleFile = (0,core.getInput)("file");
(0,core.debug)("checkstyleFile: " + checkstyleFile);
const pathTrim = (0,core.getInput)("pathTrim");
(0,core.debug)("pathTrim: " + pathTrim);
checkstyle_run(checkstyleFile, pathTrim);
(0,core.debug)("end");
}
action_run().catch((err) => {
console.log(err.stack);
Expand All @@ -29096,4 +29089,5 @@ action_run().catch((err) => {

module.exports = __webpack_exports__;
/******/ })()
;
;
//# sourceMappingURL=index.js.map
1 change: 1 addition & 0 deletions actions/checkstyle/dist/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions actions/checkstyle/dist/sourcemap-register.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion actions/checkstyle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "src/action.ts",
"scripts": {
"lint": "eslint src",
"prepare": "ncc build src/action.ts --license licenses.txt",
"prepare": "ncc build --source-map src/action.ts --license licenses.txt",
"test": "jest",
"all": "npm run lint && npm run prepare && npm run test"
},
Expand Down
6 changes: 1 addition & 5 deletions actions/checkstyle/src/action.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { debug, getInput, setFailed } from "@actions/core";
import { getInput, setFailed } from "@actions/core";
import { run as realRun } from "./checkstyle";

async function run(): Promise<void> {
debug("start");
const checkstyleFile = getInput("file");
debug("checkstyleFile: " + checkstyleFile);
const pathTrim = getInput("pathTrim");
debug("pathTrim: " + pathTrim);
realRun(checkstyleFile, pathTrim);
debug("end");
}

run().catch((err) => {
Expand Down
4 changes: 2 additions & 2 deletions actions/checkstyle/src/checkstyle.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { debug } from "@actions/core";
import { readFileSync, existsSync } from "fs";
import { XMLParser } from "fast-xml-parser";
import { Problem } from "pmd";
import { logProblems } from "pmd";
import { Problem } from "pmd/src/pmd";
import { logProblems } from "pmd/src/pmd";
import { sep, join } from "path";

interface Violations {
Expand Down
45 changes: 15 additions & 30 deletions actions/pmd/dist/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/******/ (() => { // webpackBootstrap
require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({

/***/ 9548:
Expand Down Expand Up @@ -28909,23 +28909,6 @@ module.exports = parseParams
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __nccwpck_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __nccwpck_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
Expand All @@ -28949,12 +28932,6 @@ var __webpack_exports__ = {};
// ESM COMPAT FLAG
__nccwpck_require__.r(__webpack_exports__);

// EXPORTS
__nccwpck_require__.d(__webpack_exports__, {
"logProblems": () => (/* reexport */ logProblems),
"parseData": () => (/* binding */ parseData)
});

// EXTERNAL MODULE: ../../node_modules/@actions/core/lib/core.js
var core = __nccwpck_require__(7117);
// EXTERNAL MODULE: external "fs"
Expand All @@ -28975,7 +28952,7 @@ function logProblems(problems) {
}
}

;// CONCATENATED MODULE: ./src/action.ts
;// CONCATENATED MODULE: ./src/pmd.ts



Expand Down Expand Up @@ -29019,17 +28996,25 @@ function parseData(sourceDirectory, data) {
}
return problems;
}
async function run() {
const pmdFile = (0,core.getInput)("file");
const sourceDir = (0,core.getInput)("src");
function run(sourceDir, pmdFile) {
const data = (0,external_fs_.readFileSync)(pmdFile);
(0,core.debug)(data.toString());
logProblems(parseData(sourceDir, data));
}
run().catch((err) => (0,core.setFailed)(err));

;// CONCATENATED MODULE: ./src/action.ts


async function action_run() {
const pmdFile = (0,core.getInput)("file");
const sourceDir = (0,core.getInput)("src");
run(sourceDir, pmdFile);
}
action_run().catch((err) => (0,core.setFailed)(err));

})();

module.exports = __webpack_exports__;
/******/ })()
;
;
//# sourceMappingURL=index.js.map
1 change: 1 addition & 0 deletions actions/pmd/dist/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions actions/pmd/dist/sourcemap-register.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion actions/pmd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "src/action.ts",
"scripts": {
"lint": "eslint src",
"prepare": "ncc build src/action.ts --license licenses.txt",
"prepare": "ncc build --source-map src/action.ts --license licenses.txt",
"test": "jest",
"all": "npm run lint && npm run prepare && npm run test"
},
Expand Down
2 changes: 1 addition & 1 deletion actions/pmd/src/action.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseData } from "./action";
import { parseData } from "./pmd";
import { describe, expect, test } from "@jest/globals";
import { expectProblem } from "./problem.test";

Expand Down
71 changes: 3 additions & 68 deletions actions/pmd/src/action.ts
Original file line number Diff line number Diff line change
@@ -1,75 +1,10 @@
import { debug, getInput, setFailed } from "@actions/core";
import { readFileSync } from "fs";
import { XMLParser } from "fast-xml-parser";
import { logProblems } from "./logProblems";
import { Problem } from "./problem";

export { Problem, logProblems };

type Violation = {
"@_ruleset": string;
"@_rule": string;
"@_begincolumn": string;
"@_endcolumn": string;
"@_beginline": string;
"@_endline": string;
"@_externalInfoUrl": string;
};
type FileData = {
violation: Violation[];
"@_name": string;
};

function parseFile(sourceDirectory: string, fileData: FileData): Problem[] {
const file =
(sourceDirectory.length > 0 && !sourceDirectory.endsWith("/")
? sourceDirectory + "/"
: sourceDirectory) + fileData["@_name"];
const violations = fileData["violation"];
const problems: Problem[] = [];
for (const violation of violations) {
const title = violation["@_ruleset"] + "/" + violation["@_rule"];
problems.push({
file: file,
title: title,
startColumn: parseInt(violation["@_begincolumn"]),
endColumn: parseInt(violation["@_endcolumn"]),
startLine: parseInt(violation["@_beginline"]),
endLine: parseInt(violation["@_endline"]),
info: violation["@_externalInfoUrl"],
});
}
return problems;
}

export function parseData(
sourceDirectory: string,
data: string | Buffer,
): Problem[] {
const alwaysArray = ["pmd.file", "pmd.file.violation"];
const parser = new XMLParser({
ignoreAttributes: false,
isArray: (name, jpath) => {
return alwaysArray.indexOf(jpath) >= 0;
},
});
const parsed = parser.parse(data);
const files = parsed["pmd"]["file"];
let problems: Problem[] = [];
if (files !== undefined && files !== null) {
for (const file of files) {
problems = problems.concat(parseFile(sourceDirectory, file));
}
}
return problems;
}
import { getInput, setFailed } from "@actions/core";
import { run as realRun } from "./pmd";

async function run(): Promise<void> {
const pmdFile = getInput("file");
const sourceDir = getInput("src");
const data = readFileSync(pmdFile);
debug(data.toString());
logProblems(parseData(sourceDir, data));
realRun(sourceDir, pmdFile);
}

run().catch((err) => setFailed(err));
71 changes: 71 additions & 0 deletions actions/pmd/src/pmd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { debug } from "@actions/core";
import { readFileSync } from "fs";
import { XMLParser } from "fast-xml-parser";
import { logProblems } from "./logProblems";
import { Problem } from "./problem";

export { Problem, logProblems };

type Violation = {
"@_ruleset": string;
"@_rule": string;
"@_begincolumn": string;
"@_endcolumn": string;
"@_beginline": string;
"@_endline": string;
"@_externalInfoUrl": string;
};
type FileData = {
violation: Violation[];
"@_name": string;
};

function parseFile(sourceDirectory: string, fileData: FileData): Problem[] {
const file =
(sourceDirectory.length > 0 && !sourceDirectory.endsWith("/")
? sourceDirectory + "/"
: sourceDirectory) + fileData["@_name"];
const violations = fileData["violation"];
const problems: Problem[] = [];
for (const violation of violations) {
const title = violation["@_ruleset"] + "/" + violation["@_rule"];
problems.push({
file: file,
title: title,
startColumn: parseInt(violation["@_begincolumn"]),
endColumn: parseInt(violation["@_endcolumn"]),
startLine: parseInt(violation["@_beginline"]),
endLine: parseInt(violation["@_endline"]),
info: violation["@_externalInfoUrl"],
});
}
return problems;
}

export function parseData(
sourceDirectory: string,
data: string | Buffer,
): Problem[] {
const alwaysArray = ["pmd.file", "pmd.file.violation"];
const parser = new XMLParser({
ignoreAttributes: false,
isArray: (name, jpath) => {
return alwaysArray.indexOf(jpath) >= 0;
},
});
const parsed = parser.parse(data);
const files = parsed["pmd"]["file"];
let problems: Problem[] = [];
if (files !== undefined && files !== null) {
for (const file of files) {
problems = problems.concat(parseFile(sourceDirectory, file));
}
}
return problems;
}

export function run(sourceDir: string, pmdFile: string) {
const data = readFileSync(pmdFile);
debug(data.toString());
logProblems(parseData(sourceDir, data));
}
6 changes: 3 additions & 3 deletions package-lock.json

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

0 comments on commit 0d2cdfb

Please sign in to comment.