Skip to content

Commit fabb463

Browse files
authored
[chore][CICD] Reuse more GitHub workflow jobs (#6329)
* [chore][CICD] Move more functionality to reusable workflows * newlines at end of files, fix incorrect refactoring * env -> inputs * go version 1.23.8 -> 1.23.10 * fix formatting of workflows: name of job must be under "jobs:" block * Don't put reusable action step under "steps" block * fix refactor * runs-on and uses should not be used together * don't use runs-on wiht uses * ARCH -> OS, move job under "jobs" block, add runs-on in unit tests * setup go before unit tests, remove darwin-test * specify go_version in unit-test * move setup-environment to composite action instead of reusable workflow * newline at end of file, update step title * reuse more with added Ansible functionality * otel-arm64 -> ubuntu-24.04-arm * remove checkout from setup-environment composite action * use caller workflow env.GO_VERSION for setup-environment * remove sparse checkout for the updated workflow requirements * revert ubuntu-24.04-arm changes * remove fetch-depth 0 for msi build workflow
1 parent 30651d4 commit fabb463

17 files changed

+375
-586
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: 'setup environment'
2+
description: 'setup go environment'
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Set up Go
8+
uses: actions/setup-go@v5
9+
with:
10+
go-version: ${{ env.GO_VERSION }}
11+
cache-dependency-path: '**/go.sum'
12+
13+
- name: Installing required tools
14+
run: |
15+
cd ${{github.workspace}} && make install-tools
16+
shell: bash
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: agent-bundle-linux
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ARCH:
7+
required: true
8+
type: string
9+
env:
10+
GO_VERSION: 1.23.10
11+
12+
jobs:
13+
agent-bundle-linux:
14+
runs-on: ${{ fromJSON('["ubuntu-24.04", "otel-arm64"]')[inputs.ARCH == 'arm64'] }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: actions/cache@v4
19+
id: bundle-cache
20+
with:
21+
path: .cache/buildx/agent-bundle-${{ inputs.ARCH }}
22+
key: agent-bundle-buildx-${{ inputs.ARCH }}-${{ hashFiles('packaging/bundle/**') }}
23+
restore-keys: |
24+
agent-bundle-buildx-${{ inputs.ARCH }}-
25+
26+
- run: make -C packaging/bundle agent-bundle-linux ARCH=${{ inputs.ARCH }}
27+
env:
28+
BUNDLE_CACHE_HIT: "${{ steps.bundle-cache.outputs.cache-hit }}"
29+
30+
- uses: actions/upload-artifact@v4
31+
with:
32+
name: agent-bundle-linux-${{ inputs.ARCH }}
33+
path: ./dist/agent-bundle_linux_${{ inputs.ARCH }}.tar.gz
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: agent-bundle-windows
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
OS:
7+
required: true
8+
type: string
9+
PIP_CACHE_DIR:
10+
required: true
11+
type: string
12+
13+
env:
14+
GO_VERSION: 1.23.10
15+
16+
jobs:
17+
agent-bundle-windows:
18+
runs-on: ${{ inputs.OS }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/cache@v4
23+
with:
24+
path: ${{ inputs.PIP_CACHE_DIR }}
25+
key: agent-bundle-windows-pip-${{ hashFiles('packaging/bundle/collectd-plugins.yaml', 'packaging/bundle/scripts/requirements.txt') }}
26+
27+
- run: ./packaging/bundle/scripts/windows/make.ps1 bundle
28+
29+
- uses: actions/upload-artifact@v4
30+
with:
31+
name: agent-bundle-windows-${{ inputs.OS }}
32+
path: ./dist/agent-bundle_windows_amd64.zip

.github/workflows/ansible.yml

Lines changed: 26 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -32,222 +32,63 @@ env:
3232
GO_VERSION: 1.23.10
3333

3434
jobs:
35-
setup-environment:
36-
runs-on: ubuntu-24.04
37-
needs: lint
38-
steps:
39-
- name: Check out the codebase.
40-
uses: actions/checkout@v4
41-
42-
- name: Set up Go
43-
uses: actions/setup-go@v5
44-
with:
45-
go-version: ${{ env.GO_VERSION }}
46-
cache-dependency-path: '**/go.sum'
47-
48-
- name: Installing dependency
49-
run: |
50-
make install-tools
51-
5235
cross-compile:
53-
runs-on: ubuntu-24.04
54-
needs: [ setup-environment ]
5536
strategy:
5637
matrix:
57-
SYS_BINARIES: [ "binaries-linux_amd64", "binaries-linux_arm64", "binaries-linux_ppc64le", "binaries-windows_amd64" ]
58-
steps:
59-
- name: Check out the codebase.
60-
uses: actions/checkout@v4
61-
62-
- name: Set up Go
63-
uses: actions/setup-go@v5
64-
with:
65-
go-version: ${{ env.GO_VERSION }}
66-
cache-dependency-path: '**/go.sum'
67-
68-
- name: Build Collector
69-
run: |
70-
make ${{ matrix.SYS_BINARIES }}
71-
72-
- name: Uploading binaries
73-
uses: actions/upload-artifact@v4
74-
with:
75-
name: ${{ matrix.SYS_BINARIES }}
76-
path: |
77-
./bin/*
38+
SYS_BINARIES: [ "binaries-linux_amd64", "binaries-linux_arm64", "binaries-linux_ppc64le" ]
39+
uses: ./.github/workflows/compile.yml
40+
with:
41+
SYS_BINARY: ${{ matrix.SYS_BINARIES }}
7842

7943
agent-bundle-linux:
80-
runs-on: ${{ fromJSON('["ubuntu-24.04", "otel-arm64"]')[matrix.ARCH == 'arm64'] }}
81-
needs: lint
8244
strategy:
8345
matrix:
8446
ARCH: [ "amd64", "arm64" ]
8547
fail-fast: false
86-
steps:
87-
- uses: actions/checkout@v4
88-
89-
- uses: actions/cache@v4
90-
id: bundle-cache
91-
with:
92-
path: .cache/buildx/agent-bundle-${{ matrix.ARCH }}
93-
key: agent-bundle-buildx-${{ matrix.ARCH }}-${{ hashFiles('packaging/bundle/**') }}
94-
restore-keys: |
95-
agent-bundle-buildx-${{ matrix.ARCH }}-
96-
97-
- run: make -C packaging/bundle agent-bundle-linux ARCH=${{ matrix.ARCH }}
98-
env:
99-
BUNDLE_CACHE_HIT: "${{ steps.bundle-cache.outputs.cache-hit }}"
100-
101-
- uses: actions/upload-artifact@v4
102-
with:
103-
name: agent-bundle-linux-${{ matrix.ARCH }}
104-
path: ./dist/agent-bundle_linux_${{ matrix.ARCH }}.tar.gz
48+
uses: ./.github/workflows/agent-bundle-linux.yml
49+
with:
50+
ARCH: ${{ matrix.ARCH }}
10551

10652
build-package:
107-
runs-on: ubuntu-24.04
10853
needs: [ cross-compile, agent-bundle-linux ]
10954
strategy:
11055
matrix:
11156
SYS_PACKAGE: [ "deb", "rpm", "tar" ]
11257
ARCH: [ "amd64", "arm64" ]
11358
fail-fast: false
114-
steps:
115-
- name: Check out the codebase.
116-
uses: actions/checkout@v4
117-
with:
118-
fetch-depth: 0
119-
120-
- name: Set up Go
121-
uses: actions/setup-go@v5
122-
with:
123-
go-version: ${{ env.GO_VERSION }}
124-
cache-dependency-path: '**/go.sum'
125-
126-
- name: Downloading binaries-linux_${{ matrix.ARCH }}
127-
uses: actions/download-artifact@v4
128-
with:
129-
name: binaries-linux_${{ matrix.ARCH }}
130-
path: ./bin
131-
132-
- uses: actions/download-artifact@v4
133-
with:
134-
name: agent-bundle-linux-${{ matrix.ARCH }}
135-
path: ./dist
136-
137-
- name: Build ${{ matrix.SYS_PACKAGE }} ${{ matrix.ARCH }} package
138-
run: make ${{ matrix.SYS_PACKAGE }}-package SKIP_COMPILE=true SKIP_BUNDLE=true VERSION="" ARCH="${{ matrix.ARCH }}"
139-
140-
- name: Uploading ${{ matrix.SYS_PACKAGE }} ${{ matrix.ARCH }} package artifacts
141-
uses: actions/upload-artifact@v4
142-
with:
143-
name: ${{ matrix.SYS_PACKAGE }}-${{ matrix.ARCH }}-package
144-
path: ./dist/splunk-otel-collector*
59+
uses: ./.github/workflows/build-package.yml
60+
with:
61+
SYS_PACKAGE: ${{ matrix.SYS_PACKAGE }}
62+
ARCH: ${{ matrix.ARCH }}
14563

14664
agent-bundle-windows:
14765
needs: lint
14866
runs-on: ${{ matrix.OS }}
14967
strategy:
15068
matrix:
15169
OS: [ "windows-2025" ]
152-
env:
70+
uses: ./.github/workflows/agent-bundle-windows.yml
71+
with:
72+
OS: ${{ matrix.OS }}
15373
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
154-
steps:
155-
- uses: actions/checkout@v4
156-
157-
- uses: actions/cache@v4
158-
with:
159-
path: ${{ env.PIP_CACHE_DIR }}
160-
key: agent-bundle-windows-pip-${{ hashFiles('packaging/bundle/collectd-plugins.yaml', 'packaging/bundle/scripts/requirements.txt') }}
161-
162-
- run: ./packaging/bundle/scripts/windows/make.ps1 bundle
163-
164-
- uses: actions/upload-artifact@v4
165-
with:
166-
name: agent-bundle-windows-${{ matrix.OS }}
167-
path: ./dist/agent-bundle_windows_amd64.zip
16874

16975
msi-custom-actions:
170-
runs-on: windows-2025
17176
needs: lint
172-
steps:
173-
- name: Check out the codebase.
174-
uses: actions/checkout@v4
175-
176-
- name: Uninstall default WiX
177-
run: choco uninstall wixtoolset
178-
179-
- name: Install WiX 3.14.0
180-
run: choco install wixtoolset --version 3.14.0 --allow-downgrade --force
181-
182-
- name: Build Custom Actions
183-
working-directory: packaging/msi/SplunkCustomActions
184-
run: |
185-
dotnet test ./test/SplunkCustomActionsTests.csproj -c Release
186-
dotnet publish ./src/SplunkCustomActions.csproj -c Release -o ./bin/Release
187-
188-
- name: Package Custom Actions
189-
run: |
190-
$WixPath = "${Env:ProgramFiles(x86)}\WiX Toolset v3.14"
191-
$sfxcaDll = "${WixPath}\SDK\x64\sfxca.dll"
192-
$Env:PATH = "${WixPath}\SDK;" + $Env:PATH
193-
$customActionDir = "${PWD}\packaging\msi\SplunkCustomActions"
194-
$customActionBinDir = "${customActionDir}\bin\Release"
195-
MakeSfxCA.exe "${PWD}\dist\SplunkCustomActions.CA.dll" `
196-
"${sfxcaDll}" `
197-
"${customActionBinDir}\SplunkCustomActions.dll" `
198-
"${customActionBinDir}\Microsoft.Deployment.WindowsInstaller.dll" `
199-
"${customActionDir}\src\CustomAction.config"
200-
201-
- uses: actions/upload-artifact@v4
202-
with:
203-
name: msi-custom-actions
204-
path: ./dist/SplunkCustomActions.CA.dll
77+
strategy:
78+
matrix:
79+
OS: [ "windows-2025" ]
80+
uses: ./.github/workflows/msi-custom-actions.yml
81+
with:
82+
OS: ${{ matrix.OS }}
20583

20684
msi-build:
207-
runs-on: ubuntu-24.04
208-
env:
209-
WINDOWS_VER: "windows-2025"
21085
needs: [cross-compile, agent-bundle-windows, msi-custom-actions]
211-
steps:
212-
- name: Check out the codebase.
213-
uses: actions/checkout@v4
214-
with:
215-
fetch-depth: 0
216-
217-
- name: Downloading binaries-windows_amd64
218-
uses: actions/download-artifact@v4
219-
with:
220-
name: binaries-windows_amd64
221-
path: ./bin
222-
223-
- name: Set up Go
224-
uses: actions/setup-go@v5
225-
with:
226-
go-version: ${{ env.GO_VERSION }}
227-
cache-dependency-path: '**/go.sum'
228-
229-
- name: Downloading agent-bundle-windows
230-
uses: actions/download-artifact@v4
231-
with:
232-
name: agent-bundle-windows-${{ env.WINDOWS_VER }}
233-
path: ./dist
234-
235-
- name: Downloading msi-custom-actions
236-
uses: actions/download-artifact@v4
237-
with:
238-
name: msi-custom-actions
239-
path: ./packaging/msi/SplunkCustomActions/bin/Release
240-
241-
- name: Build MSI
242-
run: |
243-
mkdir -p dist
244-
make msi SKIP_COMPILE=true VERSION=""
245-
246-
- name: Uploading msi build artifacts
247-
uses: actions/upload-artifact@v4
248-
with:
249-
name: msi-build
250-
path: ./dist/*.msi
86+
strategy:
87+
matrix:
88+
OS: [ "windows-2025" ]
89+
uses: ./.github/workflows/msi-build.yml
90+
with:
91+
OS: ${{ matrix.OS }}
25192

25293
lint:
25394
name: Lint

.github/workflows/auto-instrumentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
SYS_BINARIES: [ "binaries-linux_amd64", "binaries-linux_arm64" ]
3333
uses: ./.github/workflows/compile.yml
3434
with:
35-
sys_binary: ${{ matrix.SYS_BINARIES }}
35+
SYS_BINARY: ${{ matrix.SYS_BINARIES }}
3636

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

0 commit comments

Comments
 (0)