Skip to content

Commit 175817a

Browse files
committed
Report coverage percentage.
Signed-off-by: dblock <[email protected]>
1 parent e6a31b2 commit 175817a

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

.github/workflows/coverage.yml

+22-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ env:
1010
jobs:
1111
coverage:
1212
runs-on: ubuntu-latest
13+
permissions:
14+
pull-requests: write
1315
steps:
1416
- name: Checkout Repo
1517
uses: actions/checkout@v2
@@ -24,7 +26,7 @@ jobs:
2426
run: |
2527
docker build . --tag opensearch-with-api-plugin
2628
docker run -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -e OPENSEARCH_INITIAL_ADMIN_PASSWORD="${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }}" opensearch-with-api-plugin
27-
sleep 30
29+
sleep 15
2830
- name: Display OpenSearch Info
2931
run: |
3032
curl -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} --insecure https://localhost:9200/ | jq
@@ -38,4 +40,22 @@ jobs:
3840
cat diff.json | jq '.newEndpoints | group_by(.pathUrl)[] | .[0].pathUrl + ": " + (map(.method) | tostring)' --raw-output
3941
echo "-------- Legacy APIs"
4042
cat diff.json | jq '.missingEndpoints | group_by(.pathUrl)[] | .[0].pathUrl + ": " + (map(.method) | tostring)' --raw-output
41-
43+
- name: Gather Coverage
44+
id: coverage
45+
shell: bash
46+
run: |
47+
echo "current=`cat OpenSearch.openapi.json | jq '.paths | keys[]' | wc -l`" >> $GITHUB_OUTPUT
48+
echo "total=`cat OpenSearch.auto.openapi.json | jq '.paths | keys[]' | wc -l`" >> $GITHUB_OUTPUT
49+
- name: Calculate Percent
50+
id: math
51+
shell: bash
52+
run: |
53+
echo "percent=$((${{ steps.coverage.outputs.current }}*100/${{ steps.coverage.outputs.total }}))" >> $GITHUB_OUTPUT
54+
- name: Report Coverage
55+
shell: bash
56+
run: |
57+
echo API specs implemented for ${{ steps.coverage.outputs.current }}/${{ steps.coverage.outputs.total }} (${{ steps.math.outputs.percent }}%) APIs.
58+
- uses: mshick/add-pr-comment@v2
59+
with:
60+
message: |
61+
API specs implemented for ${{ steps.coverage.outputs.current }}/${{ steps.coverage.outputs.total }} (${{ steps.math.outputs.percent }}%) APIs.

0 commit comments

Comments
 (0)