diff --git a/ChangeLog b/ChangeLog index 1375d4d..1d9a272 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Version 1.17.2 +-------------- + * Don't stop processing the remaining paths when one of them has `stop` set + * Warn instead of silently doing nothing when there's no `Modfile` configured to sync against + * Warn, rather than abandoning the whole update, when a module's licence can't be downloaded + * Warn when `puku watch` is given nothing to watch + Version 1.17.1 -------------- * Correctly handle addition of an external test to a package that already contains an diff --git a/PUKU_VERSION b/PUKU_VERSION index 511a76e..06fb41b 100644 --- a/PUKU_VERSION +++ b/PUKU_VERSION @@ -1 +1 @@ -1.17.1 +1.17.2 diff --git a/e2e/harness/BUILD b/e2e/harness/BUILD index 0901d5e..b7cfaf2 100644 --- a/e2e/harness/BUILD +++ b/e2e/harness/BUILD @@ -1,7 +1,7 @@ go_library( name = "harness", srcs = ["harness.go"], - visibility = ["//e2e/tests/codegen:all"], + visibility = ["//e2e/tests/..."], deps = [ "///third_party/go/github.com_please-build_buildtools//build", "///third_party/go/golang.org_x_sys//execabs", diff --git a/e2e/tests/stop/BUILD b/e2e/tests/stop/BUILD new file mode 100644 index 0000000..3bb9b33 --- /dev/null +++ b/e2e/tests/stop/BUILD @@ -0,0 +1,14 @@ +subinclude("//e2e/build_defs") + +# Tests that a package with `stop` set doesn't prevent later paths being processed +puku_e2e_test( + name = "stop_test", + srcs = ["stop_test.go"], + repo = "test_repo", + deps = [ + "///third_party/go/github.com_stretchr_testify//assert", + "///third_party/go/github.com_stretchr_testify//require", + "//e2e/harness", + "//edit", + ], +) diff --git a/e2e/tests/stop/stop_test.go b/e2e/tests/stop/stop_test.go new file mode 100644 index 0000000..e845e0c --- /dev/null +++ b/e2e/tests/stop/stop_test.go @@ -0,0 +1,32 @@ +package stop + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/please-build/puku/e2e/harness" + "github.com/please-build/puku/edit" +) + +// A directory with stop set in its puku.json must not stop puku processing the paths that come +// after it on the command line. +func TestStopDoesntSkipLaterPaths(t *testing.T) { + h := harness.MustNew() + err := h.Format("stopped", "other") + require.NoError(t, err) + + file, err := h.ParseFile("other/BUILD_FILE.plz") + require.NoError(t, err) + + other := edit.FindTargetByName(file, "other") + require.NotNil(t, other, "puku didn't generate a target for other/, having been given stopped/ first") + assert.ElementsMatch(t, []string{"other.go"}, other.AttrStrings("srcs")) + + // The stopped package should still have been left alone. + _, err = os.Stat(filepath.Join(h.RepoRoot, "stopped", "BUILD_FILE.plz")) + assert.True(t, os.IsNotExist(err), "puku generated a build file in a package with stop set") +} diff --git a/e2e/tests/stop/test_repo/.plzconfig b/e2e/tests/stop/test_repo/.plzconfig new file mode 100644 index 0000000..e414150 --- /dev/null +++ b/e2e/tests/stop/test_repo/.plzconfig @@ -0,0 +1,9 @@ +[Parse] +buildfilename = BUILD_FILE.plz +buildfilename = BUILD +preloadsubincludes = ///go//build_defs:go + +[Plugin "go"] +Target = //plugins:go +ImportPath = github.com/example/repo + diff --git a/e2e/tests/stop/test_repo/other/other.go b/e2e/tests/stop/test_repo/other/other.go new file mode 100644 index 0000000..58a9531 --- /dev/null +++ b/e2e/tests/stop/test_repo/other/other.go @@ -0,0 +1 @@ +package other diff --git a/e2e/tests/stop/test_repo/plugins/BUILD_FILE.plz b/e2e/tests/stop/test_repo/plugins/BUILD_FILE.plz new file mode 100644 index 0000000..162e1d9 --- /dev/null +++ b/e2e/tests/stop/test_repo/plugins/BUILD_FILE.plz @@ -0,0 +1,6 @@ +plugin_repo( + name = "go", + owner = "please-build", + plugin = "go-rules", + revision = "v1.7.0", +) diff --git a/e2e/tests/stop/test_repo/stopped/puku.json b/e2e/tests/stop/test_repo/stopped/puku.json new file mode 100644 index 0000000..81be60c --- /dev/null +++ b/e2e/tests/stop/test_repo/stopped/puku.json @@ -0,0 +1 @@ +{"stop": true} diff --git a/e2e/tests/stop/test_repo/stopped/stopped.go b/e2e/tests/stop/test_repo/stopped/stopped.go new file mode 100644 index 0000000..601ef42 --- /dev/null +++ b/e2e/tests/stop/test_repo/stopped/stopped.go @@ -0,0 +1 @@ +package stopped diff --git a/e2e/tests/stop/test_repo/third_party/go/BUILD_FILE.plz b/e2e/tests/stop/test_repo/third_party/go/BUILD_FILE.plz new file mode 100644 index 0000000..0aebe46 --- /dev/null +++ b/e2e/tests/stop/test_repo/third_party/go/BUILD_FILE.plz @@ -0,0 +1 @@ +subinclude("///go//build_defs:go") diff --git a/edit/BUILD b/edit/BUILD index 408ebcc..dfeb347 100644 --- a/edit/BUILD +++ b/edit/BUILD @@ -7,7 +7,7 @@ go_library( ], visibility = [ "//e2e/codegen:all", - "//e2e/tests/codegen:all", + "//e2e/tests/...", "//eval:all", "//generate:all", "//generate/integration/syncmod:all", diff --git a/generate/generate.go b/generate/generate.go index 00edb79..dd4c597 100644 --- a/generate/generate.go +++ b/generate/generate.go @@ -161,9 +161,11 @@ func (u *updater) update(paths ...string) error { } if conf.GetStop() { - return nil + log.Warningf("not updating %v: stop is set in its puku.json", path) + continue } + log.Debugf("updating %v", path) if err := u.updateOne(conf, path); err != nil { return fmt.Errorf("failed to update %v: %v", path, err) } diff --git a/licences/BUILD b/licences/BUILD index 6ca9c7f..2600c4d 100644 --- a/licences/BUILD +++ b/licences/BUILD @@ -14,6 +14,7 @@ go_library( "///third_party/go/github.com_please-build_buildtools//build", "//edit", "//graph", + "//logging", "//proxy", ], ) diff --git a/licences/licences.go b/licences/licences.go index 04eb6a2..c7b23e4 100644 --- a/licences/licences.go +++ b/licences/licences.go @@ -9,9 +9,12 @@ import ( "github.com/please-build/puku/edit" "github.com/please-build/puku/graph" + "github.com/please-build/puku/logging" "github.com/please-build/puku/proxy" ) +var log = logging.GetLogger() + var modCacheDir = "plz-out/puku/modcache" type Licenses struct { @@ -112,7 +115,8 @@ func (l *Licenses) update(paths []string) error { return err } if downloadPath == "" { - return nil + log.Warningf("no download path for %v@%v; skipping its licence", mod, ver) + continue } rules[downloadPath] = r mods = append(mods, downloadPath) diff --git a/logging/BUILD b/logging/BUILD index e3f41e1..9e27568 100644 --- a/logging/BUILD +++ b/logging/BUILD @@ -6,6 +6,7 @@ go_library( "//cmd/puku:all", "//generate:all", "//graph:all", + "//licences:all", "//sync:all", "//watch:all", ], diff --git a/sync/sync.go b/sync/sync.go index ae5fe3e..bdeb943 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -59,6 +59,8 @@ func SyncToStdout(format string, plzConf *please.Config, g *graph.Graph) error { func (s *syncer) sync() error { if s.plzConf.ModFile() == "" { + log.Warningf("no go.mod target is configured, so there's nothing to sync against. Expose your go.mod " + + "as a build target, and set it as Modfile under [Plugin \"go\"] in your .plzconfig.") return nil } diff --git a/watch/watch.go b/watch/watch.go index 2119fd2..3fe0a3f 100644 --- a/watch/watch.go +++ b/watch/watch.go @@ -68,6 +68,7 @@ func (d *debouncer) wait() { func Watch(config *please.Config, opts options.Options, paths ...string) error { if len(paths) < 1 { + log.Warningf("no paths to watch") return nil } watcher, err := fsnotify.NewWatcher()