-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds API spec coverage report. #179
Changes from 4 commits
b8e161b
de1fe44
e6a31b2
60f5d32
1bc3e98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
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 | ||
dblock marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sleep 15 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sleep feels prone to causing spurious errors, but probably good enough for now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you have a better way to wait for service I can change it. |
||
- name: Display OpenSearch Info | ||
run: | | ||
curl -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} --insecure https://localhost:9200/ | jq | ||
dblock marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- 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 | ||
dblock marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
dblock marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- 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 | ||
dblock marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- 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: Calculate Percent | ||
id: math | ||
shell: bash | ||
run: | | ||
echo "percent=$((${{ steps.coverage.outputs.current }}*100/${{ steps.coverage.outputs.total }}))" >> $GITHUB_OUTPUT | ||
- name: Report Coverage | ||
shell: bash | ||
run: | | ||
echo "API specs implemented for ${{ steps.coverage.outputs.current }}/${{ steps.coverage.outputs.total }} (${{ steps.math.outputs.percent }}%) APIs." | ||
dblock marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# - uses: mshick/add-pr-comment@v2 | ||
# with: | ||
# message: | | ||
# API specs implemented for ${{ steps.coverage.outputs.current }}/${{ steps.coverage.outputs.total }} (${{ steps.math.outputs.percent }}%) APIs. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be uncommented or removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The workflow needs permissions which are declared as part of this workflow for this to work. I'll delete it for now.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a particular reason to build up the Dockerfile in the workflow rather than committing it and using a build arg to pass in the opensearch version?
Also you could remove the wget and just have opensearch-plugin do the download: