Skip to content

Index Search Template API tests #191

Index Search Template API tests

Index Search Template API tests #191

Workflow file for this run

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