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

all: faster builds by caching the build cache ⚡ #41033

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .buildkite/pull-requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"skip_target_branches": [ ],
"skip_ci_on_only_changed": [ ],
"always_require_ci_on_changed": [ ]
}
}
]
}
11 changes: 1 addition & 10 deletions .buildkite/x-pack/pipeline.xpack.agentbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ env:
ASDF_MAGE_VERSION: 1.15.0
GCP_HI_PERF_MACHINE_TYPE: "c2d-highcpu-16"
IMAGE_UBUNTU_X86_64: "family/platform-ingest-beats-ubuntu-2204"

IMAGE_BEATS_WITH_HOOKS_LATEST: "docker.elastic.co/ci-agent-images/platform-ingest/buildkite-agent-beats-ci-with-hooks:latest"

steps:
Expand Down Expand Up @@ -40,6 +39,7 @@ steps:
set -euo pipefail
cd x-pack/agentbeat
mage package

artifact_paths:
- x-pack/agentbeat/build/distributions/**/*
- "x-pack/agentbeat/build/*.xml"
Expand All @@ -60,26 +60,17 @@ steps:

- label: ":linux: Agentbeat/Integration tests Linux"
key: "agentbeat-it-linux"
depends_on:
- agentbeat-package-linux
env:
ASDF_NODEJS_VERSION: 18.17.1
PLATFORMS: "+all linux/amd64 linux/arm64 windows/amd64 darwin/amd64 darwin/arm64"
SNAPSHOT: true
command: |
set -euo pipefail
echo "~~~ Downloading artifacts"
buildkite-agent artifact download x-pack/agentbeat/build/distributions/** . --step 'agentbeat-package-linux'
ls -lah x-pack/agentbeat/build/distributions/
Comment on lines -71 to -73
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't why we were doing this. For the integration test, test binaries will be created which is already handled in mage goIntegTest.

echo "~~~ Installing @elastic/synthetics with npm"
npm install -g @elastic/synthetics
echo "~~~ Running tests"
cd x-pack/agentbeat
mage goIntegTest
artifact_paths:
- x-pack/agentbeat/build/distributions/**/*
- "x-pack/agentbeat/build/*.xml"
- "x-pack/agentbeat/build/*.json"
retry:
automatic:
- limit: 1
Expand Down
8 changes: 3 additions & 5 deletions dev-tools/mage/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"errors"
"fmt"
"go/build"
"log"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -124,8 +123,7 @@
// environment.
func GolangCrossBuild(params BuildArgs) error {
if os.Getenv("GOLANG_CROSSBUILD") != "1" {
return errors.New("Use the crossBuild target. golangCrossBuild can " +
"only be executed within the golang-crossbuild docker environment.")
return errors.New("use the crossBuild target. golangCrossBuild can only be executed within the golang-crossbuild docker environment")
}

defer DockerChown(filepath.Join(params.OutputDir, params.Name+binaryExtension(GOOS)))
Expand Down Expand Up @@ -206,15 +204,15 @@
}

if GOOS == "windows" && params.WinMetadata {
log.Println("Generating a .syso containing Windows file metadata.")
fmt.Println("Generating a .syso containing Windows file metadata.")
syso, err := MakeWindowsSysoFile()
if err != nil {
return fmt.Errorf("failed generating Windows .syso metadata file: %w", err)
}
defer os.Remove(syso)
}

log.Println("Adding build environment vars:", env)
fmt.Println("Adding build environment vars:", env)
return sh.RunWith(env, "go", args...)
}

Expand Down Expand Up @@ -248,7 +246,7 @@
},
StringFileInfo: goversioninfo.StringFileInfo{
CompanyName: BeatVendor,
ProductName: strings.Title(BeatName),

Check failure on line 249 in dev-tools/mage/build.go

View workflow job for this annotation

GitHub Actions / lint (linux)

SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. (staticcheck)
ProductVersion: version,
FileVersion: version,
FileDescription: BeatDescription,
Expand Down
11 changes: 5 additions & 6 deletions dev-tools/mage/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -59,7 +58,7 @@

if len(changes) > 0 {
if mg.Verbose() {
GitDiff()
_ = GitDiff()
}

return fmt.Errorf("some files are not up-to-date. "+
Expand Down Expand Up @@ -229,7 +228,7 @@

hasErrors := false
for _, file := range dashboardFiles {
d, err := ioutil.ReadFile(file)
d, err := os.ReadFile(file)
if err != nil {
return fmt.Errorf("failed to read dashboard file %s: %w", file, err)
}
Expand All @@ -253,7 +252,7 @@
var dashboard DashboardObject
err := json.Unmarshal(d, &dashboard)
if err != nil {
fmt.Println(fmt.Sprintf("failed to parse dashboard from %s: %s", file, err))
fmt.Printf("failed to parse dashboard from %s: %s\n", file, err)
return true
}

Expand Down Expand Up @@ -321,11 +320,11 @@
return fmt.Errorf("empty description on dashboard '%s'", d.Attributes.Title)
}
if err := checkTitle(dashboardTitleRegexp, d.Attributes.Title, module); err != nil {
return fmt.Errorf("expected title with format '[%s Module] Some title', found '%s': %w", strings.Title(BeatName), d.Attributes.Title, err)
return fmt.Errorf("expected title with format '[%s Module] Some title', found '%s': %w", strings.Title(BeatName), d.Attributes.Title, err) // nolint:staticcheck // strings.Title is deprecated but we need it.

Check failure on line 323 in dev-tools/mage/check.go

View workflow job for this annotation

GitHub Actions / lint (linux)

directive `// nolint:staticcheck // strings.Title is deprecated but we need it.` should be written without leading space as `//nolint:staticcheck // strings.Title is deprecated but we need it.` (nolintlint)
}
case "visualization":
if err := checkTitle(visualizationTitleRegexp, d.Attributes.Title, module); err != nil {
return fmt.Errorf("expected title with format 'Some title [%s Module]', found '%s': %w", strings.Title(BeatName), d.Attributes.Title, err)
return fmt.Errorf("expected title with format 'Some title [%s Module]', found '%s': %w", strings.Title(BeatName), d.Attributes.Title, err) // nolint:staticcheck // strings.Title is deprecated but we need it.

Check failure on line 327 in dev-tools/mage/check.go

View workflow job for this annotation

GitHub Actions / lint (linux)

directive `// nolint:staticcheck // strings.Title is deprecated but we need it.` should be written without leading space as `//nolint:staticcheck // strings.Title is deprecated but we need it.` (nolintlint)
}
}

Expand All @@ -341,7 +340,7 @@
if len(match) < 3 {
return errors.New("title doesn't match pattern")
}
beatTitle := strings.Title(BeatName)

Check failure on line 343 in dev-tools/mage/check.go

View workflow job for this annotation

GitHub Actions / lint (linux)

SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. (staticcheck)
if match[1] != beatTitle {
return fmt.Errorf("expected: '%s', found: '%s'", beatTitle, match[1])
}
Expand Down
3 changes: 1 addition & 2 deletions dev-tools/mage/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ func Clean(pathLists ...[]string) error {
if err := sh.Rm(f); err != nil {
if errors.Is(err, os.ErrPermission) ||
strings.Contains(err.Error(), "permission denied") {
fmt.Printf("warn: cannot delete %q: %v, proceeding anyway\n",
f, err)
fmt.Printf("warn: cannot delete %q: %v, proceeding anyway\n", f, err)
continue
}
return err
Expand Down
Loading
Loading