From e2522023e0c958acc0321073fa46b38988c51f7d Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 3 Apr 2021 15:37:46 +0200 Subject: [PATCH] Improve debugging --- .github/workflows/ci.yml | 10 +++++ README.md | 5 +++ dist/index.js | 80 +++++++++++++++++++++++++++++++++++++--- src/flavor.ts | 8 ++++ src/tag.ts | 37 +++++++++++++++---- 5 files changed, 126 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5a8193c9..f5ae03bc2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,9 @@ jobs: strategy: fail-fast: false matrix: + debug: + - "" + - "true" tag-schedule: - "" - "cron-{{date 'YYYYMMDD'}}" @@ -65,6 +68,8 @@ jobs: type=ref,event=tag type=ref,event=pr type=sha + env: + RUNNER_DEBUG: ${{ matrix.debug }} tag-match: runs-on: ubuntu-latest @@ -102,6 +107,9 @@ jobs: strategy: fail-fast: false matrix: + debug: + - "" + - "true" flavor-latest: - "auto" - "true" @@ -128,6 +136,8 @@ jobs: type=sha flavor: | latest=${{ matrix.flavor-latest }} + env: + RUNNER_DEBUG: ${{ matrix.debug }} flavor: runs-on: ubuntu-latest diff --git a/README.md b/README.md index 9a164ff27..6326e175b 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ ___ * [Notes](#notes) * [Latest tag](#latest-tag) * [Overwrite labels](#overwrite-labels) + * [Debug](#debug) * [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot) * [Contributing](#contributing) * [License](#license) @@ -573,6 +574,10 @@ labels generated are not suitable, you can overwrite them like this: org.opencontainers.image.vendor=MyCompany ``` +### Debug + +For more details, please enable debug logs by [adding secret `ACTIONS_STEP_DEBUG=true`](https://docs.github.com/en/actions/managing-workflow-runs/enabling-debug-logging#enabling-step-debug-logging). + ## Keep up-to-date with GitHub Dependabot Since [Dependabot](https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot) diff --git a/dist/index.js b/dist/index.js index b21ab7b51..17ea03dd8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -99,12 +99,32 @@ exports.asyncForEach = (array, callback) => __awaiter(void 0, void 0, void 0, fu /***/ }), /***/ 3716: -/***/ ((__unused_webpack_module, exports) => { +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.Transform = void 0; +const core = __importStar(__webpack_require__(2186)); function Transform(inputs) { const flavor = { latest: 'auto', @@ -137,6 +157,15 @@ function Transform(inputs) { } } } + if (core.isDebug()) { + core.startGroup(`Parsing flavor input`); + core.debug([ + `latest=${flavor.latest}`, + `prefix=${flavor.prefix}`, + `suffix=${flavor.suffix}`, + ].join(',')); + core.endGroup(); + } return flavor; } exports.Transform = Transform; @@ -690,12 +719,32 @@ exports.Meta = Meta; "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.Parse = exports.Transform = exports.DefaultPriorities = exports.RefEvent = exports.Type = void 0; +exports.Parse = exports.Transform = exports.DefaultPriorities = exports.Tag = exports.RefEvent = exports.Type = void 0; const sync_1 = __importDefault(__webpack_require__(8750)); +const core = __importStar(__webpack_require__(2186)); var Type; (function (Type) { Type["Schedule"] = "schedule"; @@ -712,6 +761,19 @@ var RefEvent; RefEvent["Tag"] = "tag"; RefEvent["PR"] = "pr"; })(RefEvent = exports.RefEvent || (exports.RefEvent = {})); +class Tag { + constructor() { + this.attrs = {}; + } + toString() { + const out = [`type=${this.type}`]; + for (let attr in this.attrs) { + out.push(`${attr}=${this.attrs[attr]}`); + } + return out.join(','); + } +} +exports.Tag = Tag; exports.DefaultPriorities = { [Type.Schedule]: '1000', [Type.Semver]: '900', @@ -735,7 +797,7 @@ function Transform(inputs) { for (const input of inputs) { tags.push(Parse(input)); } - return tags.sort((tag1, tag2) => { + const sorted = tags.sort((tag1, tag2) => { if (Number(tag1.attrs['priority']) < Number(tag2.attrs['priority'])) { return 1; } @@ -744,6 +806,14 @@ function Transform(inputs) { } return 0; }); + if (core.isDebug()) { + core.startGroup(`Parsing tags input`); + for (const tag of sorted) { + core.debug(tag.toString()); + } + core.endGroup(); + } + return sorted; } exports.Transform = Transform; function Parse(s) { @@ -751,9 +821,7 @@ function Parse(s) { relaxColumnCount: true, skipLinesWithEmptyValues: true })[0]; - const tag = { - attrs: {} - }; + const tag = new Tag(); for (const field of fields) { const parts = field.toString().split('=', 2); if (parts.length == 1) { diff --git a/src/flavor.ts b/src/flavor.ts index 3ae13b736..e4ed7a5ba 100644 --- a/src/flavor.ts +++ b/src/flavor.ts @@ -1,3 +1,5 @@ +import * as core from '@actions/core'; + export interface Flavor { latest: string; prefix: string; @@ -38,5 +40,11 @@ export function Transform(inputs: string[]): Flavor { } } + if (core.isDebug()) { + core.startGroup(`Parsing flavor input`); + core.debug([`latest=${flavor.latest}`, `prefix=${flavor.prefix}`, `suffix=${flavor.suffix}`].join(',')); + core.endGroup(); + } + return flavor; } diff --git a/src/tag.ts b/src/tag.ts index 0a935d11f..16d608010 100644 --- a/src/tag.ts +++ b/src/tag.ts @@ -1,4 +1,5 @@ import csvparse from 'csv-parse/lib/sync'; +import * as core from '@actions/core'; export enum Type { Schedule = 'schedule', @@ -16,9 +17,21 @@ export enum RefEvent { PR = 'pr' } -export interface Tag { - type: Type; - attrs: Record; +export class Tag { + public type?: Type; + public attrs: Record; + + constructor() { + this.attrs = {}; + } + + public toString(): string { + const out: string[] = [`type=${this.type}`]; + for (let attr in this.attrs) { + out.push(`${attr}=${this.attrs[attr]}`); + } + return out.join(','); + } } export const DefaultPriorities: Record = { @@ -42,10 +55,11 @@ export function Transform(inputs: string[]): Tag[] { `type=ref,event=${RefEvent.PR}` ]; } + for (const input of inputs) { tags.push(Parse(input)); } - return tags.sort((tag1, tag2) => { + const sorted = tags.sort((tag1, tag2) => { if (Number(tag1.attrs['priority']) < Number(tag2.attrs['priority'])) { return 1; } @@ -54,6 +68,16 @@ export function Transform(inputs: string[]): Tag[] { } return 0; }); + + if (core.isDebug()) { + core.startGroup(`Parsing tags input`); + for (const tag of sorted) { + core.debug(tag.toString()); + } + core.endGroup(); + } + + return sorted; } export function Parse(s: string): Tag { @@ -62,10 +86,7 @@ export function Parse(s: string): Tag { skipLinesWithEmptyValues: true })[0]; - const tag = { - attrs: {} - } as Tag; - + const tag = new Tag(); for (const field of fields) { const parts = field.toString().split('=', 2); if (parts.length == 1) {