Skip to content

Commit 64854c0

Browse files
authored
[chore][CICD] Move cross-compile and setup-environment into reusable workflows (#6306)
* [chore][CICD] Move cross-compile into reusable workflow * use reusable cross compile workflow * add reusable workflows * add go version env * name new workflows * Use one job for setup-environment, remaining just need that job * rename workflow file, don't call setup env in reusable workflow * pass in compile targets * rename cross-compile to compile * move remaining workflows to reusable compile and setup-environment * re-add setup-env requirement, formatting
1 parent aa96dc1 commit 64854c0

File tree

7 files changed

+79
-142
lines changed

7 files changed

+79
-142
lines changed

.github/workflows/auto-instrumentation.yml

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,12 @@ env:
2727

2828
jobs:
2929
cross-compile:
30-
runs-on: ubuntu-24.04
3130
strategy:
3231
matrix:
3332
SYS_BINARIES: [ "binaries-linux_amd64", "binaries-linux_arm64" ]
34-
steps:
35-
- name: Check out the codebase.
36-
uses: actions/checkout@v4
37-
38-
- name: Set up Go
39-
uses: actions/setup-go@v5
40-
with:
41-
go-version: ${{ env.GO_VERSION }}
42-
cache-dependency-path: '**/go.sum'
43-
44-
- name: Build Collector
45-
run: |
46-
make ${{ matrix.SYS_BINARIES }}
47-
48-
- name: Upload artifact
49-
uses: actions/upload-artifact@v4
50-
with:
51-
name: ${{ matrix.SYS_BINARIES }}
52-
path: |
53-
./bin/*
33+
uses: ./.github/workflows/compile.yml
34+
with:
35+
sys_binary: ${{ matrix.SYS_BINARIES }}
5436

5537
build-package:
5638
runs-on: ${{ matrix.ARCH == 'amd64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}

.github/workflows/build-and-test.yml

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,7 @@ env:
1717
jobs:
1818
setup-environment:
1919
name: setup-environment
20-
runs-on: ubuntu-24.04
21-
steps:
22-
- name: Check out the codebase.
23-
uses: actions/checkout@v4
24-
25-
- name: Set up Go
26-
uses: actions/setup-go@v5
27-
with:
28-
go-version: ${{ env.GO_VERSION }}
29-
cache-dependency-path: '**/go.sum'
30-
31-
- name: Installing dependency
32-
run: |
33-
make install-tools
20+
uses: ./.github/workflows/setup-environment.yml
3421

3522
tidy:
3623
name: tidy
@@ -194,29 +181,10 @@ jobs:
194181
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
195182

196183
cross-compile:
197-
name: cross-compile
198-
runs-on: ubuntu-24.04
199184
needs: [setup-environment]
200185
strategy:
201186
matrix:
202187
SYS_BINARIES: [ "binaries-darwin_amd64", "binaries-darwin_arm64", "binaries-linux_amd64", "binaries-linux_arm64", "binaries-windows_amd64", "binaries-linux_ppc64le" ]
203-
steps:
204-
- name: Check out the codebase.
205-
uses: actions/checkout@v4
206-
207-
- name: Set up Go
208-
uses: actions/setup-go@v5
209-
with:
210-
go-version: ${{ env.GO_VERSION }}
211-
cache-dependency-path: '**/go.sum'
212-
213-
- name: Build Collector
214-
run: |
215-
make ${{ matrix.SYS_BINARIES }}
216-
217-
- name: Uploading binaries
218-
uses: actions/upload-artifact@v4
219-
with:
220-
name: ${{ matrix.SYS_BINARIES }}
221-
path: |
222-
./bin/*
188+
uses: ./.github/workflows/compile.yml
189+
with:
190+
sys_binary: ${{ matrix.SYS_BINARIES }}

.github/workflows/compile.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: compile
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
sys_binary:
7+
required: true
8+
type: string
9+
10+
env:
11+
GO_VERSION: 1.23.8
12+
13+
jobs:
14+
compile:
15+
name: compile
16+
runs-on: ubuntu-24.04
17+
steps:
18+
- name: Check out the codebase.
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: ${{ env.GO_VERSION }}
25+
cache-dependency-path: '**/go.sum'
26+
27+
- name: Build Collector
28+
run: |
29+
make ${{ inputs.sys_binary }}
30+
31+
- name: Uploading binaries
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: ${{ inputs.sys_binary }}
35+
path: |
36+
./bin/*

.github/workflows/linux-package-test.yml

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,47 +26,17 @@ env:
2626

2727
jobs:
2828
setup-environment:
29-
runs-on: ubuntu-24.04
30-
steps:
31-
- name: Check out the codebase.
32-
uses: actions/checkout@v4
33-
34-
- name: Set up Go
35-
uses: actions/setup-go@v5
36-
with:
37-
go-version: ${{ env.GO_VERSION }}
38-
cache-dependency-path: '**/go.sum'
39-
40-
- name: Installing dependency
41-
run: |
42-
make install-tools
29+
name: setup-environment
30+
uses: ./.github/workflows/setup-environment.yml
4331

4432
cross-compile:
45-
runs-on: ubuntu-24.04
4633
needs: [setup-environment]
4734
strategy:
4835
matrix:
4936
SYS_BINARIES: [ "binaries-linux_amd64", "binaries-linux_arm64", "binaries-linux_ppc64le" ]
50-
steps:
51-
- name: Check out the codebase.
52-
uses: actions/checkout@v4
53-
54-
- name: Set up Go
55-
uses: actions/setup-go@v5
56-
with:
57-
go-version: ${{ env.GO_VERSION }}
58-
cache-dependency-path: '**/go.sum'
59-
60-
- name: Build Collector
61-
run: |
62-
make ${{ matrix.SYS_BINARIES }}
63-
64-
- name: Uploading binaries
65-
uses: actions/upload-artifact@v4
66-
with:
67-
name: ${{ matrix.SYS_BINARIES }}
68-
path: |
69-
./bin/*
37+
uses: ./.github/workflows/compile.yml
38+
with:
39+
sys_binary: ${{ matrix.SYS_BINARIES }}
7040

7141
agent-bundle-linux:
7242
runs-on: ${{ fromJSON('["ubuntu-24.04", "otel-arm64"]')[matrix.ARCH == 'arm64'] }}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: setup-environment
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
GO_VERSION: 1.23.8
8+
9+
jobs:
10+
setup-environment:
11+
name: setup-environment
12+
runs-on: ubuntu-24.04
13+
steps:
14+
- name: Check out the codebase.
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: ${{ env.GO_VERSION }}
21+
cache-dependency-path: '**/go.sum'
22+
23+
- name: Installing dependency
24+
run: |
25+
make install-tools

.github/workflows/splunk-ta-otel.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,7 @@ env:
2323
jobs:
2424
setup-environment:
2525
name: setup-environment
26-
runs-on: ubuntu-24.04
27-
steps:
28-
- name: Check out the codebase.
29-
uses: actions/checkout@v4
30-
31-
- name: Set up Go
32-
uses: actions/setup-go@v5
33-
with:
34-
go-version: ${{ env.GO_VERSION }}
35-
cache-dependency-path: '**/go.sum'
36-
37-
- name: Installing dependency
38-
run: |
39-
make install-tools
40-
26+
uses: ./.github/workflows/setup-environment.yml
4127

4228
test:
4329
name: test

.github/workflows/win-package-test.yml

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,47 +26,17 @@ env:
2626

2727
jobs:
2828
setup-environment:
29-
runs-on: ubuntu-24.04
30-
steps:
31-
- name: Check out the codebase.
32-
uses: actions/checkout@v4
33-
34-
- name: Set up Go
35-
uses: actions/setup-go@v5
36-
with:
37-
go-version: ${{ env.GO_VERSION }}
38-
cache-dependency-path: '**/go.sum'
39-
40-
- name: Installing dependency
41-
run: |
42-
make install-tools
29+
name: setup-environment
30+
uses: ./.github/workflows/setup-environment.yml
4331

4432
cross-compile:
45-
runs-on: ubuntu-24.04
4633
needs: [setup-environment]
4734
strategy:
4835
matrix:
4936
SYS_BINARIES: [ "binaries-windows_amd64" ]
50-
steps:
51-
- name: Check out the codebase.
52-
uses: actions/checkout@v4
53-
54-
- name: Set up Go
55-
uses: actions/setup-go@v5
56-
with:
57-
go-version: ${{ env.GO_VERSION }}
58-
cache-dependency-path: '**/go.sum'
59-
60-
- name: Build Collector
61-
run: |
62-
make ${{ matrix.SYS_BINARIES }}
63-
64-
- name: Uploading binaries
65-
uses: actions/upload-artifact@v4
66-
with:
67-
name: ${{ matrix.SYS_BINARIES }}
68-
path: |
69-
./bin/*
37+
uses: ./.github/workflows/compile.yml
38+
with:
39+
sys_binary: ${{ matrix.SYS_BINARIES }}
7040

7141
agent-bundle-windows:
7242
runs-on: ${{ matrix.OS }}

0 commit comments

Comments
 (0)