GoogleCloudPlatform / prometheus-engine

Google Cloud Managed Service for Prometheus libraries and manifests.
https://g.co/cloud/managedprometheus
Apache License 2.0
191 stars 89 forks source link

refactor(e2e): use consistent tag name when building images at the same time #852

Open TheSpiritXIII opened 7 months ago

TheSpiritXIII commented 7 months ago

tl;dr: this ensures that when you run make e2e, all Docker images are built with the same tag.

Another try for https://github.com/GoogleCloudPlatform/prometheus-engine/pull/845 (thanks @pintohutch)

How this works

  1. The problem is we call $(MAKE) which calls and forks make without carrying variables over. This is fixed by using export.
  2. The second problem is that make has rules for variable expansion. = and ?= are considered "recursively expansions" which you can think of as lazily evaluated. := is considered "simply expanded" and is evaluated at declaration time. This is what we want to ensure it's only evaluated once.
  3. Now that we export the value correctly to targets, we need to make sure we don't override it, so we add the conditional.
  4. We still use the latest tag for e2e tests because we need this for the e2e-only target which does not rebuild all images. This needs to be conditional so I'll fix this in a separate PR.
  5. I added nanoseconds to the tag which helps with testing but also better so we reduce the odds of mutating tags for older images.