From 74da2d8011a60eca257330db4cf2f1b02f92bbe2 Mon Sep 17 00:00:00 2001 From: quobix Date: Fri, 6 Jun 2025 07:43:03 -0700 Subject: [PATCH 01/12] tuning action --- .github/workflows/test_vacuum.yaml | 3 ++- action.yml | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test_vacuum.yaml b/.github/workflows/test_vacuum.yaml index 8b03030..72ad092 100644 --- a/.github/workflows/test_vacuum.yaml +++ b/.github/workflows/test_vacuum.yaml @@ -4,7 +4,7 @@ name: "Lint OpenAPI Spec and Comment on PR" on: push: branches: - - feature/docker-lint + - dev workflow_dispatch: {} permissions: @@ -23,3 +23,4 @@ jobs: uses: ./ with: openapi_path: "sample-specs/burgershop.yaml" + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/action.yml b/action.yml index 2facd1d..cc5a4f7 100644 --- a/action.yml +++ b/action.yml @@ -9,11 +9,13 @@ inputs: description: "Optional ruleset file or URL for vacuum lint (e.g. 'rules/ruleset.yaml')" required: false default: "" + github_token: + description: "GitHub token (needs write permissions on PRs to post comments)" + required: true outputs: report: - description: "Markdown-formatted lint report from vacuum" - # Note: you do NOT need to repeat 'value:' here; outputs get set by steps. + description: "Markdown‐formatted lint report from vacuum" runs: using: "composite" @@ -22,7 +24,6 @@ runs: id: lint shell: bash run: | - # Build the Docker command CMD="docker run --rm \ -v ${{ github.workspace }}:/work:ro \ dshanley/vacuum lint \ @@ -32,8 +33,6 @@ runs: fi echo "Running: $CMD" report=$($CMD) - - # Expose it as the action output named 'report' echo "::set-output name=report::$report" env: DOCKER_BUILDKIT: 1 @@ -42,11 +41,14 @@ runs: if: ${{ github.event_name == 'pull_request' }} uses: peter-evans/create-or-update-comment@v4 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ inputs.github_token }} repository: ${{ github.repository }} issue-number: ${{ github.event.pull_request.number }} body-includes: '' body: | ${{ steps.lint.outputs.report }} - edit-mode: replace \ No newline at end of file + edit-mode: replace + + + From 8de16814ad4b8e9d2a1c1a28f19b5577cff91bf1 Mon Sep 17 00:00:00 2001 From: quobix Date: Fri, 6 Jun 2025 07:48:48 -0700 Subject: [PATCH 02/12] tuning workflow --- .github/workflows/test_vacuum.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_vacuum.yaml b/.github/workflows/test_vacuum.yaml index 72ad092..a449f2d 100644 --- a/.github/workflows/test_vacuum.yaml +++ b/.github/workflows/test_vacuum.yaml @@ -2,7 +2,7 @@ name: "Lint OpenAPI Spec and Comment on PR" on: - push: + pull_request: branches: - dev workflow_dispatch: {} From 38dab5205e6498cf0e8e4331665fd5444a131324 Mon Sep 17 00:00:00 2001 From: quobix Date: Fri, 6 Jun 2025 07:50:53 -0700 Subject: [PATCH 03/12] tuning --- .github/workflows/test_vacuum.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_vacuum.yaml b/.github/workflows/test_vacuum.yaml index a449f2d..b657f2f 100644 --- a/.github/workflows/test_vacuum.yaml +++ b/.github/workflows/test_vacuum.yaml @@ -2,10 +2,12 @@ name: "Lint OpenAPI Spec and Comment on PR" on: + push: + branches: + - main pull_request: branches: - - dev - workflow_dispatch: {} + - main permissions: contents: read From 1debc1cc60ff8a5be2bdb818f32594aac070c1e9 Mon Sep 17 00:00:00 2001 From: quobix Date: Fri, 6 Jun 2025 07:58:30 -0700 Subject: [PATCH 04/12] tuning --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index cc5a4f7..3ad9bc9 100644 --- a/action.yml +++ b/action.yml @@ -44,10 +44,10 @@ runs: token: ${{ inputs.github_token }} repository: ${{ github.repository }} issue-number: ${{ github.event.pull_request.number }} - body-includes: '' + comment-id: ${{ steps.find-comment.outputs.comment-id }} body: | - ${{ steps.lint.outputs.report }} + ${{ steps.lint-step.outputs.report }} edit-mode: replace From b344f2c7575fb190817be4c23209a9959a9c6b4e Mon Sep 17 00:00:00 2001 From: quobix Date: Fri, 6 Jun 2025 08:03:49 -0700 Subject: [PATCH 05/12] tuning again! --- action.yml | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 3ad9bc9..a88402f 100644 --- a/action.yml +++ b/action.yml @@ -33,22 +33,58 @@ runs: fi echo "Running: $CMD" report=$($CMD) - echo "::set-output name=report::$report" + # + # Write the full Markdown report (including our HTML comment marker) to a file. + # We prepend "" so that downstream steps can find it. + # + REPORT_FILE="$GITHUB_WORKSPACE/vacuum-lint-report.md" + { + echo "" + echo + echo "$report" + } > "$REPORT_FILE" + + # Output the path so the workflow can locate it. + echo "::set-output name=report_path::vacuum-lint-report.md" env: DOCKER_BUILDKIT: 1 - - name: Create or update comment on PR - if: ${{ github.event_name == 'pull_request' }} +# - name: Create or update comment on PR +# if: ${{ github.event_name == 'pull_request' }} +# uses: peter-evans/create-or-update-comment@v4 +# with: +# token: ${{ inputs.github_token }} +# repository: ${{ github.repository }} +# issue-number: ${{ github.event.pull_request.number }} +# comment-id: ${{ steps.find-comment.outputs.comment-id }} +# body: | +# +# ${{ steps.lint-step.outputs.report }} +# edit-mode: replace + + + + + - name: Find existing vacuum-lint comment (if any) + id: find-comment + uses: peter-evans/find-comment@v3 + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: "" + + - name: Create or update vacuum-lint comment + if: always() uses: peter-evans/create-or-update-comment@v4 with: token: ${{ inputs.github_token }} repository: ${{ github.repository }} issue-number: ${{ github.event.pull_request.number }} comment-id: ${{ steps.find-comment.outputs.comment-id }} - body: | - - ${{ steps.lint-step.outputs.report }} + # Instead of passing 'body:', we give the path to our Markdown file: + body-path: ${{ steps.lint-step.outputs.report_path }} edit-mode: replace + From 0df5aeee5d79c977f6c4e164111dee4cb61d63d4 Mon Sep 17 00:00:00 2001 From: quobix Date: Fri, 6 Jun 2025 08:11:40 -0700 Subject: [PATCH 06/12] tuning --- action.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index a88402f..32f0535 100644 --- a/action.yml +++ b/action.yml @@ -13,9 +13,9 @@ inputs: description: "GitHub token (needs write permissions on PRs to post comments)" required: true -outputs: - report: - description: "Markdown‐formatted lint report from vacuum" +#outputs: +# report: +# description: "Markdown‐formatted lint report from vacuum" runs: using: "composite" @@ -46,6 +46,7 @@ runs: # Output the path so the workflow can locate it. echo "::set-output name=report_path::vacuum-lint-report.md" + echo "report generated" env: DOCKER_BUILDKIT: 1 From a6d6153aec6e18dc755021eae3b0bd547e0f1925 Mon Sep 17 00:00:00 2001 From: quobix Date: Fri, 6 Jun 2025 08:21:44 -0700 Subject: [PATCH 07/12] tuning --- action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 32f0535..8933770 100644 --- a/action.yml +++ b/action.yml @@ -45,8 +45,8 @@ runs: } > "$REPORT_FILE" # Output the path so the workflow can locate it. - echo "::set-output name=report_path::vacuum-lint-report.md" - echo "report generated" + echo "report_path=vacuum-lint-report.md" >> $GITHUB_OUTPUT + echo "report generated\n\n ${report}" env: DOCKER_BUILDKIT: 1 @@ -83,7 +83,7 @@ runs: issue-number: ${{ github.event.pull_request.number }} comment-id: ${{ steps.find-comment.outputs.comment-id }} # Instead of passing 'body:', we give the path to our Markdown file: - body-path: ${{ steps.lint-step.outputs.report_path }} + body-path: ${{ GITHUB_OUTPUT.report_path }} edit-mode: replace From 951bb72b8e03a3e1c2df6fb6089626b57bdda750 Mon Sep 17 00:00:00 2001 From: quobix Date: Fri, 6 Jun 2025 08:23:31 -0700 Subject: [PATCH 08/12] tuning --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 8933770..944f732 100644 --- a/action.yml +++ b/action.yml @@ -71,7 +71,7 @@ runs: uses: peter-evans/find-comment@v3 with: issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' + comment-author: 'pb33f-bot' body-includes: "" - name: Create or update vacuum-lint comment @@ -83,7 +83,7 @@ runs: issue-number: ${{ github.event.pull_request.number }} comment-id: ${{ steps.find-comment.outputs.comment-id }} # Instead of passing 'body:', we give the path to our Markdown file: - body-path: ${{ GITHUB_OUTPUT.report_path }} + body-path: ${{ steps.lint.outputs.report_path }} edit-mode: replace From 506ddd16eeec53ad85e1db136c0c7fea08c3aefd Mon Sep 17 00:00:00 2001 From: quobix Date: Fri, 6 Jun 2025 10:10:21 -0700 Subject: [PATCH 09/12] lets see if we can make this a bot! --- .github/workflows/test_vacuum.yaml | 5 ++--- action.yml | 30 +++++++++--------------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test_vacuum.yaml b/.github/workflows/test_vacuum.yaml index b657f2f..b749c10 100644 --- a/.github/workflows/test_vacuum.yaml +++ b/.github/workflows/test_vacuum.yaml @@ -1,5 +1,4 @@ -# .github/workflows/test_vacuum.yaml -name: "Lint OpenAPI Spec and Comment on PR" +name: "Lint OpenAPI specification using vacuum" on: push: @@ -21,7 +20,7 @@ jobs: - name: Check out repository uses: actions/checkout@v3 - - name: Run vacuum-lint composite action + - name: Run vacuum-lint uses: ./ with: openapi_path: "sample-specs/burgershop.yaml" diff --git a/action.yml b/action.yml index 944f732..33cf5c6 100644 --- a/action.yml +++ b/action.yml @@ -13,10 +13,6 @@ inputs: description: "GitHub token (needs write permissions on PRs to post comments)" required: true -#outputs: -# report: -# description: "Markdown‐formatted lint report from vacuum" - runs: using: "composite" steps: @@ -50,22 +46,6 @@ runs: env: DOCKER_BUILDKIT: 1 -# - name: Create or update comment on PR -# if: ${{ github.event_name == 'pull_request' }} -# uses: peter-evans/create-or-update-comment@v4 -# with: -# token: ${{ inputs.github_token }} -# repository: ${{ github.repository }} -# issue-number: ${{ github.event.pull_request.number }} -# comment-id: ${{ steps.find-comment.outputs.comment-id }} -# body: | -# -# ${{ steps.lint-step.outputs.report }} -# edit-mode: replace - - - - - name: Find existing vacuum-lint comment (if any) id: find-comment uses: peter-evans/find-comment@v3 @@ -74,6 +54,15 @@ runs: comment-author: 'pb33f-bot' body-includes: "" + + - name: Generate GitHub App token + id: generate-app-token + uses: crazy-max/ghaction-github-app-token@v1 + with: + app_id: ${{ secrets.GH_APP_ID }} + pem: ${{ secrets.GH_APP_PEM }} + repository: ${{ github.repository }} + - name: Create or update vacuum-lint comment if: always() uses: peter-evans/create-or-update-comment@v4 @@ -82,7 +71,6 @@ runs: repository: ${{ github.repository }} issue-number: ${{ github.event.pull_request.number }} comment-id: ${{ steps.find-comment.outputs.comment-id }} - # Instead of passing 'body:', we give the path to our Markdown file: body-path: ${{ steps.lint.outputs.report_path }} edit-mode: replace From 4440340174be103bc8f50a160645bbe4484ef0a3 Mon Sep 17 00:00:00 2001 From: quobix Date: Fri, 6 Jun 2025 12:31:07 -0500 Subject: [PATCH 10/12] this may be our limit. --- action.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/action.yml b/action.yml index 33cf5c6..284bb4c 100644 --- a/action.yml +++ b/action.yml @@ -55,14 +55,6 @@ runs: body-includes: "" - - name: Generate GitHub App token - id: generate-app-token - uses: crazy-max/ghaction-github-app-token@v1 - with: - app_id: ${{ secrets.GH_APP_ID }} - pem: ${{ secrets.GH_APP_PEM }} - repository: ${{ github.repository }} - - name: Create or update vacuum-lint comment if: always() uses: peter-evans/create-or-update-comment@v4 From ffdb7eaf764e913e9230afb986ef7666d705e537 Mon Sep 17 00:00:00 2001 From: quobix Date: Fri, 6 Jun 2025 12:32:48 -0500 Subject: [PATCH 11/12] more tuning --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 284bb4c..a478151 100644 --- a/action.yml +++ b/action.yml @@ -51,7 +51,7 @@ runs: uses: peter-evans/find-comment@v3 with: issue-number: ${{ github.event.pull_request.number }} - comment-author: 'pb33f-bot' + comment-author: 'github-actions[bot]' body-includes: "" From e324d80b2e7bd0b84243704b63e9592208ece9cc Mon Sep 17 00:00:00 2001 From: quobix Date: Fri, 6 Jun 2025 12:44:23 -0500 Subject: [PATCH 12/12] more tuning --- .github/workflows/test_vacuum.yaml | 2 +- README.md | 69 +++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_vacuum.yaml b/.github/workflows/test_vacuum.yaml index b749c10..94fd668 100644 --- a/.github/workflows/test_vacuum.yaml +++ b/.github/workflows/test_vacuum.yaml @@ -20,7 +20,7 @@ jobs: - name: Check out repository uses: actions/checkout@v3 - - name: Run vacuum-lint + - name: Run OpenAPI lint with vacuum uses: ./ with: openapi_path: "sample-specs/burgershop.yaml" diff --git a/README.md b/README.md index d06439f..e977e51 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,67 @@ -# vacuum-action -The official GitHub action for vacuum, OpenAPI linter +# Official vacuum OpenAPI linter GitHub Action + +Got an OpenAPI spec in your repository? Want to lint it with vacuum? This GitHub Action will do just that. + +- Super fast +- Super simple +- Super useful + +All you need to do is add the action to your repo via a workflow via `pb33f/vacuum-action@v1` + +There are currently two properties required. + +- `openapi_path` - The path to your OpenAPI spec file, relative to the root of your repository. +- `ruleset` - (optional) The path to a custom ruleset file, relative to the root of your repository. If not provided, the default ruleset will be used. + +```yaml +name: "Lint OpenAPI spec with Vacuum" + +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: read + pull-requests: write + +jobs: + vacuum-lint: + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Run OpenAPI linting with vacuum + id: lint-step + uses: pb33f/vacuum-action@v1 + with: + openapi_path: "path/to/your/openapi-spec.yaml" + # ruleset: "rules/custom-rules.yaml" << Uncomment to use a custom ruleset + + # The following steps will add the vacuum report as a comment on the pull request. + - name: Find existing vacuum report + id: find-comment + uses: peter-evans/find-comment@v3 + with: + issue-number: ${{ github.event.pull_request.number || github.event.number }} + comment-author: 'github-actions[bot]' + body-includes: '' + + - name: Create or update vacuum report + if: ${{ github.event_name == 'pull_request' }} + uses: peter-evans/create-or-update-comment@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + repository: ${{ github.repository }} + issue-number: ${{ github.event.pull_request.number }} + comment-id: ${{ steps.find-comment.outputs.comment-id }} + body-path: ${{ steps.lint-step.outputs.report_path }} + edit-mode: replace +``` + +To learn more about vacuum visit the [vacuum docs](https://quobix.com/vacuum/) \ No newline at end of file