forked from tmc/langchaingo
-
Notifications
You must be signed in to change notification settings - Fork 7
156 lines (136 loc) · 4.83 KB
/
ci.yaml
File metadata and controls
156 lines (136 loc) · 4.83 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# GitHub Actions CI workflow for langchaingo.
name: CI
on:
push:
branches:
- main-vxcontrol
pull_request:
branches:
- main-vxcontrol
permissions:
contents: read
jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
check-latest: false
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: v2.8.0
args: --timeout=5m
skip-cache: false
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
check-latest: false
- name: Build
run: go build -v ./...
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
check-latest: false
- name: Get Go version
id: go-version
run: |
GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//')
echo "Go version: $GO_VERSION"
echo "version=$GO_VERSION" >> $GITHUB_OUTPUT
- name: Test
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
go test -timeout=20m -race -v -json -coverprofile=coverage-${{ steps.go-version.outputs.version }}.out ./... | tee test-results-${{ steps.go-version.outputs.version }}.ndjson
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results-go${{ steps.go-version.outputs.version }}.ndjson
path: |
test-results-${{ steps.go-version.outputs.version }}.ndjson
coverage-${{ steps.go-version.outputs.version }}.out
coverage:
name: coverage
needs: [test]
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
cache: true
check-latest: false
- name: Download all test results
uses: actions/download-artifact@v4
with:
pattern: test-results-*
path: test-results
- name: Generate coverage report
run: |
# Find the latest Go version coverage file (highest version number)
COVERAGE_FILE=$(find test-results -name "coverage-*.out" -type f | sort -V | tail -1)
if [ -z "$COVERAGE_FILE" ]; then
echo "No coverage file found"
exit 1
fi
# Extract Go version from filename
GO_VERSION=$(basename "$COVERAGE_FILE" | sed 's/coverage-//' | sed 's/.out//')
# Generate coverage reports
go tool cover -html="$COVERAGE_FILE" -o coverage.html
go tool cover -func="$COVERAGE_FILE" -o coverage.txt
# Extract total coverage percentage
TOTAL_COVERAGE=$(go tool cover -func="$COVERAGE_FILE" | grep total | awk '{print $3}')
# Get all tested Go versions
TESTED_VERSIONS=$(find test-results -name "coverage-*.out" -type f | sed 's/.*coverage-//' | sed 's/.out//' | sort -V | paste -sd, -)
# Get workflow run URL
WORKFLOW_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# Create markdown summary
cat > coverage-summary.md << EOF
## Test Coverage: ${TOTAL_COVERAGE}
**Go versions tested:** ${TESTED_VERSIONS}
[Download Coverage Report](${WORKFLOW_URL}#artifacts) • [View Workflow](${WORKFLOW_URL})
EOF
# Output to GitHub Actions summary
cat coverage-summary.md >> $GITHUB_STEP_SUMMARY
- name: Upload coverage artifacts
uses: actions/upload-artifact@v4
id: coverage-artifact
with:
name: coverage-report-html
path: |
coverage.html
coverage.txt
coverage-summary.md
test-results/**/coverage-*.out
- name: Add artifact URL to summary
if: steps.coverage-artifact.outputs.artifact-url != ''
run: |
cat >> $GITHUB_STEP_SUMMARY << EOF
---
### Direct Artifact Link
[**Download Coverage Report**](${{ steps.coverage-artifact.outputs.artifact-url }})
> **Note:** You must be logged in to GitHub to download this artifact.
EOF