Skip to content

Commit

Permalink
Merge pull request juju#16354 from hpidcock/enable-upgrade-action
Browse files Browse the repository at this point in the history
juju#16354

- Re-enabling the upgrade action for 3.2 to ensure upgrades work from 3.2/stable to current HEAD.
- Fix build-agent to find the juju go root via `go list -json`. This is required for running juju commands that take --build-agent in a subdirectory of the juju root (e.g. running shell tests in the tests directory.)

## QA steps

- Wait for upgrade actions to pass.
- Test using build agent with tests:
```sh
$ cd tests
$ BUILD_AGENT=true BOOTSTRAP_CLOUD=lxd BOOTSTRAP_PROVIDER=lxd ./main.sh -v -s '"test_metrics,test_mongo_memory_profile,test_query_tracing"' controller test_enable_ha
```

## Documentation changes

N/A

## Links

N/A
  • Loading branch information
jujubot authored Sep 29, 2023
2 parents 86e1d51 + ae2aeac commit 26ffaa6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
Upgrade:
name: Upgrade
runs-on: [self-hosted, linux, x64, aws, xlarge]
if: false && github.event.pull_request.draft == false
if: github.event.pull_request.draft == false
strategy:
fail-fast: false
matrix:
Expand Down
34 changes: 20 additions & 14 deletions environs/tools/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"bytes"
"compress/gzip"
"crypto/sha256"
"encoding/json"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -255,32 +256,37 @@ func buildJujus(dir string) error {
// Determine if we are in tree of juju and if to prefer
// vendor or readonly mod deps.
var lastErr error
var cmdDir string
for _, m := range []string{"-mod=vendor", "-mod=readonly"} {
cmd := exec.Command("go", "list", m, "github.com/juju/juju")
var stdout, stderr bytes.Buffer
cmd := exec.Command("go", "list", "-json", m, "github.com/juju/juju")
cmd.Env = append(os.Environ(), "GO111MODULE=on")
out, err := cmd.CombinedOutput()
cmd.Stderr = &stderr
cmd.Stdout = &stdout
err := cmd.Run()
if err != nil {
lastErr = fmt.Errorf(`cannot build juju agent outside of github.com/juju/juju tree
cd into the directory containing juju version=%s commit=%s: %w:
%s`, jujuversion.Current.String(), jujuversion.GitCommit, err, stderr.String())
continue
}
pkg := struct {
Root string `json:"Root"`
}{}
err = json.Unmarshal(stdout.Bytes(), &pkg)
if err != nil {
info := `cannot build juju agent outside of github.com/juju/juju tree
cd into the directory containing juju %s %s
%s`
lastErr = errors.Annotatef(err, info, jujuversion.Current.String(), jujuversion.GitCommit, out)
lastErr = fmt.Errorf("cannot parse go list output for github.com/juju/juju version=%s commit=%s: %w",
jujuversion.Current.String(), jujuversion.GitCommit, err)
continue
}
lastErr = nil
cmdDir = pkg.Root
break
}
if lastErr != nil {
return lastErr
}

// When using integration tests, you can't build jujud from outside of the
// root package. So if the GOPATH is set, we'll use that as the working
// directory to rebuild jujud.
var cmdDir string
if path, ok := os.LookupEnv("GOPATH"); ok && path != "" {
cmdDir = filepath.Join(path, "src", "github.com", "juju", "juju")
}

// Build binaries.
cmds := [][]string{
{"make", "jujud"},
Expand Down

0 comments on commit 26ffaa6

Please sign in to comment.