Skip to content

Commit 79337c4

Browse files
Enable macOS unit tests for macOS 15 (#10234) (#10706)
(cherry picked from commit 9b2ad06) Co-authored-by: Olga Naydyonock <[email protected]>
1 parent e43a121 commit 79337c4

File tree

2 files changed

+55
-6
lines changed

2 files changed

+55
-6
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: macos-unit-tests
2+
3+
on:
4+
workflow_dispatch:
5+
# Temporary disabled for PRs
6+
# pull_request:
7+
push:
8+
branches:
9+
- main
10+
- '8.19'
11+
- 9.*
12+
13+
permissions:
14+
contents: read
15+
16+
## Concurrency only allowed in the main branch.
17+
## So old builds running for old commits within the same Pull Request are cancelled
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
21+
22+
jobs:
23+
unit-tests:
24+
runs-on: macos-15
25+
timeout-minutes: 60
26+
steps:
27+
- uses: actions/checkout@v5
28+
with:
29+
# pkg/testing/tools/git TestGetReleaseBranches test require full git history
30+
fetch-depth: 0
31+
32+
- uses: actions/setup-go@v6
33+
with:
34+
go-version-file: .go-version
35+
36+
- name: Install make
37+
run: |
38+
brew install make
39+
export PATH="/usr/local/opt/make/libexec/gnubin:$PATH"
40+
41+
- name: Install mage
42+
run: make mage
43+
44+
- name: mage unitTest
45+
run: RACE_DETECTOR=true TEST_COVERAGE=true mage unitTest

magefile.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,14 @@ import (
3434
"sync/atomic"
3535
"time"
3636

37-
"github.com/elastic/elastic-agent/dev-tools/mage/otel"
38-
3937
"github.com/jedib0t/go-pretty/v6/table"
40-
"github.com/otiai10/copy"
38+
filecopy "github.com/otiai10/copy"
4139

4240
"github.com/elastic/elastic-agent/dev-tools/mage"
4341
devtools "github.com/elastic/elastic-agent/dev-tools/mage"
4442
"github.com/elastic/elastic-agent/dev-tools/mage/downloads"
4543
"github.com/elastic/elastic-agent/dev-tools/mage/manifest"
44+
"github.com/elastic/elastic-agent/dev-tools/mage/otel"
4645
"github.com/elastic/elastic-agent/dev-tools/mage/pkgcommon"
4746
"github.com/elastic/elastic-agent/dev-tools/packaging"
4847
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact/download"
@@ -421,7 +420,12 @@ func (Build) TestBinaries() error {
421420
}
422421

423422
outputName := filepath.Join(pkg, binary)
424-
err := devtools.Run(nil, nil, os.Stderr, "go", pkg, "build", "-v", "-o", outputName, pkg)
423+
424+
finalArgs := make([]string, len(args))
425+
copy(finalArgs, args)
426+
finalArgs = append(finalArgs, "-o", outputName, filepath.Join(pkg))
427+
428+
err := RunGo(finalArgs...)
425429
if err != nil {
426430
return err
427431
}
@@ -1790,8 +1794,8 @@ func useDRAAgentBinaryForPackage(ctx context.Context, manifestURL string, versio
17901794

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

1793-
err = copy.Copy(srcBinaryPath, dstBinaryPath, copy.Options{
1794-
PermissionControl: copy.PerservePermission,
1797+
err = filecopy.Copy(srcBinaryPath, dstBinaryPath, filecopy.Options{
1798+
PermissionControl: filecopy.PerservePermission,
17951799
})
17961800
if err != nil {
17971801
return fmt.Errorf("copying %q to %q: %w", srcBinaryPath, dstBinaryPath, err)

0 commit comments

Comments
 (0)