Skip to content

Commit

Permalink
Check that job summary support is available
Browse files Browse the repository at this point in the history
Fixes #319
  • Loading branch information
bigdaz committed Jun 9, 2022
1 parent ee54c1f commit f3e4903
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 22 deletions.
33 changes: 24 additions & 9 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65988,6 +65988,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Expand All @@ -65998,15 +66007,17 @@ const fs_1 = __importDefault(__nccwpck_require__(7147));
const path_1 = __importDefault(__nccwpck_require__(1017));
const cache_reporting_1 = __nccwpck_require__(6674);
function writeJobSummary(buildResults, cacheListener) {
core.info('Writing job summary');
if (buildResults.length === 0) {
core.debug('No Gradle build results found. Summary table will not be generated.');
}
else {
writeSummaryTable(buildResults);
}
(0, cache_reporting_1.logCachingReport)(cacheListener);
core.summary.write();
return __awaiter(this, void 0, void 0, function* () {
core.info('Writing job summary');
if (buildResults.length === 0) {
core.debug('No Gradle build results found. Summary table will not be generated.');
}
else {
writeSummaryTable(buildResults);
}
(0, cache_reporting_1.logCachingReport)(cacheListener);
yield core.summary.write();
});
}
exports.writeJobSummary = writeJobSummary;
function loadBuildResults() {
Expand Down Expand Up @@ -66392,6 +66403,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.complete = exports.setup = void 0;
const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514));
const summary_1 = __nccwpck_require__(1327);
const fs = __importStar(__nccwpck_require__(7147));
const path = __importStar(__nccwpck_require__(1017));
const os = __importStar(__nccwpck_require__(2037));
Expand All @@ -66403,6 +66415,9 @@ const GRADLE_USER_HOME = 'GRADLE_USER_HOME';
const CACHE_LISTENER = 'CACHE_LISTENER';
const JOB_SUMMARY_ENABLED_PARAMETER = 'generate-job-summary';
function shouldGenerateJobSummary() {
if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
return false;
}
return core.getBooleanInput(JOB_SUMMARY_ENABLED_PARAMETER);
}
function setup(buildRootDirectory) {
Expand Down
2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

33 changes: 24 additions & 9 deletions dist/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64908,6 +64908,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Expand All @@ -64918,15 +64927,17 @@ const fs_1 = __importDefault(__nccwpck_require__(7147));
const path_1 = __importDefault(__nccwpck_require__(1017));
const cache_reporting_1 = __nccwpck_require__(6674);
function writeJobSummary(buildResults, cacheListener) {
core.info('Writing job summary');
if (buildResults.length === 0) {
core.debug('No Gradle build results found. Summary table will not be generated.');
}
else {
writeSummaryTable(buildResults);
}
(0, cache_reporting_1.logCachingReport)(cacheListener);
core.summary.write();
return __awaiter(this, void 0, void 0, function* () {
core.info('Writing job summary');
if (buildResults.length === 0) {
core.debug('No Gradle build results found. Summary table will not be generated.');
}
else {
writeSummaryTable(buildResults);
}
(0, cache_reporting_1.logCachingReport)(cacheListener);
yield core.summary.write();
});
}
exports.writeJobSummary = writeJobSummary;
function loadBuildResults() {
Expand Down Expand Up @@ -65076,6 +65087,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.complete = exports.setup = void 0;
const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514));
const summary_1 = __nccwpck_require__(1327);
const fs = __importStar(__nccwpck_require__(7147));
const path = __importStar(__nccwpck_require__(1017));
const os = __importStar(__nccwpck_require__(2037));
Expand All @@ -65087,6 +65099,9 @@ const GRADLE_USER_HOME = 'GRADLE_USER_HOME';
const CACHE_LISTENER = 'CACHE_LISTENER';
const JOB_SUMMARY_ENABLED_PARAMETER = 'generate-job-summary';
function shouldGenerateJobSummary() {
if (!process.env[summary_1.SUMMARY_ENV_VAR]) {
return false;
}
return core.getBooleanInput(JOB_SUMMARY_ENABLED_PARAMETER);
}
function setup(buildRootDirectory) {
Expand Down
2 changes: 1 addition & 1 deletion dist/post/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/job-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface BuildResult {
get buildScanUri(): string
}

export function writeJobSummary(buildResults: BuildResult[], cacheListener: CacheListener): void {
export async function writeJobSummary(buildResults: BuildResult[], cacheListener: CacheListener): Promise<void> {
core.info('Writing job summary')

if (buildResults.length === 0) {
Expand All @@ -24,7 +24,7 @@ export function writeJobSummary(buildResults: BuildResult[], cacheListener: Cach

logCachingReport(cacheListener)

core.summary.write()
await core.summary.write()
}

export function loadBuildResults(): BuildResult[] {
Expand Down
6 changes: 6 additions & 0 deletions src/setup-gradle.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import {SUMMARY_ENV_VAR} from '@actions/core/lib/summary'
import * as fs from 'fs'
import * as path from 'path'
import * as os from 'os'
Expand All @@ -14,6 +15,11 @@ const CACHE_LISTENER = 'CACHE_LISTENER'
const JOB_SUMMARY_ENABLED_PARAMETER = 'generate-job-summary'

function shouldGenerateJobSummary(): boolean {
// Check if Job Summary is supported on this platform
if (!process.env[SUMMARY_ENV_VAR]) {
return false
}

return core.getBooleanInput(JOB_SUMMARY_ENABLED_PARAMETER)
}

Expand Down

0 comments on commit f3e4903

Please sign in to comment.