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

Ko builder: Implement file watch dependencies #6617

Merged

Conversation

halvards
Copy link
Contributor

@halvards halvards commented Sep 17, 2021

Description
Add support for the dependencies section in the ko builder config.

Use **/*.go as the default file watch pattern, this prevents unintended image rebuilds based on changes to files in .git/, .idea/, and *.swap files and similar.

For this pattern to be effective, the changes in #6605 are required.

Tracking: #6041
Related: #6605

@halvards halvards requested a review from a team as a code owner September 17, 2021 05:00
@google-cla google-cla bot added the cla: yes label Sep 17, 2021
@codecov
Copy link

codecov bot commented Sep 17, 2021

Codecov Report

Merging #6617 (318f83e) into main (290280e) will decrease coverage by 0.45%.
The diff coverage is 53.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6617      +/-   ##
==========================================
- Coverage   70.48%   70.02%   -0.46%     
==========================================
  Files         515      523       +8     
  Lines       23150    23747     +597     
==========================================
+ Hits        16317    16629     +312     
- Misses       5776     6035     +259     
- Partials     1057     1083      +26     
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/flags.go 89.00% <0.00%> (-1.82%) ⬇️
cmd/skaffold/skaffold.go 0.00% <ø> (ø)
pkg/diag/recommender/container_errors.go 0.00% <0.00%> (ø)
pkg/diag/validator/pod.go 1.32% <0.00%> (ø)
pkg/skaffold/build/buildpacks/logger.go 0.00% <ø> (ø)
pkg/skaffold/build/cluster/logs.go 0.00% <ø> (-16.67%) ⬇️
cmd/skaffold/app/cmd/cmd.go 70.32% <66.66%> (-0.73%) ⬇️
pkg/diag/validator/resource.go 47.05% <66.66%> (ø)
pkg/skaffold/build/docker/docker.go 86.44% <66.66%> (-2.85%) ⬇️
pkg/skaffold/build/docker/errors.go 63.33% <80.00%> (-2.23%) ⬇️
... and 80 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 26dc1b8...318f83e. Read the comment docs.

@halvards halvards added the kokoro:force-run forces a kokoro re-run on a PR label Sep 17, 2021
@kokoro-team kokoro-team removed the kokoro:force-run forces a kokoro re-run on a PR label Sep 17, 2021
@halvards halvards force-pushed the ko-builder-dependencies branch 2 times, most recently from 60c7850 to f2e243f Compare September 21, 2021 23:25
@aaron-prindle aaron-prindle added the kokoro:force-run forces a kokoro re-run on a PR label Sep 23, 2021
@kokoro-team kokoro-team removed the kokoro:force-run forces a kokoro re-run on a PR label Sep 23, 2021
@halvards halvards force-pushed the ko-builder-dependencies branch from f2e243f to 99c06f6 Compare September 24, 2021 02:10
// defaultKoDependencies behavior is to watch all files in the context directory
func defaultKoDependencies() *latestV1.KoDependencies {
return &latestV1.KoDependencies{
Paths: []string{"."},
Copy link
Contributor

Choose a reason for hiding this comment

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

We shd stay away from having . as default dependency for following reasons

  1. A change in .git/*.lock file will trigger a dev loop
  2. A change in any hidden files (like .swap files or .ides) will trigger dev loop.

Can we instead add **/*.go as default?

Copy link
Contributor Author

@halvards halvards Oct 1, 2021

Choose a reason for hiding this comment

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

Thanks @tejal29, good point! I've pushed a new commit that uses **/*.go as the default. We'll need the globstar support in #6605 to make this pattern work well.

As a side note, the buildpacks and custom builders both use . as the default:


For those builders we can't really list patterns, since it could be any number of languages. Should we consider a list of default excludes for those builders?

Copy link
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

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

LGTM except default dependency

Add support for the `dependencies` section in the ko builder config.

Use `**/*.go` instead of `.` as the default file watch pattern for the
ko builder. As @tejal29
[points out](GoogleContainerTools#6617 (comment)),
this prevents unintended image rebuilds based on changes to files in
`.git/`, `.idea/`, and `*.swap` files and similar.

For this pattern to be effective, the changes in GoogleContainerTools#6605 are required.

**Tracking:** GoogleContainerTools#6041
**Related:** GoogleContainerTools#6605
@halvards halvards force-pushed the ko-builder-dependencies branch from 99c06f6 to 318f83e Compare October 1, 2021 00:06
@halvards halvards added the kokoro:force-run forces a kokoro re-run on a PR label Oct 1, 2021
@kokoro-team kokoro-team removed the kokoro:force-run forces a kokoro re-run on a PR label Oct 1, 2021
Copy link
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

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

Thanks!

@tejal29 tejal29 merged commit f481ea2 into GoogleContainerTools:main Oct 4, 2021
@halvards halvards deleted the ko-builder-dependencies branch October 6, 2021 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants