-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (75 loc) · 2.41 KB
/
Copy pathverify-go.yml
File metadata and controls
86 lines (75 loc) · 2.41 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Verify Go examples
on:
push:
branches: [master]
paths:
- "go/**"
- "scenarios/live-core-enforcement/go-agent/**"
- ".github/workflows/verify-go.yml"
pull_request:
branches: [master]
paths:
- "go/**"
- "scenarios/live-core-enforcement/go-agent/**"
- ".github/workflows/verify-go.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
lint:
name: Lint Go examples (gofmt + vet)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "1.26"
cache: false
# Scope to real example modules under go/ and the scenario go-agent. The
# snippets/ tree is intentionally excluded: snippets/go/*.go are extracted
# quick-start fragments with no package clause (see scripts/extract_snippets.py),
# so they are not gofmt-parseable and must not be linted here.
- name: gofmt
run: |
unformatted=$(gofmt -l go scenarios)
if [ -n "$unformatted" ]; then
echo "::error::The following Go files are not gofmt-clean. Run 'gofmt -w' on them:"
echo "$unformatted"
exit 1
fi
- name: go vet
run: |
set -euo pipefail
for mod in $(find go scenarios -name go.mod | sort); do
dir=$(dirname "$mod")
echo "==> go vet $dir"
(cd "$dir" && go vet ./...)
done
test:
name: Test Go examples
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example:
- basic-agent
- tool-policy
- langchaingo
- cli-runtime-integration
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: "1.26"
cache-dependency-path: go/${{ matrix.example }}/go.sum
- name: Test ${{ matrix.example }}
env:
EXAMPLE: ${{ matrix.example }}
run: |
if [ -d "go/${EXAMPLE}" ]; then
cd "go/${EXAMPLE}" && go test ./...
else
echo "go/${EXAMPLE} not yet present — skipping"
fi