-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Theo Truong <[email protected]>
- Loading branch information
Showing
1 changed file
with
56 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
# TODO: Enable this workflow when the API coverage tool is ready to handle yaml files | ||
#name: API Coverage | ||
# | ||
#on: [push, pull_request_target] | ||
# | ||
#env: | ||
# JAVA_VERSION: 11 | ||
# OPENSEARCH_INITIAL_ADMIN_PASSWORD: BobgG7YrtsdKf9M | ||
# | ||
#jobs: | ||
# coverage: | ||
# permissions: | ||
# pull-requests: write | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Checkout Repo | ||
# uses: actions/checkout@v4 | ||
# with: | ||
# ref: ${{ github.event.pull_request.head.sha }} | ||
# - name: Build and Run Docker Container | ||
# run: | | ||
# docker build coverage --tag opensearch-with-api-plugin | ||
# docker run -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -e OPENSEARCH_INITIAL_ADMIN_PASSWORD="$OPENSEARCH_INITIAL_ADMIN_PASSWORD" opensearch-with-api-plugin | ||
# sleep 15 | ||
# - name: Display OpenSearch Info | ||
# run: | | ||
# curl -ks -u "admin:$OPENSEARCH_INITIAL_ADMIN_PASSWORD" https://localhost:9200/ | jq | ||
# - name: Dump and Compare API | ||
# run: | | ||
# curl -ks -u "admin:$OPENSEARCH_INITIAL_ADMIN_PASSWORD" https://localhost:9200/_plugins/api | jq > OpenSearch.auto.openapi.json | ||
# docker run --rm --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" | ||
# jq -r '.newEndpoints | group_by(.pathUrl)[] | "\(.[0].pathUrl): \([.[].method])"' diff.json | ||
# echo "-------- Legacy APIs" | ||
# jq -r '.missingEndpoints | group_by(.pathUrl)[] | "\(.[0].pathUrl): \([.[].method])"' diff.json | ||
# - name: Gather Coverage | ||
# id: coverage | ||
# shell: bash | ||
# run: | | ||
# current=`jq -r '.paths | keys | length' OpenSearch.openapi.json` | ||
# total=`jq -r '.paths | keys | length' OpenSearch.auto.openapi.json` | ||
# percent=$((current * 100 / total)) | ||
# echo "API specs implemented for $current/$total ($percent%) APIs." | ||
# cat >>"$GITHUB_OUTPUT" <<EOL | ||
# current=$current | ||
# total=$total | ||
# percent=$percent | ||
# EOL | ||
# - uses: peter-evans/create-or-update-comment@v4 | ||
# if: github.event_name == 'pull_request_target' | ||
# with: | ||
# issue-number: ${{ github.event.number }} | ||
# body: | | ||
# API specs implemented for ${{ steps.coverage.outputs.current }}/${{ steps.coverage.outputs.total }} (${{ steps.coverage.outputs.percent }}%) APIs. | ||
# TODO: Update this workflow API coverage tool is ready to handle yaml files | ||
name: API Coverage | ||
|
||
on: [push, pull_request_target] | ||
|
||
env: | ||
JAVA_VERSION: 11 | ||
OPENSEARCH_INITIAL_ADMIN_PASSWORD: BobgG7YrtsdKf9M | ||
|
||
jobs: | ||
coverage: | ||
permissions: | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Build and Run Docker Container | ||
run: | | ||
docker build coverage --tag opensearch-with-api-plugin | ||
docker run -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -e OPENSEARCH_INITIAL_ADMIN_PASSWORD="$OPENSEARCH_INITIAL_ADMIN_PASSWORD" opensearch-with-api-plugin | ||
sleep 15 | ||
- name: Display OpenSearch Info | ||
run: | | ||
curl -ks -u "admin:$OPENSEARCH_INITIAL_ADMIN_PASSWORD" https://localhost:9200/ | jq | ||
- name: Dump and Compare API | ||
run: | | ||
curl -ks -u "admin:$OPENSEARCH_INITIAL_ADMIN_PASSWORD" https://localhost:9200/_plugins/api | jq > OpenSearch.auto.openapi.json | ||
docker run --rm --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" | ||
jq -r '.newEndpoints | group_by(.pathUrl)[] | "\(.[0].pathUrl): \([.[].method])"' diff.json | ||
echo "-------- Legacy APIs" | ||
jq -r '.missingEndpoints | group_by(.pathUrl)[] | "\(.[0].pathUrl): \([.[].method])"' diff.json | ||
- name: Gather Coverage | ||
id: coverage | ||
shell: bash | ||
run: | | ||
current=`jq -r '.paths | keys | length' OpenSearch.openapi.json` | ||
total=`jq -r '.paths | keys | length' OpenSearch.auto.openapi.json` | ||
percent=$((current * 100 / total)) | ||
echo "API specs implemented for $current/$total ($percent%) APIs." | ||
cat >>"$GITHUB_OUTPUT" <<EOL | ||
current=$current | ||
total=$total | ||
percent=$percent | ||
EOL | ||
- uses: peter-evans/create-or-update-comment@v4 | ||
if: github.event_name == 'pull_request_target' | ||
with: | ||
issue-number: ${{ github.event.number }} | ||
body: | | ||
API specs implemented for ${{ steps.coverage.outputs.current }}/${{ steps.coverage.outputs.total }} (${{ steps.coverage.outputs.percent }}%) APIs. |