Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion PUKU_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.17.1
1.17.2
2 changes: 1 addition & 1 deletion e2e/harness/BUILD
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 14 additions & 0 deletions e2e/tests/stop/BUILD
Original file line number Diff line number Diff line change
@@ -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",
],
)
32 changes: 32 additions & 0 deletions e2e/tests/stop/stop_test.go
Original file line number Diff line number Diff line change
@@ -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")
}
9 changes: 9 additions & 0 deletions e2e/tests/stop/test_repo/.plzconfig
Original file line number Diff line number Diff line change
@@ -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

1 change: 1 addition & 0 deletions e2e/tests/stop/test_repo/other/other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package other
6 changes: 6 additions & 0 deletions e2e/tests/stop/test_repo/plugins/BUILD_FILE.plz
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
plugin_repo(
name = "go",
owner = "please-build",
plugin = "go-rules",
revision = "v1.7.0",
)
1 change: 1 addition & 0 deletions e2e/tests/stop/test_repo/stopped/puku.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"stop": true}
1 change: 1 addition & 0 deletions e2e/tests/stop/test_repo/stopped/stopped.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package stopped
1 change: 1 addition & 0 deletions e2e/tests/stop/test_repo/third_party/go/BUILD_FILE.plz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
subinclude("///go//build_defs:go")
2 changes: 1 addition & 1 deletion edit/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ go_library(
],
visibility = [
"//e2e/codegen:all",
"//e2e/tests/codegen:all",
"//e2e/tests/...",
"//eval:all",
"//generate:all",
"//generate/integration/syncmod:all",
Expand Down
4 changes: 3 additions & 1 deletion generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions licences/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ go_library(
"///third_party/go/github.com_please-build_buildtools//build",
"//edit",
"//graph",
"//logging",
"//proxy",
],
)
Expand Down
6 changes: 5 additions & 1 deletion licences/licences.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions logging/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ go_library(
"//cmd/puku:all",
"//generate:all",
"//graph:all",
"//licences:all",
"//sync:all",
"//watch:all",
],
Expand Down
2 changes: 2 additions & 0 deletions sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions watch/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading