⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@rophy
Copy link

@rophy rophy commented Dec 29, 2025

Fixes: #9506

Description

When no --build-artifacts flag is provided, skaffold verify now automatically builds the artifacts referenced in verify test cases. Only artifacts whose image names are used in verify containers are built.

Changes:

  • Modified doVerify() to call r.Build() when no pre-built artifacts are provided
  • Added targetArtifactsForVerify() to filter build artifacts to only those referenced in verify test cases
  • Added unit tests for getVerifyImgs() and targetArtifactsForVerify()

User facing changes

Before:

$ skaffold verify
Error: no tag provided for image [bootstrap]

Workaround required:

$ skaffold build -q --file-output=artifacts.json
$ skaffold verify --build-artifacts=artifacts.json

After:

$ skaffold verify

Automatically builds images referenced in verify test cases, then runs verification

Existing behavior preserved when --build-artifacts is provided:

$ skaffold verify --build-artifacts=artifacts.json

Uses pre-built images, no build phase

When no --build-artifacts flag is provided, skaffold verify now
automatically builds the artifacts referenced in verify test cases.
This improves UX by allowing `skaffold verify` to work out of the box
without requiring a separate build step.

Fixes GoogleContainerTools#9506
@rophy rophy requested a review from a team as a code owner December 29, 2025 16:26
@google-cla
Copy link

google-cla bot commented Dec 29, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @rophy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the skaffold verify command by integrating an automatic image building step. Previously, users had to manually build images before running verification if no pre-built artifacts were supplied, leading to a less intuitive experience. The change ensures that skaffold verify can now intelligently build only the necessary images required for its test cases, making the command more self-sufficient and user-friendly.

Highlights

  • Automatic Image Building for skaffold verify: The skaffold verify command now automatically builds images referenced in verify test cases if the --build-artifacts flag is not provided, streamlining the verification workflow.
  • Targeted Artifact Building: Only artifacts whose image names are explicitly used within the verify test cases will be built, avoiding unnecessary builds.
  • New Utility Function: A new function, targetArtifactsForVerify(), has been introduced to identify and filter the specific build artifacts required for verification.
  • Improved User Experience: Users no longer need to manually run skaffold build before skaffold verify when no pre-built artifacts are specified, simplifying the command usage.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a useful feature to automatically build artifacts for skaffold verify when they are not pre-built. The implementation looks good, with new logic in doVerify to handle the auto-build path and a new helper function targetArtifactsForVerify to select the correct artifacts. The addition of unit tests for the new logic is also great. I have one suggestion to improve the robustness and efficiency of the new targetArtifactsForVerify function.

Comment on lines 101 to 114
func targetArtifactsForVerify(configs []util.VersionedConfig) []*latest.Artifact {
verifyImgs := getVerifyImgs(configs)

var artifacts []*latest.Artifact
for _, cfg := range configs {
for _, artifact := range cfg.(*latest.SkaffoldConfig).Build.Artifacts {
// Only include artifacts that are referenced in verify test cases
if verifyImgs[artifact.ImageName] {
artifacts = append(artifacts, artifact)
}
}
}
return artifacts
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This function can be made more robust and slightly more efficient with a couple of changes:

  1. Early exit: If getVerifyImgs returns no images, we can exit early instead of iterating through all artifacts.
  2. Safe type assertion: The type assertion cfg.(*latest.SkaffoldConfig) will panic if cfg is not of the expected type. Using the _, ok form is safer.
  3. Pre-allocation: We can pre-allocate the artifacts slice with a capacity based on the number of verify images to avoid potential reallocations.
func targetArtifactsForVerify(configs []util.VersionedConfig) []*latest.Artifact {
	verifyImgs := getVerifyImgs(configs)
	if len(verifyImgs) == 0 {
		return nil
	}

	artifacts := make([]*latest.Artifact, 0, len(verifyImgs))
	for _, cfg := range configs {
		skaffoldConfig, ok := cfg.(*latest.SkaffoldConfig)
		if !ok {
			continue
		}
		for _, artifact := range skaffoldConfig.Build.Artifacts {
			// Only include artifacts that are referenced in verify test cases
			if verifyImgs[artifact.ImageName] {
				artifacts = append(artifacts, artifact)
			}
		}
	}
	return artifacts
}

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the review! I addressed 2 of the 3 suggestions:

Early exit - Applied

Pre-allocation - Applied

Safe type assertion - Not applied. The existing code in cmd/skaffold/app/cmd/ consistently uses direct type assertions (cfg.(*latest.SkaffoldConfig)) without the safe form - see dev.go:69, exec.go:99, build.go:101, filter.go:159,163,180, deploy.go:48. The safe form is only used in pkg/skaffold/. To maintain consistency within this package, I kept the direct assertion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

skaffold verify should be able to build images

1 participant