Skip to content

Commit

Permalink
Display coverage checklist usable on GitHub.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Nov 26, 2024
1 parent 3b6eb57 commit 101f6bb
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions .github/workflows/analyze-pr-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
BEFORE_COVERAGE=/tmp/coverage-api-${BEFORE_SHA}.json
AFTER_COVERAGE=/tmp/coverage-api-${AFTER_SHA}.json
COVERAGE_DIFF=/tmp/coverage-api-${BEFORE_SHA}-${AFTER_SHA}-DIFF.json
vars=(
BEFORE_SHA
AFTER_SHA
Expand All @@ -33,7 +33,7 @@ jobs:
AFTER_COVERAGE
COVERAGE_DIFF
)
{
for var in "${vars[@]}"
do
Expand All @@ -48,19 +48,19 @@ jobs:
shell: bash -eo pipefail {0}
run: |
docker build coverage --tag opensearch-with-api-plugin
docker run \
--name opensearch \
--rm -d \
-p 9200:9200 -p 9600:9600 \
-e "discovery.type=single-node" \
-e OPENSEARCH_INITIAL_ADMIN_PASSWORD="$OPENSEARCH_PASSWORD" \
opensearch-with-api-plugin
npm ci
npm run dump-cluster-spec -- --opensearch-insecure --output $CLUSTER_SPEC
docker stop opensearch
env:
OPENSEARCH_PASSWORD: BobgG7YrtsdKf9M
Expand Down Expand Up @@ -92,14 +92,14 @@ jobs:
--cluster $CLUSTER_SPEC \
--specification $BEFORE_SPEC \
--output $BEFORE_COVERAGE
npm run coverage:spec -- \
--cluster $CLUSTER_SPEC \
--specification $AFTER_SPEC \
--output $AFTER_COVERAGE
jq . $AFTER_COVERAGE
jq --slurp '
[ .[].counts ]
| {
Expand All @@ -116,6 +116,18 @@ jobs:
$AFTER_COVERAGE \
| tee $COVERAGE_DIFF
- name: Display Coverage Checklist
shell: bash -eo pipefail {0}
run: |
jq -sc '
(map(.endpoints .uncovered | to_entries | sort_by(.value) | map((.value[] | ascii_upcase) + " " + .key)) | .[] | to_entries | map({path: .value, covered: false})) as $uncovered |
(map(.endpoints .covered | to_entries | sort_by(.value) | map((.value[] | ascii_upcase) + " " + .key)) | .[] | to_entries | map({path: .value, covered: true})) as $covered |
$covered+$uncovered |
sort_by(.path) |
map(if .covered then "-[x] \(.path)" else "-[ ] \(.path)" end) |
.[]
' $AFTER_COVERAGE | jq -r
- name: Upload Coverage Data
id: upload-coverage
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -150,7 +162,7 @@ jobs:
exit 1
fi
fi
gawk '
BEGIN {
RS = "(\r|\n|\r\n)"
Expand All @@ -176,7 +188,7 @@ jobs:
HAD_CHANGES = 1
print
}
END {
if (!HAD_CHANGES) {
print "**NO CHANGES**\n"
Expand Down

0 comments on commit 101f6bb

Please sign in to comment.