-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (60 loc) · 1.78 KB
/
Copy pathtest.yaml
File metadata and controls
68 lines (60 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Test Plugins
on:
pull_request:
push:
branches:
- main
permissions:
contents: read
jobs:
test:
name: Test ${{ matrix.plugin }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
plugin:
- arthas
- golang
- inspektor-gadget
- kubernetes-logs
- opensearch
- postgres
- s3
- sql-server
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check plugin changes
id: changes
env:
PLUGIN: ${{ matrix.plugin }}
EVENT_NAME: ${{ github.event_name }}
BASE_REF: ${{ github.base_ref }}
BEFORE: ${{ github.event.before }}
run: |
if [ "$EVENT_NAME" = "pull_request" ]; then
git fetch --no-tags --depth=1 origin "$BASE_REF"
changed_files=$(git diff --name-only "origin/$BASE_REF"...HEAD)
elif [ -n "$BEFORE" ] && ! printf '%s' "$BEFORE" | grep -q '^0\+$'; then
changed_files=$(git diff --name-only "$BEFORE"..HEAD)
else
changed_files=$(git diff --name-only HEAD~1..HEAD)
fi
if printf '%s\n' "$changed_files" | grep -q "^$PLUGIN/"; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Setup Go
if: steps.changes.outputs.changed == 'true'
uses: actions/setup-go@v6
with:
go-version-file: ${{ matrix.plugin }}/go.mod
cache-dependency-path: ${{ matrix.plugin }}/go.sum
- name: Test
if: steps.changes.outputs.changed == 'true'
working-directory: ${{ matrix.plugin }}
run: go test ./...