Skip to content

Commit

Permalink
Download all coverage artifacts.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed May 10, 2024
1 parent 09e7078 commit 8d20830
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ 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" <<EOL
cat >>"coverage-api.json" <<EOL
{
"pull_request":${{ github.event.number }},
"current":$current,
Expand All @@ -56,5 +56,5 @@ jobs:
EOL
- uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage.json
name: coverage-api
path: coverage-api.json
15 changes: 8 additions & 7 deletions .github/workflows/coverage-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
name: coverage
pattern: coverage-*
merge-multiple: true
run-id: ${{ github.event.workflow_run.id }}

- name: 'Comment on PR'
Expand All @@ -26,13 +27,13 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const data = JSON.parse(fs.readFileSync('./coverage.json'));
console.log(data);
const test_data = JSON.parse(fs.readFileSync('./test-coverage.json'));
console.log(test_data);
const coverage_api = JSON.parse(fs.readFileSync('./coverage-api.json'));
console.log(coverage_api);
const coverage_tests = JSON.parse(fs.readFileSync('./coverage-tests.json'));
console.log(coverage_tests);
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, with ${test_data.current}/${test_data.total} (${test_data.percent}%) APIs tested.`
issue_number: coverage_api.pull_request,
body: `API specs implemented for ${coverage_api.current}/${coverage_api.total} (${coverage_api.percent}%) APIs, with ${coverage_tests.current}/${coverage_tests.total} (${coverage_tests.percent}%) APIs tested.`
});
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
total=`docker run --rm -i mikefarah/yq:latest -r '.paths | keys | length' < build/opensearch-openapi.yaml`
percent=$((current * 100 / total))
echo "$current/$total ($percent%) APIs tested."
cat >>"test-coverage.json" <<EOL
cat >>"coverage-tests.json" <<EOL
{
"pull_request":${{ github.event.number }},
"current":$current,
Expand All @@ -61,5 +61,5 @@ jobs:
EOL
- uses: actions/upload-artifact@v4
with:
name: test-coverage
path: test-coverage.json
name: coverage-tests
path: coverage-tests.json
2 changes: 1 addition & 1 deletion coverage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

0 comments on commit 8d20830

Please sign in to comment.