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

Remove mage notice in favour of make notice #1108

Merged
merged 7 commits into from
Sep 13, 2022
Merged
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
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