Skip to content

Commit c7a8d28

Browse files
tomerseinclaude
authored andcommitted
ci: Split unit and integration tests
Tests that drive live ETW sessions, read the runner's catalog signatures or download the loldrivers.io feed now carry the integration build tag: - internal/etw/source_test.go -> source_integration_test.go - pkg/sys/trust_test.go -> trust_integration_test.go - pkg/util/loldrivers/client_test.go -> client_integration_test.go make.bat renames the test target to unit-test and adds integration-test, which runs only the packages that have *_integration_test.go files, with the integration tag added to TAGS. golangci-lint builds with the tag so the moved files are still linted. pr.yml and master.yml replace the test job with unit-test, which no longer has continue-on-error, and integration-test, which keeps it. Only integration-test builds the internal/etw fixtures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 8a4133b commit c7a8d28

7 files changed

Lines changed: 133 additions & 9 deletions

File tree

‎.github/workflows/master.yml‎

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,62 @@ jobs:
122122
name: "fibratus-amd64-slim.exe"
123123
path: "./cmd/fibratus/fibratus.exe"
124124

125-
test:
125+
unit-test:
126+
runs-on: windows-latest
127+
needs:
128+
- build
129+
- build-slim
130+
steps:
131+
- name: Checkout
132+
uses: actions/checkout@v4
133+
- name: Install Go
134+
uses: actions/setup-go@v5
135+
with:
136+
go-version: ${{ env.GO_VERSION }}
137+
- name: Install Python
138+
uses: actions/setup-python@v5
139+
with:
140+
python-version: ${{ env.PYTHON_VERSION }}
141+
- name: Adjust pkg-config prefix
142+
shell: bash
143+
run: |
144+
sed -i 's/C:\/Python37/C:\/hostedtoolcache\/windows\/Python\/3.7.9\/x64/' pkg-config/python-37.pc
145+
- name: Setup msys2
146+
uses: msys2/setup-msys2@v2
147+
with:
148+
release: false
149+
install: >-
150+
base-devel
151+
mingw-w64-x86_64-gcc
152+
mingw-w64-x86_64-pkg-config
153+
mingw-w64-x86_64-openssl
154+
automake
155+
libtool
156+
autoconf
157+
- name: Cache yara
158+
uses: actions/cache@v4
159+
id: cache
160+
with:
161+
path: |
162+
**/yara
163+
key: ${{ runner.os }}-yara-${{ hashFiles('**/pkg/yara') }}
164+
restore-keys: |
165+
${{ runner.os }}-yara-${{ hashFiles('**/pkg/yara') }}
166+
- name: Install yara
167+
shell: msys2 {0}
168+
run: |
169+
cd yara
170+
make install
171+
- name: Test
172+
shell: bash
173+
run: |
174+
export PATH="/c/msys64/mingw64/bin:$PATH"
175+
export PKG_CONFIG_PATH=$(pwd)/pkg-config
176+
./make.bat unit-test
177+
env:
178+
TAGS: cap,yara,yara_static
179+
180+
integration-test:
126181
runs-on: windows-latest
127182
needs:
128183
- build
@@ -178,13 +233,13 @@ jobs:
178233
run: |
179234
export PATH="/c/msys64/mingw64/bin:$PATH"
180235
export PKG_CONFIG_PATH=$(pwd)/pkg-config
181-
./make.bat test
236+
./make.bat integration-test
182237
env:
183238
TAGS: cap,yara,yara_static
184239

185240
lint:
186241
runs-on: windows-latest
187-
needs: test
242+
needs: unit-test
188243
continue-on-error: true
189244
steps:
190245
- name: Checkout

‎.github/workflows/pr.yml‎

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,61 @@ jobs:
109109
name: "fibratus-amd64.msi"
110110
path: "./build/msi/fibratus-0.0.0-amd64.msi"
111111

112-
test:
112+
unit-test:
113+
runs-on: windows-latest
114+
needs:
115+
- build
116+
steps:
117+
- name: Checkout
118+
uses: actions/checkout@v4
119+
- name: Install Go
120+
uses: actions/setup-go@v5
121+
with:
122+
go-version: ${{ env.GO_VERSION }}
123+
- name: Install Python
124+
uses: actions/setup-python@v5
125+
with:
126+
python-version: ${{ env.PYTHON_VERSION }}
127+
- name: Adjust pkg-config prefix
128+
shell: bash
129+
run: |
130+
sed -i 's/C:\/Python37/C:\/hostedtoolcache\/windows\/Python\/3.7.9\/x64/' pkg-config/python-37.pc
131+
- name: Setup msys2
132+
uses: msys2/setup-msys2@v2
133+
with:
134+
release: false
135+
install: >-
136+
base-devel
137+
mingw-w64-x86_64-gcc
138+
mingw-w64-x86_64-pkg-config
139+
mingw-w64-x86_64-openssl
140+
automake
141+
libtool
142+
autoconf
143+
- name: Cache yara
144+
uses: actions/cache@v4
145+
id: cache
146+
with:
147+
path: |
148+
**/yara
149+
key: ${{ runner.os }}-yara-${{ hashFiles('**/pkg/yara') }}
150+
restore-keys: |
151+
${{ runner.os }}-yara-${{ hashFiles('**/pkg/yara') }}
152+
- name: Install yara
153+
shell: msys2 {0}
154+
run: |
155+
cd yara
156+
make install
157+
- name: Test
158+
shell: bash
159+
run: |
160+
export PATH="/c/msys64/mingw64/bin:$PATH"
161+
export PKG_CONFIG_PATH=$(pwd)/pkg-config
162+
./make.bat unit-test
163+
env:
164+
TAGS: cap,yara,yara_static
165+
166+
integration-test:
113167
runs-on: windows-latest
114168
needs:
115169
- build
@@ -164,13 +218,13 @@ jobs:
164218
run: |
165219
export PATH="/c/msys64/mingw64/bin:$PATH"
166220
export PKG_CONFIG_PATH=$(pwd)/pkg-config
167-
./make.bat test
221+
./make.bat integration-test
168222
env:
169223
TAGS: cap,yara,yara_static
170224

171225
lint:
172226
runs-on: windows-latest
173-
needs: test
227+
needs: unit-test
174228
continue-on-error: true
175229
steps:
176230
- name: Checkout

‎.golangci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
version: "2"
2+
run:
3+
build-tags:
4+
- integration
25
# run:
36
# build-tags:
47
# - cap
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build integration
2+
13
/*
24
* Copyright 2019-2020 by Nedim Sabic Sabic
35
* https://www.fibratus.io

‎make.bat‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ for /f %%p in ('go list .\...') do call set "PKGS=%%PKGS%% %%p"
4848

4949

5050
if "%~1"=="build" goto build
51-
if "%~1"=="test" goto test
51+
if "%~1"=="unit-test" goto unit-test
52+
if "%~1"=="integration-test" goto integration-test
5253
if "%~1"=="lint" goto lint
5354
if "%~1"=="fmt" goto fmt
5455
if "%~1"=="clean" goto clean
@@ -67,11 +68,18 @@ go build -ldflags %LDFLAGS% -o .\cmd\systray\fibratus-systray.exe .\cmd\systray
6768
if errorlevel 1 goto fail
6869
goto :EOF
6970

70-
:test
71+
:unit-test
7172
%GOTEST% -tags %TAGS% %PKGS%
7273
if errorlevel 1 goto fail
7374
goto :EOF
7475

76+
:integration-test
77+
set IPKGS=
78+
for /f "tokens=1" %%p in ('go list -tags integration -f "{{.ImportPath}} {{.TestGoFiles}}" .\... ^| findstr /c:"_integration_test.go"') do call set "IPKGS=%%IPKGS%% %%p"
79+
%GOTEST% -tags integration,%TAGS% %IPKGS%
80+
if errorlevel 1 goto fail
81+
goto :EOF
82+
7583
:lint
7684
%GOLINT% run --timeout 10m
7785
if errorlevel 1 goto fail
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build windows
1+
//go:build windows && integration
22

33
/*
44
* Copyright 2021-2022 by Nedim Sabic Sabic

pkg/util/loldrivers/client_test.go renamed to pkg/util/loldrivers/client_integration_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build integration
2+
13
/*
24
* Copyright 2021-2022 by Nedim Sabic Sabic
35
* https://www.fibratus.io

0 commit comments

Comments
 (0)