|
| 1 | +name: API Coverage |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +# git clone [email protected]:dblock/OpenSearch.git |
| 6 | +# cd OpenSearch |
| 7 | +# git remote add upstream [email protected]:opensearch-project/OpenSearch.git |
| 8 | +# git fetch upstream --tags |
| 9 | +# git checkout 2.11.1 |
| 10 | +# git checkout -b 2.11.1-api-plugin |
| 11 | +# git cherry-pick ffa9ce9d41ac4d8a15b7041b4c8c60c4d3b1cffc |
| 12 | +# git push origin 2.11.1-api-plugin |
| 13 | + |
| 14 | +env: |
| 15 | + JAVA_VERSION: 11 |
| 16 | + OPENSEARCH_VERSION: 2.11.1 |
| 17 | + |
| 18 | +jobs: |
| 19 | + coverage: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout Repo |
| 23 | + uses: actions/checkout@v2 |
| 24 | + - name: Setup Java |
| 25 | + uses: actions/setup-java@v1 |
| 26 | + with: |
| 27 | + java-version: ${{ env.JAVA_VERSION }} |
| 28 | + - name: Checkout OpenSearch |
| 29 | + uses: actions/checkout@v2 |
| 30 | + with: |
| 31 | + repository: 'dblock/OpenSearch' |
| 32 | + path: OpenSearch |
| 33 | + ref: ${{ env.OPENSEARCH_VERSION }}-api-plugin |
| 34 | + - name: Build API Plugin |
| 35 | + working-directory: ./OpenSearch |
| 36 | + run: | |
| 37 | + ./gradlew :server:assemble -Dbuild.snapshot=false |
| 38 | + ./gradlew :libs:opensearch-core:assemble -Dbuild.snapshot=false |
| 39 | + ./gradlew :plugins:api:assemble -Dbuild.snapshot=false |
| 40 | + - name: Install API Plugin |
| 41 | + run: | |
| 42 | + echo "FROM opensearchproject/opensearch:${{ env.OPENSEARCH_VERSION }}" >> Dockerfile |
| 43 | + echo "ADD ./OpenSearch/plugins/api/build/distributions/api-${{ env.OPENSEARCH_VERSION }}.zip /tmp/" >> Dockerfile |
| 44 | + echo "COPY ./OpenSearch/server/build/distributions/opensearch-${{ env.OPENSEARCH_VERSION }}.jar /usr/share/opensearch/lib/" >> Dockerfile |
| 45 | + echo "COPY ./OpenSearch/libs/core/build/distributions/opensearch-core-${{ env.OPENSEARCH_VERSION }}.jar /usr/share/opensearch/lib/" >> Dockerfile |
| 46 | + echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/api-${{ env.OPENSEARCH_VERSION }}.zip" >> Dockerfile |
| 47 | + cat Dockerfile |
| 48 | + - name: Build and Run Docker Container |
| 49 | + run: | |
| 50 | + docker build . --tag opensearch-with-api-plugin |
| 51 | + docker run --detach -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" opensearch-with-api-plugin |
| 52 | + sleep 30 |
| 53 | + - name: Display OpenSearch Info |
| 54 | + run: | |
| 55 | + curl -u admin:admin --insecure https://localhost:9200/ | jq |
| 56 | + - name: Dump and Compare API |
| 57 | + run: | |
| 58 | + curl -u admin:admin --insecure https://localhost:9200/_plugins/api | jq > OpenSearch.auto.openapi.json |
| 59 | + 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 |
| 60 | + - name: Show Diff |
| 61 | + run: | |
| 62 | + echo "-------- Missing APIs" |
| 63 | + cat diff.json | jq '.newEndpoints | group_by(.pathUrl)[] | .[0].pathUrl + ": " + (map(.method) | tostring)' --raw-output |
| 64 | + echo "-------- Legacy APIs" |
| 65 | + cat diff.json | jq '.missingEndpoints | group_by(.pathUrl)[] | .[0].pathUrl + ": " + (map(.method) | tostring)' --raw-output |
| 66 | +
|
0 commit comments