Skip to content

Commit 923c1f3

Browse files
authored
enable unit test for memory-bandwidth-exporter (#400)
Signed-off-by: Yingchun Guo <[email protected]>
1 parent 26f9b16 commit 923c1f3

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

.github/workflows/pr-go-unittests.yaml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
1010
paths:
1111
- microservices-connector/**
12+
- kubernetes-addons/memory-bandwidth-exporter/**
1213
- "!microservices-connector/helm/**"
1314
- "!**.md"
1415
- "!**.txt"
@@ -21,11 +22,45 @@ concurrency:
2122
cancel-in-progress: true
2223

2324
env:
24-
GOSRC_DIR: "microservices-connector"
25+
GMC_DIR: "microservices-connector"
26+
MBE_DIR: "kubernetes-addons/memory-bandwidth-exporter"
2527

2628
jobs:
29+
job1:
30+
name: Get-test-matrix
31+
runs-on: ubuntu-latest
32+
outputs:
33+
run_matrix: ${{ steps.get-test-matrix.outputs.run_matrix }}
34+
steps:
35+
- name: Checkout out Repo
36+
uses: actions/checkout@v4
37+
with:
38+
fetch-depth: 0
39+
40+
- name: Get test matrix
41+
id: get-test-matrix
42+
run: |
43+
set -xe
44+
base_commit=${{ github.event.pull_request.base.sha }}
45+
merged_commit=${{ github.event.pull_request.head.sha }}
46+
run_matrix="["
47+
if git diff --name-only ${base_commit} ${merged_commit} | grep -q "^${GMC_DIR}/"; then
48+
run_matrix="${run_matrix}\"${GMC_DIR}\","
49+
fi
50+
if git diff --name-only ${base_commit} ${merged_commit} | grep -q "^${MBE_DIR}/"; then
51+
run_matrix="${run_matrix}\"${MBE_DIR}\","
52+
fi
53+
run_matrix=${run_matrix%,}"]"
54+
echo "run_matrix=${run_matrix}"
55+
echo "run_matrix=${run_matrix}" >> $GITHUB_OUTPUT
56+
2757
go-unittests:
58+
needs: [job1]
2859
runs-on: ubuntu-latest
60+
if: always() && ${{ needs.job1.outputs.run_matrix.length }} > 0
61+
strategy:
62+
matrix:
63+
gopath: ${{ fromJSON(needs.job1.outputs.run_matrix) }}
2964
permissions:
3065
contents: write
3166
actions: write
@@ -47,15 +82,15 @@ jobs:
4782
with:
4883
args: --timeout=10m
4984
version: v1.55.2
50-
working-directory: ${{ env.GOSRC_DIR }}
85+
working-directory: ${{ matrix.gopath }}
5186

5287
- name: Run golangunit test
5388
run: |
54-
cd $GOSRC_DIR
89+
cd ${{ matrix.gopath }}
5590
make test
5691
5792
- name: Run tests and generate coverage
5893
run: |
59-
cd $GOSRC_DIR
94+
cd ${{ matrix.gopath }}
6095
go test -coverprofile=coverage.out $(go list ./... | grep -v /e2e)
6196
../.github/workflows/scripts/go-coverage.sh

0 commit comments

Comments
 (0)