From 0c39d22e8a1bf5e8eb3fdebf12bfa23af7540ffd Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Fri, 2 Aug 2024 21:29:09 +0200 Subject: [PATCH 1/3] Check input for empty directories --- .github/workflows/ci.yaml | 14 ++++++++++++++ README.md | 6 ++++-- dist/index.js | 4 ++++ src/main.ts | 6 ++++++ 4 files changed, 28 insertions(+), 2 deletions(-) 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/README.md b/README.md index 7c7d9d6..26e4cca 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,10 @@ jobs: buf: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: bufbuild/buf-action@v1 + - name: Checkout code + uses: actions/checkout@v4 + - name: Run Buf + uses: bufbuild/buf-action@v1 with: token: ${{ secrets.BUF_TOKEN }} ``` diff --git a/dist/index.js b/dist/index.js index 2592202..6598321 100644 --- a/dist/index.js +++ b/dist/index.js @@ -45828,6 +45828,10 @@ 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("Empty repository detected, ensure the repository is checked out"); + return steps; + } return steps; } const checks = await Promise.all([ diff --git a/src/main.ts b/src/main.ts index d0d3ddf..a309369 100644 --- a/src/main.ts +++ b/src/main.ts @@ -153,6 +153,12 @@ 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( + "Empty repository detected, ensure the repository is checked out", + ); + return steps; + } return steps; } const checks = await Promise.all([ From 69a7b9d1286123dd4833827d5f68ff76e01b1867 Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Tue, 6 Aug 2024 18:49:35 +0200 Subject: [PATCH 2/3] Update error message --- dist/index.js | 3 +-- src/main.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 6598321..8b5b3db 100644 --- a/dist/index.js +++ b/dist/index.js @@ -45829,8 +45829,7 @@ async function runWorkflow(bufPath, inputs, moduleNames) { steps.build = await build(bufPath, inputs); if (steps.build.status == Status.Failed) { if (steps.build.stderr.match(/had no .proto files/)) { - core.info("Empty repository detected, ensure the repository is checked out"); - return steps; + core.info('Did you forget to add the "actions/checkout@v4" checkout step to your workflow?'); } return steps; } diff --git a/src/main.ts b/src/main.ts index a309369..43ad520 100644 --- a/src/main.ts +++ b/src/main.ts @@ -155,9 +155,8 @@ async function runWorkflow( if (steps.build.status == Status.Failed) { if (steps.build.stderr.match(/had no .proto files/)) { core.info( - "Empty repository detected, ensure the repository is checked out", + 'Did you forget to add the "actions/checkout@v4" checkout step to your workflow?', ); - return steps; } return steps; } From e316bf08ec5f26eecd49579dbf2ec2143a80de95 Mon Sep 17 00:00:00 2001 From: Edward McFarlane <3036610+emcfarlane@users.noreply.github.com> Date: Tue, 6 Aug 2024 20:06:51 +0200 Subject: [PATCH 3/3] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 26e4cca..7c7d9d6 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,8 @@ jobs: buf: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Run Buf - uses: bufbuild/buf-action@v1 + - uses: actions/checkout@v4 + - uses: bufbuild/buf-action@v1 with: token: ${{ secrets.BUF_TOKEN }} ```