Skip to content

Commit

Permalink
Added API spec coverage.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <dblock@amazon.com>
  • Loading branch information
dblock committed Jan 11, 2024
1 parent c190acc commit d4263ac
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: API Coverage

on: [push, pull_request]

# git clone git@github.com:dblock/OpenSearch.git
# cd OpenSearch
# git remote add upstream git@github.com:opensearch-project/OpenSearch.git
# git fetch upstream --tags
# git checkout 2.11.1
# git checkout -b 2.11.1-api-plugin
# git cherry-pick ffa9ce9d41ac4d8a15b7041b4c8c60c4d3b1cffc
# git push origin 2.11.1-api-plugin

env:
JAVA_VERSION: 11
OPENSEARCH_VERSION: 2.11.1

jobs:
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}
- name: Checkout OpenSearch
uses: actions/checkout@v2
with:
repository: 'dblock/OpenSearch'
path: OpenSearch
ref: ${{ env.OPENSEARCH_VERSION }}-api-plugin
- name: Build API Plugin
working-directory: ./OpenSearch
run: |
./gradlew :server:assemble -Dbuild.snapshot=false
./gradlew :libs:opensearch-core:assemble -Dbuild.snapshot=false
./gradlew :plugins:api:assemble -Dbuild.snapshot=false
- name: Install API Plugin
run: |
echo "FROM opensearchproject/opensearch:${{ env.OPENSEARCH_VERSION }}" >> Dockerfile
echo "ADD ./OpenSearch/plugins/api/build/distributions/api-${{ env.OPENSEARCH_VERSION }}.zip /tmp/" >> Dockerfile
echo "COPY ./OpenSearch/server/build/distributions/opensearch-${{ env.OPENSEARCH_VERSION }}.jar /usr/share/opensearch/lib/" >> Dockerfile
echo "COPY ./OpenSearch/libs/core/build/distributions/opensearch-core-${{ env.OPENSEARCH_VERSION }}.jar /usr/share/opensearch/lib/" >> Dockerfile
echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/api-${{ env.OPENSEARCH_VERSION }}.zip" >> Dockerfile
cat Dockerfile
- name: Build and Run Docker Container
run: |
docker build . --tag opensearch-with-api-plugin
docker run --detach -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" opensearch-with-api-plugin
sleep 30
- name: Display OpenSearch Info
run: |
curl -u admin:admin --insecure https://localhost:9200/ | jq
- name: Dump and Compare API
run: |
curl -u admin:admin --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 --out /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

0 comments on commit d4263ac

Please sign in to comment.