Skip to content
Open
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
45 changes: 45 additions & 0 deletions .github/workflows/macos-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: macos-unit-tests

on:
workflow_dispatch:
# Temporary disabled for PRs
# pull_request:
push:
branches:
- main
- '8.19'
- 9.*

permissions:
contents: read

## Concurrency only allowed in the main branch.
## So old builds running for old commits within the same Pull Request are cancelled
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
unit-tests:
runs-on: macos-15
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
with:
# pkg/testing/tools/git TestGetReleaseBranches test require full git history
fetch-depth: 0

- uses: actions/setup-go@v6
with:
go-version-file: .go-version

- name: Install make
run: |
brew install make
export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"

- name: Install mage
run: make mage

- name: mage unitTest
run: RACE_DETECTOR=true TEST_COVERAGE=true mage unitTest
22 changes: 17 additions & 5 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ import (
"sync/atomic"
"time"

"github.com/elastic/elastic-agent/dev-tools/mage/otel"
filecopy "github.com/otiai10/copy"

"github.com/jedib0t/go-pretty/v6/table"
"github.com/otiai10/copy"

"github.com/elastic/elastic-agent/dev-tools/mage"
devtools "github.com/elastic/elastic-agent/dev-tools/mage"
"github.com/elastic/elastic-agent/dev-tools/mage/downloads"
"github.com/elastic/elastic-agent/dev-tools/mage/manifest"
"github.com/elastic/elastic-agent/dev-tools/mage/otel"
"github.com/elastic/elastic-agent/dev-tools/mage/pkgcommon"
"github.com/elastic/elastic-agent/dev-tools/packaging"
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact/download"
Expand Down Expand Up @@ -399,14 +399,26 @@ func (Build) TestBinaries() error {
fmt.Errorf("cannot build test binaries: %w", err)
}

args := []string{"build", "-v"}
if runtime.GOOS == "darwin" {
// Workaround for https://github.com/golang/go/issues/67854 until it
// is resolved.
args = append(args, "-ldflags", "-extldflags='-ld_classic'")
}

for _, pkg := range testBinaryPkgs {
binary := filepath.Base(pkg)
if runtime.GOOS == "windows" {
binary += ".exe"
}

outputName := filepath.Join(pkg, binary)
err := RunGo("build", "-v", "-o", outputName, filepath.Join(pkg))

finalArgs := make([]string, len(args))
copy(finalArgs, args)
finalArgs = append(finalArgs, "-o", outputName, filepath.Join(pkg))

err := RunGo(finalArgs...)
if err != nil {
return err
}
Expand Down Expand Up @@ -1775,8 +1787,8 @@ func useDRAAgentBinaryForPackage(ctx context.Context, manifestURL string, versio

log.Printf("copying %q to %q", srcBinaryPath, dstBinaryPath)

err = copy.Copy(srcBinaryPath, dstBinaryPath, copy.Options{
PermissionControl: copy.PerservePermission,
err = filecopy.Copy(srcBinaryPath, dstBinaryPath, filecopy.Options{
PermissionControl: filecopy.PerservePermission,
})
if err != nil {
return fmt.Errorf("copying %q to %q: %w", srcBinaryPath, dstBinaryPath, err)
Expand Down