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

example: simplify major version updates #165

Merged
merged 1 commit into from
Jan 27, 2023

Conversation

AaronFriel
Copy link
Contributor

@AaronFriel AaronFriel commented Jan 27, 2023

This commit is an example of a change to be rolled out with ci-mgmt.

Providers are free to modify their major version without requiring many code changes beyond changing the code in ./provider:

  1. disabling examples tests (can be done with PR changing provider code)
  2. ci-mgmt change to bump the major version
  3. ci-mgmt PR against repo updating major version in CI files
  4. re-enabling examples

To accomplish this, files managed via ci-mgmt no longer require using the major version number of the provider in any scripts. This major version appears in:

  • Makefile: no longer required as go commands now use paths to build and modifying ldflags version argument
  • goreleaser: no longer required by modifying version ldflags argument
  • GitHub Actions: no longer required as an environment variable

A change to pulumi/pkg ProgramTest is needed to modify Dependencies to remove the need to disable and re-enable examples:

@github-actions
Copy link
Contributor

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

@AaronFriel AaronFriel force-pushed the friel/simpler-version-upgrades branch from ac2b17e to a48c149 Compare January 27, 2023 08:13
@github-actions
Copy link
Contributor

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

AaronFriel added a commit to pulumi/pulumi that referenced this pull request Jan 27, 2023
This change to ProgramTest allows Go module replacements to omit the major
version number, simplifying the process to release a provider with a new major
version.

When the major version is incremented in a PR, the examples fail to compile if
they reference the incorrect SDK version.

This enables the examples to be written to target a versionless `/sdk`, and have
a Dependencies line such as:

```go
	integration.ProgramTestOptions{
		Dependencies: []string{
			"github.com/pulumi/pulumi-keycloak/sdk=../sdk",
		},
	}
```

This versionless import mapping means that examples run regardless of the major
version of the provider, and updates to major versions in PRs will require only
one PR.

A provider PR proving out the implementation was created against this commit
here:
- pulumi/pulumi-keycloak#165
This commit is an example of a change to be rolled out with ci-mgmt.

Providers are free to modify their major version without requiring many code
changes beyond changing the code in `./provider`:

1. disabling examples tests (can be done with PR changing provider code)
2. ci-mgmt change to bump the major version
3. ci-mgmt PR against repo updating major version in CI files
4. re-enabling examples

To accomplish this, files managed via ci-mgmt no longer require using the major
version number of the provider in any scripts. This major version appears in:

* Makefile: no longer required as go commands now use paths to build and
  modifying ldflags version argument
* goreleaser: no longer required by modifying version ldflags argument
* GitHub Actions: no longer required as an environment variable

A change to pulumi/pkg ProgramTest is needed to modify `Dependencies` to remove
the need to disable and re-enable examples:
- pulumi/pulumi#12004
@AaronFriel AaronFriel force-pushed the friel/simpler-version-upgrades branch from a48c149 to f49e9cc Compare January 27, 2023 08:30
@github-actions
Copy link
Contributor

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

bors bot added a commit to pulumi/pulumi that referenced this pull request Jan 27, 2023
12004: feat: enable simpler Go programtest replacements r=AaronFriel a=AaronFriel

This change to ProgramTest allows Go module replacements to omit the major version number, simplifying the process to release a provider with a new major version.

When the major version is incremented in a PR, the examples fail to compile if they reference the incorrect SDK version.

This enables the examples to be written to target a versionless `/sdk`, and have a Dependencies line such as:

```go
	integration.ProgramTestOptions{
		Dependencies: []string{
			"github.com/pulumi/pulumi-keycloak/sdk=../sdk",
		},
	}
```

This versionless import mapping means that examples run regardless of the major version of the provider, and updates to major versions in PRs will require only one PR.

A provider PR proving out the implementation was created against this commit here:
- pulumi/pulumi-keycloak#165


Co-authored-by: Aaron Friel <[email protected]>
Copy link
Contributor

@guineveresaenger guineveresaenger left a comment

Choose a reason for hiding this comment

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

So basically, we would have a versionless version package? 😂

I love seeing this example, but have we tried this out somewhere?

@AaronFriel
Copy link
Contributor Author

@guineveresaenger this PR is the trial run: provider build, schema and SDK generation, examples are all green.

And to validate that the version is getting in there, tfgen panics if version.Version is the empty string, console output during make provider shows the correct version number.

Copy link
Member

@iwahbe iwahbe left a comment

Choose a reason for hiding this comment

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

This looks like a good prototype. I wasn't sure we could just remove the version prefixes where we describe the module, such as specifying linker flags. Given that tests go green, I'm comfortable merging.

I'll wait on master to go green before rolling out the change to other providers, since that invokes the goreleaser in it's publish step.

@iwahbe iwahbe merged commit 3aa45bb into master Jan 27, 2023
@iwahbe iwahbe deleted the friel/simpler-version-upgrades branch January 27, 2023 20:35
@AaronFriel
Copy link
Contributor Author

@iwahbe this commit introduces a go.mod file at provider/pkg/version, making it a separate module fixed at v0 enables the ldflags change.

iwahbe added a commit that referenced this pull request Mar 14, 2023
iwahbe added a commit that referenced this pull request Mar 14, 2023
* [internal] Update GitHub Actions workflow files

* Revert "example: simplify major version updates (#165)"

This reverts commit 3aa45bb.

* Remove VERSION_PREFIX

---------

Co-authored-by: Pulumi Bot <[email protected]>
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.

3 participants