diff --git a/README.md b/README.md index faecad7b707..b1f581b38bb 100644 --- a/README.md +++ b/README.md @@ -103,3 +103,20 @@ kubectl apply -f elastic-agent-${ELASTIC_AGENT_MODE}-kubernetes.yaml ``` kubectl -n kube-system get pods -l app=elastic-agent ``` + +## Updating dependencies/PRs +Even though we prefer `mage` to our automation, we still have some +rules implemented on our `Makefile` as well as CI will use the +`Makefile`. CI will run `make check-ci`, so make sure to run it +locally before submitting any PRs to have a quicker feedback instead +of waiting for a CI failure. + +### Generating the `NOTICE.txt` when updating/adding dependencies +To do so, just run `make notice`, this is also part of the `make +check-ci` and is the same check our CI will do. + +At some point we will migrate it to mage (see discussion on +https://github.com/elastic/elastic-agent/pull/1108 and on +https://github.com/elastic/elastic-agent/issues/1107). However until +we have the mage automation sorted out, it has been removed to avoid +confusion. diff --git a/magefile.go b/magefile.go index a215f1639d7..66b648ac1d8 100644 --- a/magefile.go +++ b/magefile.go @@ -10,14 +10,12 @@ package main import ( "context" "fmt" - "io" "os" "os/exec" "path/filepath" "runtime" "strconv" "strings" - "sync" "time" "github.com/hashicorp/go-multierror" @@ -92,48 +90,6 @@ type Demo mg.Namespace // Dev runs package and build for dev purposes. type Dev mg.Namespace -// Notice regenerates the NOTICE.txt file. -func Notice() error { - fmt.Println(">> Generating NOTICE") - fmt.Println(">> fmt - go mod tidy") - err := sh.RunV("go", "mod", "tidy", "-v") - if err != nil { - return errors.Wrap(err, "failed running go mod tidy, please fix the issues reported") - } - fmt.Println(">> fmt - go mod download") - err = sh.RunV("go", "mod", "download") - if err != nil { - return errors.Wrap(err, "failed running go mod download, please fix the issues reported") - } - fmt.Println(">> fmt - go list") - str, err := sh.Output("go", "list", "-m", "-json", "all") - if err != nil { - return errors.Wrap(err, "failed running go list, please fix the issues reported") - } - fmt.Println(">> fmt - go run") - cmd := exec.Command("go", "run", "go.elastic.co/go-licence-detector", "-includeIndirect", "-rules", "dev-tools/notice/rules.json", "-overrides", "dev-tools/notice/overrides.json", "-noticeTemplate", "dev-tools/notice/NOTICE.txt.tmpl", - "-noticeOut", "NOTICE.txt", "-depsOut", "\"\"") - stdin, err := cmd.StdinPipe() - if err != nil { - return errors.Wrap(err, "failed running go run, please fix the issues reported") - } - var wg sync.WaitGroup - wg.Add(1) - go func() { - defer stdin.Close() - defer wg.Done() - if _, err := io.WriteString(stdin, str); err != nil { - fmt.Println(err) - } - }() - wg.Wait() - _, err = cmd.CombinedOutput() - if err != nil { - return errors.Wrap(err, "failed combined output, please fix the issues reported") - } - return nil -} - func CheckNoChanges() error { fmt.Println(">> fmt - go run") err := sh.RunV("go", "mod", "tidy", "-v")