diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0c49f3a..87fe9de 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,7 +8,7 @@ permissions: contents: read pull-requests: write env: - BUF_VERSION: "1.32.1" + BUF_VERSION: "1.32.2" jobs: build: runs-on: ubuntu-latest diff --git a/dist/index.js b/dist/index.js index 267696b..65ab794 100644 --- a/dist/index.js +++ b/dist/index.js @@ -37788,7 +37788,6 @@ async function commentOnPR(context, github, comment) { async function main() { const inputs = getInputs(); - core.debug(`inputs: ${JSON.stringify(inputs, null, 2)}`); const github = (0,lib_github.getOctokit)(inputs.github_token); const bufPath = await installBuf(github, inputs.version); await login(bufPath, inputs); @@ -37819,8 +37818,8 @@ async function main() { // NB: Write empties the buffer must be after the comment. await summary.write(); // Finally, set the status of the action. - for (const key of Object.keys(steps)) { - if (steps[key].status == Status.Failed) { + for (const [key, value] of Object.entries(steps)) { + if (value?.status == Status.Failed) { core.setFailed(`Failed ${key}`); } } @@ -37828,38 +37827,24 @@ async function main() { main() .catch((err) => core.setFailed(err.message)) .then(() => core.debug(`done in ${process.uptime()} s`)); -class Steps { - build; - lint; - format; - breaking; - push; - archive; -} // runWorkflow runs the buf workflow. It returns the results of each step. // First, it builds the input. If the build fails, the workflow stops. // Next, it runs lint, format, and breaking checks. If any of these fail, the workflow stops. // Finally, it pushes or archives the label to the registry. async function runWorkflow(bufPath, inputs) { - const steps = new Steps(); + const steps = {}; steps.build = await build(bufPath, inputs); if (steps.build.status == Status.Failed) { return steps; } const checks = await Promise.all([ - lint(bufPath, inputs).then((result) => { - steps.lint = result; - return result; - }), - format(bufPath, inputs).then((result) => { - steps.format = result; - return result; - }), - breaking(bufPath, inputs).then((result) => { - steps.breaking = result; - return result; - }), + lint(bufPath, inputs), + format(bufPath, inputs), + breaking(bufPath, inputs), ]); + steps.lint = checks[0]; + steps.format = checks[1]; + steps.breaking = checks[2]; if (checks.some((result) => result.status == Status.Failed)) { return steps; } @@ -37908,7 +37893,7 @@ async function build(bufPath, inputs) { async function lint(bufPath, inputs) { if (!inputs.lint) { core.info("Skipping lint"); - return Promise.resolve(skip()); + return skip(); } const args = ["lint", "--error-format", "github-actions"]; if (inputs.input) { diff --git a/src/main.ts b/src/main.ts index a9de9f9..08b4b60 100644 --- a/src/main.ts +++ b/src/main.ts @@ -22,7 +22,6 @@ import { commentOnPR } from "./comment"; async function main() { const inputs = getInputs(); - core.debug(`inputs: ${JSON.stringify(inputs, null, 2)}`); const github = getOctokit(inputs.github_token); const bufPath = await installBuf(github, inputs.version); await login(bufPath, inputs); @@ -55,8 +54,11 @@ async function main() { // NB: Write empties the buffer must be after the comment. await summary.write(); // Finally, set the status of the action. - for (const key of Object.keys(steps)) { - if (steps[key].status == Status.Failed) { + for (const [key, value] of Object.entries(steps) as [ + keyof Steps, + Result | undefined, + ][]) { + if (value?.status == Status.Failed) { core.setFailed(`Failed ${key}`); } } @@ -66,13 +68,13 @@ main() .catch((err) => core.setFailed(err.message)) .then(() => core.debug(`done in ${process.uptime()} s`)); -class Steps { - build: Result; - lint: Result; - format: Result; - breaking: Result; - push: Result; - archive: Result; +interface Steps { + build?: Result; + lint?: Result; + format?: Result; + breaking?: Result; + push?: Result; + archive?: Result; } // runWorkflow runs the buf workflow. It returns the results of each step. @@ -80,25 +82,19 @@ class Steps { // Next, it runs lint, format, and breaking checks. If any of these fail, the workflow stops. // Finally, it pushes or archives the label to the registry. async function runWorkflow(bufPath: string, inputs: Inputs): Promise { - const steps = new Steps(); + const steps: Steps = {}; steps.build = await build(bufPath, inputs); if (steps.build.status == Status.Failed) { return steps; } const checks = await Promise.all([ - lint(bufPath, inputs).then((result) => { - steps.lint = result; - return result; - }), - format(bufPath, inputs).then((result) => { - steps.format = result; - return result; - }), - breaking(bufPath, inputs).then((result) => { - steps.breaking = result; - return result; - }), + lint(bufPath, inputs), + format(bufPath, inputs), + breaking(bufPath, inputs), ]); + steps.lint = checks[0]; + steps.format = checks[1]; + steps.breaking = checks[2]; if (checks.some((result) => result.status == Status.Failed)) { return steps; } @@ -154,7 +150,7 @@ async function build(bufPath: string, inputs: Inputs): Promise { async function lint(bufPath: string, inputs: Inputs): Promise { if (!inputs.lint) { core.info("Skipping lint"); - return Promise.resolve(skip()); + return skip(); } const args = ["lint", "--error-format", "github-actions"]; if (inputs.input) {