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: generate openapi contract before asking for contract diff #21

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 22 additions & 2 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,33 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build docker image
uses: docker/build-push-action@v5
with:
context: ./api
target: php_dev
tags: local:latest
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
push: false
- name: Generate OpenAPI contract
uses: addnab/docker-run-action@v3
with:
image: local:latest
options: -v ${{github.workspace}}/api:/srv/app -v /srv/app/vendor
run: |
composer require symfony/runtime
php bin/console api:openapi:export > openapi.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to keep contract on same file docs/openapi.json ?

- name: Comment pull request with API diff
uses: bump-sh/github-action@v1
with:
doc: apiplatform-test-demo
token: ${{secrets.BUMP_TOKEN}}
file: docs/openapi.json
file: api/openapi.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to keep contract on same file docs/openapi.json ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or does it mean openapi contract is not persisted anymore (there is no file api/openapi.json with second commit)

command: diff
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
2 changes: 0 additions & 2 deletions api/src/Entity/Book.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Put;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use Doctrine\Common\Collections\ArrayCollection;
Expand All @@ -15,7 +14,6 @@
operations: [
new Get(),
new Put(),
new Delete(),
new GetCollection(),
new Post(),
]
Expand Down
2 changes: 2 additions & 0 deletions api/src/Entity/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Put;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Patch;
Expand All @@ -14,6 +15,7 @@
operations: [
new Get(),
new Put(),
new Delete(),
new GetCollection(),
new Post(),
new Patch(),
Expand Down