Skip to content
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
Original file line number Diff line number Diff line change
@@ -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 <details><summary>{{summary}}</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 </details>\n\n{{/runs}}\n";
Original file line number Diff line number Diff line change
@@ -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}}

<details><summary>{{summary}}</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}}

</details>

{{/runs}}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ declare const ResultsCheck: {
requestGitHubCheck(githubToken: any, checkName: any, output: any): Promise<void>;
renderSummary(runMetas: any): Promise<string>;
renderDetails(runMetas: any): Promise<string>;
render(viewPath: any, runMetas: any): Promise<string>;
render(source: any, runMetas: any): Promise<string>;
};
export default ResultsCheck;
9 changes: 4 additions & 5 deletions plugins/unity/dist/unity-test-runner/model/results-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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}}

<details><summary>{{summary}}</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}}

</details>

{{/runs}}
`;
9 changes: 4 additions & 5 deletions plugins/unity/src/unity-test-runner/model/results-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 },
Expand Down
Loading