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

Add API documentation workflow #3281

Conversation

varshadr
Copy link
Contributor

@varshadr varshadr commented Nov 2, 2023

Fixes #3278

Technical details
This PR adds a new workflow to generate API documentation using Docker and Git Actions. The workflow is triggered on push event to the develop branch.
The workflow performs the following steps:

  1. Checks out the code from the branch that triggered the workflow.
  2. Copy the .env file
  3. Sets the Git identity to github-actions[bot]
  4. Starts the Docker Compose environment
  5. Generates the API documentation using the spectacular management command.
  6. Compares the schema.yml file to the previous version to see if it has changed.
  7.  If the schema file has changed, the workflow commits it to the repository with the message - Updated schema file.
  8. Finally, pushes the changes to the branch that triggered the workflow.

Why this approach?

  • It makes it easier for developers to review and test the API documentation before the pull request is merged.
  • It ensures that the API documentation is always up-to-date with the latest code changes.

Additional notes:

  • The workflow uses the mathesar_service_dev Docker container to generate the API documentation. This container contains the dependencies (drf-spectacular library) for generating the documentation.
  • The workflow uses the ./manage.py spectacular --color --file schema.yml command to generate the API documentation. This command generates a YAML file containing the OpenAPI schema for the API.
  • The workflow uses the git diff --quiet schema.yml command to check if the schema file has changed. This command returns a status code of 0 if the schema file has not changed, and a status code of 1 if the schema file has changed.
  • The workflow uses the git add schema.yml && git commit -m "Updated schema file" command to commit the changes to the schema file.
  • The workflow uses the git push origin ${{ github.head_ref }} command to push the changes to the remote branch.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@varshadr varshadr linked an issue Nov 2, 2023 that may be closed by this pull request
@seancolsen
Copy link
Contributor

@varshadr is this PR ready for review? I'm assuming so, since it's not a draft. As such, I'm assigning it to @mathemancer to review.

@seancolsen seancolsen added the pr-status: review A PR awaiting review label Nov 2, 2023
@varshadr varshadr marked this pull request as draft November 2, 2023 15:16
@varshadr
Copy link
Contributor Author

varshadr commented Nov 2, 2023

@varshadr is this PR ready for review? I'm assuming so, since it's not a draft. As such, I'm assigning it to @mathemancer to review.

Not just yet @seancolsen, I'll update it to a draft until then.

@varshadr varshadr added status: draft and removed pr-status: review A PR awaiting review labels Nov 2, 2023
@varshadr varshadr self-assigned this Nov 2, 2023
@varshadr varshadr added the type: enhancement New feature or request label Nov 2, 2023
@varshadr varshadr added pr-status: review A PR awaiting review and removed status: draft labels Nov 2, 2023
@varshadr varshadr assigned mathemancer and unassigned varshadr Nov 2, 2023
@varshadr varshadr added this to the GSoC 2023 milestone Nov 2, 2023
@varshadr
Copy link
Contributor Author

varshadr commented Nov 2, 2023

@varshadr is this PR ready for review? I'm assuming so, since it's not a draft. As such, I'm assigning it to @mathemancer to review.

Not just yet @seancolsen, I'll update it to a draft until then.

Done with it, assigned @mathemancer for review

@varshadr varshadr marked this pull request as ready for review November 5, 2023 13:55
@mathemancer
Copy link
Contributor

We're reprioritizing, and unfortunately we won't be continuing the documentation project.

@kgodey kgodey deleted the 3278-automate-api-documentation-generation-with-github-actions branch March 8, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: review A PR awaiting review type: enhancement New feature or request
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Automate API documentation generation with GitHub Actions
3 participants