Skip to content

Commit

Permalink
Remove mage notice in favour of make notice (#1108)
Browse files Browse the repository at this point in the history
The current implementation of mage notice is not working because it
was never finalised, the fact that it and `make notice` exist only
generates confusion.

This commit removes the `mage notice` and documents that `make notice`
should be used instead for the time being.

In the long run we want to use the implementation on
`elastic-agent-libs`, however it is not working at the moment.

Closes #1107

Co-authored-by: Craig MacKenzie <[email protected]>
  • Loading branch information
belimawr and cmacknz authored Sep 13, 2022
1 parent 2730049 commit 9b17473
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 44 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
44 changes: 0 additions & 44 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 9b17473

Please sign in to comment.