Skip to content

Conversation

@blampe
Copy link
Contributor

@blampe blampe commented Oct 14, 2025

The cache key we use for examples is currently derived from a hash of the HCL and the target language. This causes us to incorrectly skip generating examples when the converter is upgraded, when the provider's version changes (#2323), or when the provider's flags are changed (pulumi/ci-mgmt#1025).

This changes updates our key to derive from a couple more inputs:

  • The version of Pulumi and the bridge we're linked against.
  • The provider's info, including language flags.

Fixes pulumi/ci-mgmt#1025.

@blampe blampe requested review from a team and t0yv0 October 14, 2025 21:46
@codecov
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

❌ Patch coverage is 0% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.93%. Comparing base (b672358) to head (6189e85).

Files with missing lines Patch % Lines
pkg/tfgen/examples_cache.go 0.00% 24 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (b672358) and HEAD (6189e85). Click for more details.

HEAD has 86 uploads less than BASE
Flag BASE (b672358) HEAD (6189e85)
108 22
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3214       +/-   ##
===========================================
- Coverage   68.73%   46.93%   -21.80%     
===========================================
  Files         337      316       -21     
  Lines       44184    42870     -1314     
===========================================
- Hits        30368    20120    -10248     
- Misses      12088    20910     +8822     
- Partials     1728     1840      +112     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

This looks so much more clean in addition to changing on more conditions.

Thank you!

Could we please change the variable names? I've based my suggestions on https://google.github.io/styleguide/go/decisions#variable-names, which I think is a pretty excellent read.
While that guide isn't canonical, it is what's linked from the much less getailed Go Style Wiki so I'd consider it a solid guideline.

"github.com/pulumi/pulumi-terraform-bridge/v3/pf",
v := map[string]string{}

bi, ok := debug.ReadBuildInfo()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bi, ok := debug.ReadBuildInfo()
buildInfo, ok := debug.ReadBuildInfo()

This is honestly more because "bi" reminds me of the prefix from "binary" and could just be a personal preference.

"github.com/pulumi/pulumi/pkg/v3",
"github.com/pulumi/pulumi-terraform-bridge/v3",
"github.com/pulumi/pulumi-terraform-bridge/v3/pf",
v := map[string]string{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Because we're using it across the entire method, can we give v a descriptive name?

Suggested change
v := map[string]string{}
versions := map[string]string{}

"github.com/pulumi/pulumi-terraform-bridge/v3":

v[mod.Path] = mod.Version
default:
Copy link
Contributor

Choose a reason for hiding this comment

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

should we return versions directly here?

PulumiVersion string `json:"pulumiVersion"`
SoftwareVersions map[string]string `json:"softwareVersions"`
BuildFileHashes map[string]string `json:"buildFileHashes"`
Plugins map[string]map[string]string `json:"plugins"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed that the way we calculate the plugins is via pulumi plugin ls which apparently does not take into account PATH manipulation.

The way we currently do it (using the .pulumi local folder) and the way we plan to do it (with mise) work by putting the plugins on the PATH. This might be something that we have to fix with pulumi plugin ls

Copy link
Member

@t0yv0 t0yv0 left a comment

Choose a reason for hiding this comment

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

Nice, thanks for improving this! The cache is gnarly but important for us. Somehow uncached AWS builds were still in the 30 min range for me last time I worked on this.

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.

Example cache not always invalidated correctly

4 participants