Skip to content

Commit 4f27c67

Browse files
authored
Display coverage checklist usable on GitHub. (#697)
* Display coverage checklist usable on GitHub. Signed-off-by: dblock <[email protected]> * Display missing test paths in a GitHub compatible format. Signed-off-by: dblock <[email protected]> --------- Signed-off-by: dblock <[email protected]>
1 parent d7d6520 commit 4f27c67

File tree

4 files changed

+35
-21
lines changed

4 files changed

+35
-21
lines changed

.github/workflows/analyze-pr-changes.yml

+23-11
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
BEFORE_COVERAGE=/tmp/coverage-api-${BEFORE_SHA}.json
2323
AFTER_COVERAGE=/tmp/coverage-api-${AFTER_SHA}.json
2424
COVERAGE_DIFF=/tmp/coverage-api-${BEFORE_SHA}-${AFTER_SHA}-DIFF.json
25-
25+
2626
vars=(
2727
BEFORE_SHA
2828
AFTER_SHA
@@ -33,7 +33,7 @@ jobs:
3333
AFTER_COVERAGE
3434
COVERAGE_DIFF
3535
)
36-
36+
3737
{
3838
for var in "${vars[@]}"
3939
do
@@ -48,19 +48,19 @@ jobs:
4848
shell: bash -eo pipefail {0}
4949
run: |
5050
docker build coverage --tag opensearch-with-api-plugin
51-
51+
5252
docker run \
5353
--name opensearch \
5454
--rm -d \
5555
-p 9200:9200 -p 9600:9600 \
5656
-e "discovery.type=single-node" \
5757
-e OPENSEARCH_INITIAL_ADMIN_PASSWORD="$OPENSEARCH_PASSWORD" \
5858
opensearch-with-api-plugin
59-
59+
6060
npm ci
61-
61+
6262
npm run dump-cluster-spec -- --opensearch-insecure --output $CLUSTER_SPEC
63-
63+
6464
docker stop opensearch
6565
env:
6666
OPENSEARCH_PASSWORD: BobgG7YrtsdKf9M
@@ -92,14 +92,14 @@ jobs:
9292
--cluster $CLUSTER_SPEC \
9393
--specification $BEFORE_SPEC \
9494
--output $BEFORE_COVERAGE
95-
95+
9696
npm run coverage:spec -- \
9797
--cluster $CLUSTER_SPEC \
9898
--specification $AFTER_SPEC \
9999
--output $AFTER_COVERAGE
100-
100+
101101
jq . $AFTER_COVERAGE
102-
102+
103103
jq --slurp '
104104
[ .[].counts ]
105105
| {
@@ -116,6 +116,18 @@ jobs:
116116
$AFTER_COVERAGE \
117117
| tee $COVERAGE_DIFF
118118
119+
- name: Display Coverage Checklist
120+
shell: bash -eo pipefail {0}
121+
run: |
122+
jq -sc '
123+
(map(.endpoints .uncovered | to_entries | sort_by(.value) | map((.value[] | ascii_upcase) + " " + .key)) | .[] | to_entries | map({path: .value, covered: false})) as $uncovered |
124+
(map(.endpoints .covered | to_entries | sort_by(.value) | map((.value[] | ascii_upcase) + " " + .key)) | .[] | to_entries | map({path: .value, covered: true})) as $covered |
125+
$covered+$uncovered |
126+
sort_by(.path) |
127+
map(if .covered then "- [x] \(.path)" else "- [ ] \(.path)" end) |
128+
.[]
129+
' $AFTER_COVERAGE | jq -r
130+
119131
- name: Upload Coverage Data
120132
id: upload-coverage
121133
uses: actions/upload-artifact@v4
@@ -150,7 +162,7 @@ jobs:
150162
exit 1
151163
fi
152164
fi
153-
165+
154166
gawk '
155167
BEGIN {
156168
RS = "(\r|\n|\r\n)"
@@ -176,7 +188,7 @@ jobs:
176188
HAD_CHANGES = 1
177189
print
178190
}
179-
191+
180192
END {
181193
if (!HAD_CHANGES) {
182194
print "**NO CHANGES**\n"

.github/workflows/test-spec.yml

+10-8
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,16 @@ jobs:
126126

127127
- name: Display Missing Test Paths
128128
run: |
129-
jq -sc '
130-
(map(.operations) | add | unique) as $all |
131-
(map(.evaluated_operations) | add | unique) as $evaluated |
132-
$all-$evaluated |
133-
sort_by(.path) |
134-
.[] |
135-
"\(.method) \(.path)"
136-
' $(find ./ -name "test-spec-coverage-*.json")
129+
jq -r -sc '
130+
(map(.operations) | add | unique) as $all |
131+
(map(.evaluated_operations) | add | unique) as $evaluated |
132+
($all-$evaluated | map({path: .path, method: .method, evaluated: false})) as $unevaluated |
133+
($evaluated | map({path: .path, method: .method, evaluated: true})) as $evaluated |
134+
$evaluated+$unevaluated |
135+
sort_by(.path) |
136+
map(if .evaluated then "- [x] \(.method) \(.path)" else "- [ ] \(.method) \(.path)" end) |
137+
.[]
138+
' $(find ./ -name "test-spec-coverage-*.json")
137139
138140
- name: Combine Test Coverage Data
139141
shell: bash -eo pipefail {0}

DEVELOPER_GUIDE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ npm run lint--fix
355355

356356
### [Analyze PR Changes](.github/workflows/analyze-pr-changes.yml)
357357

358-
This workflow runs on all pull requests to analyze any potential changes to the specification. It uses the [coverage](#coverage) tool and [openapi-changes](https://pb33f.io/openapi-changes/) to calculate coverage metrics and provide a report on the changes when comparing with the commit at which the PR was branched off.
358+
This workflow runs on all pull requests to analyze any potential changes to the specification. It uses the [coverage](#coverage) tool and [openapi-changes](https://pb33f.io/openapi-changes/) to calculate coverage metrics and provide a report on the changes when comparing with the commit at which the PR was branched off. In addition, the "Display Coverage Checklist" step will output a list of OpenSearch APIs with a checkbox indicating whether the API exists in the spec that can be directly copy-pasted into the [Add Missing API Specs issue](https://github.com/opensearch-project/opensearch-api-specification/issues/168).
359359

360360
### [Build](.github/workflows/build.yml)
361361

TESTING_GUIDE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ entry:
422422
423423
Snapshot builds of OpenSearch are available on Docker Hub under [opensearchstaging/opensearch/tags](https://hub.docker.com/r/opensearchstaging/opensearch/tags).
424424
425-
The following example in the test matrix will use [a snapshot build of OpenSearch 2.18](https://hub.docker.com/layers/opensearchstaging/opensearch/2.18.0/images/sha256-504a9c42bc1b13cb47b39a29db8a9d300d01b8851fb95dbb9db6770f478e45b5?context=explore) to execute the default test suite in [tests/default](tests/default/).
425+
The following example in the test matrix will use [a snapshot build of OpenSearch 2.18](https://hub.docker.com/r/opensearchstaging/opensearch/tags?name=2.18) to execute the default test suite in [tests/default](tests/default/).
426426
427427
```yaml
428428
- version: 2.18.0

0 commit comments

Comments
 (0)