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

Generate types from the Github Actions JSON schema #43

Merged
merged 1 commit into from
Dec 2, 2022

Conversation

ringods
Copy link
Member

@ringods ringods commented Oct 20, 2022

Related: #40

About a month ago, I created a massive PR (#39) containing code to automate the creation of workflows for the different provider repositories. That PR was too big to review and it wasn't clear what it needed to solve. The need for this type of automation was then described in #40.

I will now chop up that work in a series of smaller PRs, of which this is a first one.

The setup added in the workflows folder is a regular NodeJS project (so no Pulumi code involved) which eventually will generate the required the needed workflows and utility files (.github/dependabot.yml, CODEOWNERS, ...) in a provider repository.

Before we land there, I want the ability to write Github Actions workflows in regular Typescript. This PR retrieves the JSON schema and creates a Typescript typings file from it.

More to come in a next PR.

Signed-off-by: Ringo De Smet ringo@de-smet.name

Signed-off-by: Ringo De Smet <ringo@de-smet.name>
@ringods ringods added the enhancement New feature or request label Oct 20, 2022
@ringods ringods self-assigned this Oct 20, 2022
@@ -0,0 +1,7 @@
import * as fs from "fs";
import zodToJsonSchema from "zod-to-json-schema";
import { Config } from "../src/config";
Copy link
Member

Choose a reason for hiding this comment

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

Would it be easy to add (a version of) this file to the PR? So we can see what sort of things would be written to the schema?

Copy link
Member Author

Choose a reason for hiding this comment

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

@tenwit I think I committed this file too early. It should have been part of the next PR, together with the schema config file you ask for, where I would go into reading a repository specific config file, with schema validation.

Copy link
Member

@simenandre simenandre left a comment

Choose a reason for hiding this comment

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

Since we haven't been able to find a time that fits yet for a talk, I might as well ask some questions here to try and clear things up.

I and many other developers, such as @jaxxstorm, have generated Github Actions workflows with Typescript. Is this supposed to be the same? In that case, can we please use jaxxstorm's package instead? Potentially add what we need to that package too?

I also feel there are reasons not to generate with Typescript anymore, especially after reusing workflows became a thing. In my experience, it lowered the amount of moving parts.

I might be totally off track here, in that case; sorry about that.

@ringods
Copy link
Member Author

ringods commented Oct 31, 2022

@cobraz you are not off-track and I'm all in for reuse. A pitty we couldn't find a moment to discuss in a call.

My main take for now is to stay close to what Pulumi has in the pulumi/ci-mgmt repo. The reason to stay close to what is in that repository is that we have the Pulumi team reworking their CI automation. Their intent is to have the build setup also consumable as a library in the coming months. I don't want to deviate too much with our setup so I can leverage any upstream change very easy.

The previous big PR (#39) was already mimicking the Pulumi ci-mgmt setup, but I replicated too much in a single PR. This PR is only one smaller part of it so you can review more easily, which was a remark in that previous big PR.

With our without using reusable workflows, release engineering best practices are to pin all the versions in use. So in case of workflow reuse, I will never point to "latest on main". One breaking change would possibly block everybody. Hence, I want PRs in all the repositories when I want to bump to a new tagged version of a workflow. Generating such update PRs in all the provider repos is also automated in pulumi/ci-mgmt.

I created a first tag to test reusable workflows:

https://github.com/pulumiverse/infra/tree/actions-workflows-v0.0.1

In case we don't invest in workflow reuse and would choose to generate complete workflows, I want to test the generation manually for a single provider, only later having automation to rollout such workflow changes to all repositories also via automated PRs.

I hope the strategy is transparent now, you approve and I can make more progress. 😉

@ringods
Copy link
Member Author

ringods commented Nov 25, 2022

@tenwit @cobraz @usrbinkat with all the feedback given, is it OK for one of you to approve so you allow me to make progress?

@ringods ringods merged commit 5793abf into main Dec 2, 2022
@ringods ringods deleted the feature/workflow-automation-part-1 branch December 2, 2022 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants