From 66ea6a484fe3d8408e1733c6e3959ec34f8cdb77 Mon Sep 17 00:00:00 2001 From: Adam Velebil Date: Fri, 15 Dec 2023 13:47:25 +0100 Subject: [PATCH] build path from repo root --- .../publish-spotbugs-reports/dist/index.js | 25 ++++++++++++++----- .../actions/publish-spotbugs-reports/index.js | 17 ++++++++----- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/actions/publish-spotbugs-reports/dist/index.js b/.github/actions/publish-spotbugs-reports/dist/index.js index c4ea7852..04b0b7ab 100644 --- a/.github/actions/publish-spotbugs-reports/dist/index.js +++ b/.github/actions/publish-spotbugs-reports/dist/index.js @@ -33564,6 +33564,14 @@ module.exports = require("node:events"); /***/ }), +/***/ 9411: +/***/ ((module) => { + +"use strict"; +module.exports = require("node:path"); + +/***/ }), + /***/ 4492: /***/ ((module) => { @@ -35349,16 +35357,16 @@ const { getOctokit, context } = __nccwpck_require__(3617) const glob = __nccwpck_require__(3823) const { XMLParser } = __nccwpck_require__(8396) const { readFileSync } = __nccwpck_require__(7147) +const path = __nccwpck_require__(9411) -function bugAnnotation(bug) { +function bugAnnotation(moduleDirName, bug) { if (Object.hasOwn(bug, 'Method') && !Array.isArray(bug.Method)) { - console.log(`Processing ${JSON.stringify(bug, null, 4)}`) + //console.log(`Processing ${JSON.stringify(bug, null, 4)}`) const title = `${bug.ShortMessage} (${bug['@_category']})` const message = `${bug.LongMessage}\n\nSummary:\n...` const rawDetails = bug.LongMessage - const path = bug.Method.SourceLine.hasOwnProperty('@_relSourcePath') - ? bug.Method.SourceLine['@_relSourcepath'] - : bug.Method.SourceLine['@_sourcepath'] + const path = + moduleDirName + '/src/main/java/' + bug.Method.SourceLine['@_sourcepath'] return { title: title, message: message, @@ -35385,6 +35393,11 @@ async function getAnnotations() { annotations = [] for await (const reportFile of globber.globGenerator()) { + console.log(`Processing ${reportFile}`) + const moduleDirName = path.basename( + path.normalize(path.dirname(reportFile) + '../../../../'), + ) + console.log(`dirname: ${moduleDirName}`) const parser = new XMLParser(parseOptions) let data = parser.parse(readFileSync(reportFile)) @@ -35394,7 +35407,7 @@ async function getAnnotations() { ) for (const bugInstance of data.BugCollection.BugInstance) { - const annotation = bugAnnotation(bugInstance) + const annotation = bugAnnotation(moduleDirName, bugInstance) if (annotation != null) { annotations.push(annotation) } diff --git a/.github/actions/publish-spotbugs-reports/index.js b/.github/actions/publish-spotbugs-reports/index.js index 21553f51..294f0652 100644 --- a/.github/actions/publish-spotbugs-reports/index.js +++ b/.github/actions/publish-spotbugs-reports/index.js @@ -3,16 +3,16 @@ const { getOctokit, context } = require('@actions/github') const glob = require('@actions/glob') const { XMLParser } = require('fast-xml-parser') const { readFileSync } = require('fs') +const path = require('node:path') -function bugAnnotation(bug) { +function bugAnnotation(moduleDirName, bug) { if (Object.hasOwn(bug, 'Method') && !Array.isArray(bug.Method)) { - console.log(`Processing ${JSON.stringify(bug, null, 4)}`) + //console.log(`Processing ${JSON.stringify(bug, null, 4)}`) const title = `${bug.ShortMessage} (${bug['@_category']})` const message = `${bug.LongMessage}\n\nSummary:\n...` const rawDetails = bug.LongMessage - const path = bug.Method.SourceLine.hasOwnProperty('@_relSourcePath') - ? bug.Method.SourceLine['@_relSourcepath'] - : bug.Method.SourceLine['@_sourcepath'] + const path = + moduleDirName + '/src/main/java/' + bug.Method.SourceLine['@_sourcepath'] return { title: title, message: message, @@ -39,6 +39,11 @@ async function getAnnotations() { annotations = [] for await (const reportFile of globber.globGenerator()) { + console.log(`Processing ${reportFile}`) + const moduleDirName = path.basename( + path.normalize(path.dirname(reportFile) + '../../../../'), + ) + console.log(`dirname: ${moduleDirName}`) const parser = new XMLParser(parseOptions) let data = parser.parse(readFileSync(reportFile)) @@ -48,7 +53,7 @@ async function getAnnotations() { ) for (const bugInstance of data.BugCollection.BugInstance) { - const annotation = bugAnnotation(bugInstance) + const annotation = bugAnnotation(moduleDirName, bugInstance) if (annotation != null) { annotations.push(annotation) }