From 25bd55dbe9fe73478fe6cf837682b8d7bc342351 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Fri, 17 May 2024 00:09:48 +0200 Subject: [PATCH] Don't spam pull requests with coverage comments. (#296) * Renamed workflows for consitency. Signed-off-by: dblock * Only add a comment if coverage has changed. Signed-off-by: dblock * More renames for consistency. Signed-off-by: dblock --------- Signed-off-by: dblock --- .../workflows/{links.yml => check-links.yml} | 4 +- .../{coverage-gather.yml => coverage-api.yml} | 7 +-- .github/workflows/coverage-comment.yml | 52 ++++++++++++++++--- .github/workflows/deploy.yml | 4 +- .../workflows/{tools.yml => test-tools.yml} | 4 +- .../workflows/{lint.yml => validate-spec.yml} | 2 +- DEVELOPER_GUIDE.md | 2 + coverage/README.md | 2 +- 8 files changed, 59 insertions(+), 18 deletions(-) rename .github/workflows/{links.yml => check-links.yml} (93%) rename .github/workflows/{coverage-gather.yml => coverage-api.yml} (94%) rename .github/workflows/{tools.yml => test-tools.yml} (91%) rename .github/workflows/{lint.yml => validate-spec.yml} (97%) diff --git a/.github/workflows/links.yml b/.github/workflows/check-links.yml similarity index 93% rename from .github/workflows/links.yml rename to .github/workflows/check-links.yml index bfdd4df3d..d4b521959 100644 --- a/.github/workflows/links.yml +++ b/.github/workflows/check-links.yml @@ -1,11 +1,11 @@ -name: Links +name: Check Links on: push: pull_request: jobs: - linkChecker: + check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/coverage-gather.yml b/.github/workflows/coverage-api.yml similarity index 94% rename from .github/workflows/coverage-gather.yml rename to .github/workflows/coverage-api.yml index 887132ebd..482e242bc 100644 --- a/.github/workflows/coverage-gather.yml +++ b/.github/workflows/coverage-api.yml @@ -45,9 +45,10 @@ jobs: total=`jq -r '.paths | keys | length' build/local-openapi.json` percent=$((current * 100 / total)) echo "API specs implemented for $current/$total ($percent%) APIs." - cat >>"coverage.json" <>"coverage-api.json" < comment.body.startsWith("API specs implemented for ") + ); + + if (existing_comment && ! existing_comment.body.startsWith(body)) { + // change in coverage, delete existing comment + console.log(`Deleting ${existing_comment.url}.`); + await github.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: coverage_api.pull_request, + comment_id: existing_comment.id + }); + } + + if (existing_comment && existing_comment.body.startsWith(body)) { + // no change in coverage, update commit id + await github.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: coverage_api.pull_request, + comment_id: existing_comment.id, + body: body + "\n" + commit + }); + } else { + // create a new comment + await github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: coverage_api.pull_request, + body: body + "\n" + commit + }); + } \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c0ec9b73c..c180a53bd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,5 +1,5 @@ # deploys to https://opensearch-project.github.io/opensearch-api-specification/ -name: Deploy +name: Deploy to GitHub Pages on: push: @@ -14,7 +14,7 @@ permissions: contents: write jobs: - build: + deploy: runs-on: ubuntu-latest steps: - name: Checkout the repo diff --git a/.github/workflows/tools.yml b/.github/workflows/test-tools.yml similarity index 91% rename from .github/workflows/tools.yml rename to .github/workflows/test-tools.yml index 0cae7671e..81121b6bb 100644 --- a/.github/workflows/tools.yml +++ b/.github/workflows/test-tools.yml @@ -1,4 +1,4 @@ -name: Tools Testing +name: Test Tools on: push: @@ -11,7 +11,7 @@ on: - 'tools/**' jobs: - tools-tests: + test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/lint.yml b/.github/workflows/validate-spec.yml similarity index 97% rename from .github/workflows/lint.yml rename to .github/workflows/validate-spec.yml index 2d7bd2f26..5f26fec45 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/validate-spec.yml @@ -13,7 +13,7 @@ on: - 'tools/src/linter/**' jobs: - lint-spec: + validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index ca19a0bd3..497cc8c25 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -7,6 +7,8 @@ - [Global Parameters](#global-parameters) - [OpenAPI Extensions](#openapi-extensions) - [Tools](#tools) + - [Merger](#merger) + - [Linter](#linter) # Developer Guide diff --git a/coverage/README.md b/coverage/README.md index 89ae4e76b..3afdb91b0 100644 --- a/coverage/README.md +++ b/coverage/README.md @@ -2,4 +2,4 @@ Builds the OpenAPI spec, and uses the [opensearch-api plugin](https://github.com/dblock/opensearch-api) and [openapi-diff](https://github.com/OpenAPITools/openapi-diff) to show the differences. -API coverage is run on all pull requests via the [coverage workflow](../.github/workflows/coverage-gather.yml). +API coverage is run on all pull requests via the [coverage workflow](../.github/workflows/coverage-api.yml).