From 5210588df4c62f8110bf3c577c81a9abeaddca93 Mon Sep 17 00:00:00 2001 From: Edward McFarlane <3036610+emcfarlane@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:59:27 -0400 Subject: [PATCH] Check input for empty directories (#62) To provide better errors we can map some of the buf errors to config issue errors. It's easy to miss the `- uses: actions/checkout@v4` step, provide an annotation to help resolve issues. This adds an info log: ```diff /opt/hostedtoolcache/buf/1.35.0/x64/buf build --error-format github-actions Failure: "." had no .proto files +Did you forget to add the "actions/checkout@v4" checkout step to your workflow? Error: Failed build ``` --- .github/workflows/ci.yaml | 14 ++++++++++++++ dist/index.js | 3 +++ src/main.ts | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1b15ce4..eeda9d5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -79,6 +79,20 @@ jobs: with: setup_only: true - run: buf --version | grep $BUF_VERSION + test-empty-build: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + lint: false + format: false + breaking: false + push: false + archive: false + pr_comment: false + continue-on-error: true # build fails test-lint: runs-on: ubuntu-latest needs: build diff --git a/dist/index.js b/dist/index.js index 2592202..8b5b3db 100644 --- a/dist/index.js +++ b/dist/index.js @@ -45828,6 +45828,9 @@ async function runWorkflow(bufPath, inputs, moduleNames) { const steps = {}; steps.build = await build(bufPath, inputs); if (steps.build.status == Status.Failed) { + if (steps.build.stderr.match(/had no .proto files/)) { + core.info('Did you forget to add the "actions/checkout@v4" checkout step to your workflow?'); + } return steps; } const checks = await Promise.all([ diff --git a/src/main.ts b/src/main.ts index d0d3ddf..43ad520 100644 --- a/src/main.ts +++ b/src/main.ts @@ -153,6 +153,11 @@ async function runWorkflow( const steps: Steps = {}; steps.build = await build(bufPath, inputs); if (steps.build.status == Status.Failed) { + if (steps.build.stderr.match(/had no .proto files/)) { + core.info( + 'Did you forget to add the "actions/checkout@v4" checkout step to your workflow?', + ); + } return steps; } const checks = await Promise.all([