Skip to content

Adds API spec coverage report. #28

Adds API spec coverage report.

Adds API spec coverage report. #28

Workflow file for this run

name: API Coverage
on: [push, pull_request]
env:
JAVA_VERSION: 11
OPENSEARCH_VERSION: 2.12.0
OPENSEARCH_INITIAL_ADMIN_PASSWORD: BobgG7YrtsdKf9M
jobs:
coverage:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Install API Plugin
run: |
wget https://github.com/dblock/opensearch-api/releases/download/v${{ env.OPENSEARCH_VERSION }}/opensearch-api-${{ env.OPENSEARCH_VERSION }}.0.zip
echo "FROM opensearchproject/opensearch:${{ env.OPENSEARCH_VERSION }}" >> Dockerfile
echo "ADD ./opensearch-api-${{ env.OPENSEARCH_VERSION }}.0.zip /tmp/" >> Dockerfile
echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/opensearch-api-${{ env.OPENSEARCH_VERSION }}.0.zip" >> Dockerfile
cat Dockerfile
- name: Build and Run Docker Container
run: |
docker build . --tag opensearch-with-api-plugin
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
sleep 30
- name: Display OpenSearch Info
run: |
curl -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} --insecure https://localhost:9200/ | jq
- name: Dump and Compare API
run: |
curl -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} --insecure https://localhost:9200/_plugins/api | jq > OpenSearch.auto.openapi.json
docker run --mount type=bind,source=.,target=/specs openapitools/openapi-diff:latest /specs/OpenSearch.openapi.json /specs/OpenSearch.auto.openapi.json --json /specs/diff.json
- name: Show Diff
run: |
echo "-------- Missing APIs"
cat diff.json | jq '.newEndpoints | group_by(.pathUrl)[] | .[0].pathUrl + ": " + (map(.method) | tostring)' --raw-output
echo "-------- Legacy APIs"
cat diff.json | jq '.missingEndpoints | group_by(.pathUrl)[] | .[0].pathUrl + ": " + (map(.method) | tostring)' --raw-output
- name: Gather Coverage
id: coverage
shell: bash
run: |
echo "current=`cat OpenSearch.openapi.json | jq '.paths | keys[]' | wc -l`" >> $GITHUB_OUTPUT
echo "total=`cat OpenSearch.auto.openapi.json | jq '.paths | keys[]' | wc -l`" >> $GITHUB_OUTPUT
- name: Report Coverage
shell: bash
run: |
echo API specs implemented for ${{ steps.coverage.outputs.current }}/${{ steps.coverage.outputs.total }} APIs.
- uses: mshick/add-pr-comment@v2
with:
message: |
API specs implemented for ${{ steps.coverage.outputs.current }}/${{ steps.coverage.outputs.total }} APIs.