forked from opensearch-project/opensearch-api-specification
-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (62 loc) · 2.22 KB
/
coverage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Analyze Spec Coverage
on:
push:
paths:
- .github/workflows/coverage.yml
- package*.json
- spec/**
- tsconfig.json
pull_request:
paths:
- .github/workflows/coverage.yml
- package*.json
- spec/**
- tsconfig.json
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Dump OpenSearch Cluster's API
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 build/opensearch-cluster.yaml
docker stop opensearch
env:
OPENSEARCH_PASSWORD: BobgG7YrtsdKf9M
- name: Build Spec
shell: bash -eo pipefail {0}
run: |
npm ci
npm run merge -- --source ./spec --output build/opensearch-openapi.yaml
- name: Calculate Coverage
shell: bash -eo pipefail {0}
run: |
npm run coverage:spec -- \
--cluster build/opensearch-cluster.yaml \
--specification build/opensearch-openapi.yaml \
--output build/coverage.yaml
jq . build/coverage.yaml
- 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) |
.[]
' build/coverage.yaml | jq -r