Skip to content

Modularize the OAS actions/workflows#22

Merged
stevenbal merged 10 commits intomainfrom
refactor/reusable-actions
May 19, 2025
Merged

Modularize the OAS actions/workflows#22
stevenbal merged 10 commits intomainfrom
refactor/reusable-actions

Conversation

@sergei-maertens
Copy link
Member

@sergei-maertens sergei-maertens commented May 7, 2025

So, reason for these changes is that we essentially have some interesting snippets that would benefit from being centralized, while still allowing flexibility. Personally, I want to stop maintaining repeated CI code in https://github.com/GPP-Woo/gpp-zoeken and https://github.com/GPP-Woo/gpp-publicatiebank, but also in https://github.com/open-formulieren/open-forms which also publishes its API checks and performs this kind of quality control on them.

I've tried to do this in a way that should not be too invasive and still offer great flexibility.

My design constraints I've taken into account are

  • a single place where the used tools are known/managed (with tools like spectral, drf-spectacular, openapi-generator...)
  • use the same pattern, but allow customizing details to fit the project that's using it
  • support split and monorepo's - if the backend lives in the backend directory, that should still work (currently untested)
  • make it easy to do the common stuff without having to worry about it, while providing escape hatches otherwise
  • have efficient CI pipelines and use of the runners

The approach I've taken for this is

  • what are now separate jobs in most of my projects and even separate workflows in team bron projects (the existing workflows in this repo) become composite actions
  • the OAS generation should only happen once and stored in an artifact that can be re-used
  • each action is documented and has its input parameters defined
  • there's a single workflow that uses these actions so you can easily run a battle-tested setup. if you want to tinker around with dependencies/order of operations, you can create your own workflow in your project based on the composite actions

Validation

I'm running these actions and/or workflows in several projects to verify that this setup works for (almost) everyone. Below the status of each project:

@sergei-maertens sergei-maertens force-pushed the refactor/reusable-actions branch 2 times, most recently from 439d231 to 8a355a3 Compare May 7, 2025 15:46
In attempt to unify the tooling that generates API schemas from code,
this is extracted into its own action for a more modular approach.
@sergei-maertens sergei-maertens force-pushed the refactor/reusable-actions branch 3 times, most recently from cf151f8 to 802c850 Compare May 7, 2025 16:06
@sergei-maertens sergei-maertens force-pushed the refactor/reusable-actions branch 4 times, most recently from 3efeaf4 to 20c7419 Compare May 9, 2025 16:52
@sergei-maertens sergei-maertens force-pushed the refactor/reusable-actions branch from 90c131e to fb8018a Compare May 9, 2025 18:25
This workflow is composed of the reusable actions and should over
sane defaults, while allowing usage in a matrix build strategy for
projects with multiple API specs.

The jobs are organized in such a way that early failures prevent
doing useless work - e.g. generating a postman collection or SDKs from
an API spec that is outdated has no purpose, as that has already been
done in previous commits/the default branch.
Copy link
Collaborator

@stevenbal stevenbal left a comment

Choose a reason for hiding this comment

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

@sergei-maertens the approach looks good to me, I think it's nice to have the workflow that combines them all 👍

@sergei-maertens sergei-maertens force-pushed the refactor/reusable-actions branch 5 times, most recently from 6ee4952 to ee08778 Compare May 14, 2025 17:30
This still uses the same underlying tool, but with some enhancements:

* the npm package is installed (and initialized) with a particular
  supported version range. Crucially, the package itself is picked up
  by the actions cache, so it shouldn't need downloading from maven
  every time, which frequently has outages
* the separate steps are now moved into a (default) configuration file
  for which languages/SDKs to generate
* you can provide your own config file in your project/repository to
  pin the generator version and decide which SDKs to generate
@sergei-maertens sergei-maertens force-pushed the refactor/reusable-actions branch from ee08778 to bed0b06 Compare May 14, 2025 17:34
@sergei-maertens sergei-maertens force-pushed the refactor/reusable-actions branch 3 times, most recently from 620671c to 2c8e07b Compare May 15, 2025 10:15
* Passed wrong param down to action from workflow
@sergei-maertens sergei-maertens force-pushed the refactor/reusable-actions branch from 2c8e07b to 93460c9 Compare May 15, 2025 10:15
@sergei-maertens sergei-maertens marked this pull request as ready for review May 16, 2025 10:08
@sergei-maertens sergei-maertens requested a review from stevenbal May 16, 2025 10:08
@stevenbal stevenbal self-requested a review May 19, 2025 10:39
Copy link
Collaborator

@stevenbal stevenbal left a comment

Choose a reason for hiding this comment

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

Thanks for this 🎉

@stevenbal stevenbal merged commit 6515bb3 into main May 19, 2025
@stevenbal stevenbal deleted the refactor/reusable-actions branch February 6, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants