Skip to content
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

CI: Auto generate the OpenAPI spec if Validate generated OpenAPI spec file check fails #2471

Merged
merged 34 commits into from
Oct 10, 2023
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ab0aff3
test auto generating OpenApi Spec
ShankarSinghC Oct 5, 2023
ed3386e
run it on create pull_request
ShankarSinghC Oct 5, 2023
3d7753e
remove AchTransfer to test
ShankarSinghC Oct 5, 2023
d20660c
Merge branch 'main' into auto-generate-openapi_spec
ShankarSinghC Oct 5, 2023
9db945f
docs(openapi): re-generate OpenAPI specification
github-actions[bot] Oct 5, 2023
d8695d7
test formatting
ShankarSinghC Oct 6, 2023
3efaaab
chore: run formatter
github-actions[bot] Oct 6, 2023
5fa351a
Merge branch 'main' of https://github.com/juspay/hyperswitch into aut…
ShankarSinghC Oct 6, 2023
572db94
Merge branch 'auto-generate-openapi_spec' of https://github.com/juspa…
ShankarSinghC Oct 6, 2023
003a2e5
use token for formatting
ShankarSinghC Oct 6, 2023
e6de124
chore: run formatter
github-actions[bot] Oct 6, 2023
d522bba
use token to test auto generate the openapi spec
ShankarSinghC Oct 6, 2023
93ac67e
docs(openapi): re-generate OpenAPI specification
github-actions[bot] Oct 6, 2023
cc6c31b
Merge branch 'main' of https://github.com/juspay/hyperswitch into aut…
ShankarSinghC Oct 6, 2023
80414ee
merge main
ShankarSinghC Oct 6, 2023
431a651
test commit
ShankarSinghC Oct 6, 2023
db2fc61
docs(openapi): re-generate OpenAPI specification
github-actions[bot] Oct 6, 2023
a06a7c7
test the repo name check
ShankarSinghC Oct 6, 2023
0c9fc60
test auto generating OpenApi Spec
ShankarSinghC Oct 6, 2023
716e7ed
have different checkout for prs from external contributers
ShankarSinghC Oct 9, 2023
4df33ef
Merge branch 'main' of https://github.com/juspay/hyperswitch into aut…
ShankarSinghC Oct 9, 2023
dfe169c
docs(openapi): re-generate OpenAPI specification
github-actions[bot] Oct 9, 2023
58b6c46
Merge branch 'auto-generate-openapi_spec' of https://github.com/juspa…
ShankarSinghC Oct 9, 2023
a5acbc5
have a check during checkout pr
ShankarSinghC Oct 9, 2023
d465672
docs(openapi): re-generate OpenAPI specification
github-actions[bot] Oct 9, 2023
8a8de41
having a check for checkout pr from fork
ShankarSinghC Oct 9, 2023
57aedd1
Merge branch 'auto-generate-openapi_spec' of https://github.com/juspa…
ShankarSinghC Oct 9, 2023
9013850
Fail the check only if it is forked pr
ShankarSinghC Oct 9, 2023
d800377
test
ShankarSinghC Oct 9, 2023
999bfc7
docs(openapi): re-generate OpenAPI specification
github-actions[bot] Oct 9, 2023
8cd37b9
Fail the check even in merge_group
ShankarSinghC Oct 9, 2023
94b5f2b
Merge branch 'main' of https://github.com/juspay/hyperswitch into aut…
ShankarSinghC Oct 9, 2023
54217d6
Merge branch 'main' of https://github.com/juspay/hyperswitch into aut…
ShankarSinghC Oct 10, 2023
13149b8
add merge group and pull_request check
ShankarSinghC Oct 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions .github/workflows/validate-openapi-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ jobs:
name: Validate generated OpenAPI spec file
runs-on: ubuntu-latest
steps:
- name: Checkout PR
if: ${{ github.event_name == 'pull_request' }}
- name: Checkout PR from fork
if: ${{ (github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) }}
uses: actions/checkout@v3
with:
# Checkout pull request branch instead of merge commit
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Checkout PR with token
if: ${{ (github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) }}
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
token: ${{ secrets.AUTO_FILE_UPDATE_PAT }}

- name: Checkout merge group HEAD commit
if: ${{ github.event_name == 'merge_group' }}
uses: actions/checkout@v3
Expand All @@ -47,7 +54,21 @@ jobs:
shell: bash
run: swagger-cli validate ./openapi/openapi_spec.json

- name: Commit the JSON file if it is not up-to-date
# PR originated from same repository
if: ${{ (github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) }}
shell: bash
run: |
if ! git diff --quiet --exit-code -- openapi/openapi_spec.json ; then
git config --local user.name 'github-actions[bot]'
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add openapi/openapi_spec.json
git commit --message 'docs(openapi): re-generate OpenAPI specification'
git push
fi

- name: Fail check if the JSON file is not up-to-date
ShankarSinghC marked this conversation as resolved.
Show resolved Hide resolved
if: ${{ (github.event_name == 'merge_group') || ((github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)) }}
shell: bash
run: |
if ! git diff --quiet --exit-code -- openapi/openapi_spec.json ; then
Expand Down
Loading