diff --git a/plugins/unity/dist/unity-test-runner/model/results-check-templates.d.ts b/plugins/unity/dist/unity-test-runner/model/results-check-templates.d.ts new file mode 100644 index 00000000..ed242e00 --- /dev/null +++ b/plugins/unity/dist/unity-test-runner/model/results-check-templates.d.ts @@ -0,0 +1,2 @@ +export declare const RESULTS_CHECK_SUMMARY_TEMPLATE = "{{#runs}}\n ###\n {{summary}}\n{{/runs}}\n"; +export declare const RESULTS_CHECK_DETAILS_TEMPLATE = "{{#runs}}\n\n
{{summary}}\n\n {{#suites}}\n *\n {{summary}}\n {{#tests}}\n *\n {{summary}}\n {{#if annotation}}\n {{#if annotation.message}}\n {{indent annotation.message}}\n {{/if}}\n {{#if annotation.raw_details}}\n {{indent annotation.raw_details}}\n {{/if}}\n {{/if}}\n {{/tests}}\n {{/suites}}\n\n
\n\n{{/runs}}\n"; diff --git a/plugins/unity/dist/unity-test-runner/model/results-check-templates.js b/plugins/unity/dist/unity-test-runner/model/results-check-templates.js new file mode 100644 index 00000000..c55bbad8 --- /dev/null +++ b/plugins/unity/dist/unity-test-runner/model/results-check-templates.js @@ -0,0 +1,42 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.RESULTS_CHECK_DETAILS_TEMPLATE = exports.RESULTS_CHECK_SUMMARY_TEMPLATE = void 0; +// Source of truth is ../views/*.hbs — keep both in sync if the templates change. +// Inlined (rather than read from disk via Action.actionFolder) because these +// two tiny templates have no reason to depend on runtime path resolution: a +// bundled/compiled game-ci binary doesn't preserve the plugin's own +// src/**/dist/ staging layout that Action.actionFolder assumes, so a +// filesystem lookup for them is fragile in exactly the context these run in +// (see game-ci/unity-test-runner#310's CI - all matrix jobs failed with an +// ENOENT for results-check-summary.hbs once the wrapper stopped shipping its +// own dist/ alongside the compiled action code). +exports.RESULTS_CHECK_SUMMARY_TEMPLATE = `{{#runs}} + ### + {{summary}} +{{/runs}} +`; +exports.RESULTS_CHECK_DETAILS_TEMPLATE = `{{#runs}} + +
{{summary}} + + {{#suites}} + * + {{summary}} + {{#tests}} + * + {{summary}} + {{#if annotation}} + {{#if annotation.message}} + {{indent annotation.message}} + {{/if}} + {{#if annotation.raw_details}} + {{indent annotation.raw_details}} + {{/if}} + {{/if}} + {{/tests}} + {{/suites}} + +
+ +{{/runs}} +`; diff --git a/plugins/unity/dist/unity-test-runner/model/results-check.d.ts b/plugins/unity/dist/unity-test-runner/model/results-check.d.ts index f1034aed..3f721952 100644 --- a/plugins/unity/dist/unity-test-runner/model/results-check.d.ts +++ b/plugins/unity/dist/unity-test-runner/model/results-check.d.ts @@ -3,6 +3,6 @@ declare const ResultsCheck: { requestGitHubCheck(githubToken: any, checkName: any, output: any): Promise; renderSummary(runMetas: any): Promise; renderDetails(runMetas: any): Promise; - render(viewPath: any, runMetas: any): Promise; + render(source: any, runMetas: any): Promise; }; export default ResultsCheck; diff --git a/plugins/unity/dist/unity-test-runner/model/results-check.js b/plugins/unity/dist/unity-test-runner/model/results-check.js index 2efdd48f..027a6457 100644 --- a/plugins/unity/dist/unity-test-runner/model/results-check.js +++ b/plugins/unity/dist/unity-test-runner/model/results-check.js @@ -43,7 +43,7 @@ const handlebars_1 = __importDefault(require("handlebars")); const results_parser_1 = __importDefault(require("./results-parser")); const results_meta_1 = require("./results-meta"); const path_1 = __importDefault(require("path")); -const action_1 = __importDefault(require("./action")); +const results_check_templates_1 = require("./results-check-templates"); const ResultsCheck = { async createCheck(artifactsPath, githubToken, checkName) { // Validate input @@ -134,17 +134,16 @@ const ResultsCheck = { await octokit.rest.checks.create(createCheckRequest); }, async renderSummary(runMetas) { - return ResultsCheck.render(`${action_1.default.actionFolder}/results-check-summary.hbs`, runMetas); + return ResultsCheck.render(results_check_templates_1.RESULTS_CHECK_SUMMARY_TEMPLATE, runMetas); }, async renderDetails(runMetas) { - return ResultsCheck.render(`${action_1.default.actionFolder}/results-check-details.hbs`, runMetas); + return ResultsCheck.render(results_check_templates_1.RESULTS_CHECK_DETAILS_TEMPLATE, runMetas); }, - async render(viewPath, runMetas) { + async render(source, runMetas) { handlebars_1.default.registerHelper('indent', (toIndent) => toIndent .split('\n') .map((s) => ` ${s.replace('/github/workspace/', '')}`) .join('\n')); - const source = await fs.promises.readFile(viewPath, 'utf8'); const template = handlebars_1.default.compile(source); return template({ runs: runMetas }, { allowProtoMethodsByDefault: true, diff --git a/plugins/unity/src/unity-test-runner/model/results-check-templates.ts b/plugins/unity/src/unity-test-runner/model/results-check-templates.ts new file mode 100644 index 00000000..cc958085 --- /dev/null +++ b/plugins/unity/src/unity-test-runner/model/results-check-templates.ts @@ -0,0 +1,40 @@ +// Source of truth is ../views/*.hbs — keep both in sync if the templates change. +// Inlined (rather than read from disk via Action.actionFolder) because these +// two tiny templates have no reason to depend on runtime path resolution: a +// bundled/compiled game-ci binary doesn't preserve the plugin's own +// src/**/dist/ staging layout that Action.actionFolder assumes, so a +// filesystem lookup for them is fragile in exactly the context these run in +// (see game-ci/unity-test-runner#310's CI - all matrix jobs failed with an +// ENOENT for results-check-summary.hbs once the wrapper stopped shipping its +// own dist/ alongside the compiled action code). +export const RESULTS_CHECK_SUMMARY_TEMPLATE = `{{#runs}} + ### + {{summary}} +{{/runs}} +`; + +export const RESULTS_CHECK_DETAILS_TEMPLATE = `{{#runs}} + +
{{summary}} + + {{#suites}} + * + {{summary}} + {{#tests}} + * + {{summary}} + {{#if annotation}} + {{#if annotation.message}} + {{indent annotation.message}} + {{/if}} + {{#if annotation.raw_details}} + {{indent annotation.raw_details}} + {{/if}} + {{/if}} + {{/tests}} + {{/suites}} + +
+ +{{/runs}} +`; diff --git a/plugins/unity/src/unity-test-runner/model/results-check.ts b/plugins/unity/src/unity-test-runner/model/results-check.ts index 2c0defa5..4d8682a9 100644 --- a/plugins/unity/src/unity-test-runner/model/results-check.ts +++ b/plugins/unity/src/unity-test-runner/model/results-check.ts @@ -5,7 +5,7 @@ import Handlebars from 'handlebars'; import ResultsParser from './results-parser'; import { RunMeta } from './results-meta'; import path from 'path'; -import Action from './action'; +import { RESULTS_CHECK_DETAILS_TEMPLATE, RESULTS_CHECK_SUMMARY_TEMPLATE } from './results-check-templates'; const ResultsCheck = { async createCheck(artifactsPath, githubToken, checkName) { @@ -109,21 +109,20 @@ const ResultsCheck = { }, async renderSummary(runMetas) { - return ResultsCheck.render(`${Action.actionFolder}/results-check-summary.hbs`, runMetas); + return ResultsCheck.render(RESULTS_CHECK_SUMMARY_TEMPLATE, runMetas); }, async renderDetails(runMetas) { - return ResultsCheck.render(`${Action.actionFolder}/results-check-details.hbs`, runMetas); + return ResultsCheck.render(RESULTS_CHECK_DETAILS_TEMPLATE, runMetas); }, - async render(viewPath, runMetas) { + async render(source, runMetas) { Handlebars.registerHelper('indent', (toIndent) => toIndent .split('\n') .map((s) => ` ${s.replace('/github/workspace/', '')}`) .join('\n'), ); - const source = await fs.promises.readFile(viewPath, 'utf8'); const template = Handlebars.compile(source); return template( { runs: runMetas },