diff --git a/.github/workflows/coverage-comment.yml b/.github/workflows/coverage-comment.yml new file mode 100644 index 000000000..687c269a4 --- /dev/null +++ b/.github/workflows/coverage-comment.yml @@ -0,0 +1,36 @@ +name: Comment with API Coverage + +on: + workflow_run: + workflows: ["Gather API Coverage"] + types: + - completed + +jobs: + comment: + runs-on: ubuntu-latest + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' + steps: + - name: Download Coverage Report + uses: actions/download-artifact@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + name: coverage + run-id: ${{ github.event.workflow_run.id }} + + - name: 'Comment on PR' + uses: actions/github-script@v3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const fs = require('fs'); + var data = JSON.parse(fs.readFileSync('./coverage.json')); + console.log(data); + await github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: data.pull_request, + body: `API specs implemented for ${data.current}/${data.total} (${data.percent}%) APIs.` + }); \ No newline at end of file diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage-gather.yml similarity index 78% rename from .github/workflows/coverage.yml rename to .github/workflows/coverage-gather.yml index 4ad04baf0..703c0c6ab 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage-gather.yml @@ -1,6 +1,6 @@ -name: API Coverage +name: Gather API Coverage -on: [push, pull_request_target] +on: [push, pull_request] env: JAVA_VERSION: 11 @@ -14,8 +14,6 @@ jobs: steps: - name: Checkout Repo uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.sha }} - name: Build Spec working-directory: ./tools run: |- @@ -50,14 +48,15 @@ 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 >>"$GITHUB_OUTPUT" <>"coverage.json" <