-
Notifications
You must be signed in to change notification settings - Fork 4
290 lines (254 loc) · 9.66 KB
/
main.yaml
File metadata and controls
290 lines (254 loc) · 9.66 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
name: Main
on:
push:
branches:
- main
tags:
- "**"
paths-ignore:
- "docs/**"
- "README.rst"
- "LICENSE.md"
- "publishing.md"
pull_request:
env:
DOTNET_VERSION: "8.x"
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
OKTA_CLIENT_SECRET: ${{ secrets.OKTA_CLIENT_SECRET }}
OKTA_DUMMY_CI_PW: ${{ secrets.OKTA_DUMMY_CI_PW }}
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
dry-run: ${{ steps.check-dry-run.outputs.enabled }}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 2
- name: Check for dry-run mode
id: check-dry-run
run: |
# For PRs, check the actual HEAD commit (not the merge commit)
# For push events, check the latest commit
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
# Get the actual branch HEAD commit message (not the merge commit)
COMMIT_MSG=$(git log -1 --pretty=%B HEAD^2 2>/dev/null || git log -1 --pretty=%B)
PR_TITLE="${{ github.event.pull_request.title }}"
else
COMMIT_MSG=$(git log -1 --pretty=%B)
PR_TITLE=""
fi
echo "Event: ${{ github.event_name }}"
echo "Commit message: $COMMIT_MSG"
echo "PR title: $PR_TITLE"
# Check if [dry-run] appears in commit message or PR title
if [[ "$COMMIT_MSG" == *"[dry-run]"* ]] || [[ "$PR_TITLE" == *"[dry-run]"* ]]; then
echo "enabled=true" >> $GITHUB_OUTPUT
echo "🏃 DRY-RUN MODE ENABLED"
else
echo "enabled=false" >> $GITHUB_OUTPUT
fi
check_formatting:
name: Check Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Get list of changed C# files
id: changed-files
uses: tj-actions/changed-files@v46
with:
files: |
**.cs
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Check formatting
if: steps.changed-files.outputs.any_changed == 'true'
run: |
dotnet tool restore
dotnet csharpier check ${{ steps.changed-files.outputs.all_changed_files }}
unit-tests:
name: Unit Tests
needs: [setup]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.*proj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Run unit tests with coverage (or dry-run)
run: |
if [[ "${{ needs.setup.outputs.dry-run }}" == "true" ]]; then
echo "🏃 DRY-RUN MODE: Skipping actual test execution"
echo "Would run: dotnet test --no-restore --filter \"FullyQualifiedName~Weaviate.Client.Tests.Unit\" --logger \"trx;LogFileName=test-unit-results.trx\" --collect:\"XPlat Code Coverage\" --results-directory ./test-results"
# Create dummy test results and coverage files
mkdir -p ./test-results
mkdir -p ./test-results/coverage
echo '<?xml version="1.0" encoding="utf-8"?><coverage line-rate="0.85" branch-rate="0.75"><packages><package name="Weaviate.Client" line-rate="0.85" branch-rate="0.75"><classes></classes></package></packages></coverage>' > ./test-results/coverage/coverage.cobertura.xml
echo '<?xml version="1.0" encoding="utf-8"?><TestRun><ResultSummary outcome="Completed"><Counters total="42" executed="42" passed="42" failed="0" error="0" timeout="0" aborted="0" inconclusive="0" passedButRunAborted="0" notRunnable="0" notExecuted="0" disconnected="0" warning="0" completed="0" inProgress="0" pending="0" /></ResultSummary></TestRun>' > ./test-results/test-unit-results.trx
else
dotnet test --no-restore \
--filter "FullyQualifiedName~Weaviate.Client.Tests.Unit" \
--logger "trx;LogFileName=test-unit-results.trx" \
--collect:"XPlat Code Coverage" \
--results-directory ./test-results
fi
- name: Upload test results
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-results-unit
path: ./test-results/*.trx
retention-days: 7
- name: Upload coverage data
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-unit
path: ./test-results/**/coverage.cobertura.xml
retention-days: 7
# =============================================================================
# Integration Tests - All Weaviate Versions
# To add a new version: Add it to the matrix.version array below
# =============================================================================
test-weaviate-versions:
name: Test on Weaviate v${{ matrix.version }}
permissions:
contents: read
needs: [unit-tests, setup]
strategy:
fail-fast: false
matrix:
version: ["1.31.16", "1.32.11", "1.33.0", "1.34.0-rc.0"]
uses: ./.github/workflows/test-on-weaviate-version.yml
secrets: inherit
with:
weaviate-version: ${{ matrix.version }}
dry-run: ${{ needs.setup.outputs.dry-run == 'true' }}
run-slow-tests: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && !github.event.pull_request.draft && !contains(github.event.pull_request.body, '[skip-slow]')) }}
test-summary:
name: Test Summary
needs:
- setup
- unit-tests
- test-weaviate-versions
runs-on: ubuntu-latest
if: always()
permissions:
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Download all coverage artifacts
uses: actions/download-artifact@v4
with:
pattern: coverage-*
path: ./all-coverage
merge-multiple: true
- name: Install ReportGenerator
run: dotnet tool install -g dotnet-reportgenerator-globaltool
- name: Generate coverage report
run: |
reportgenerator \
-reports:"./all-coverage/**/coverage.cobertura.xml" \
-targetdir:"./coveragereport" \
-reporttypes:"Html;MarkdownSummary;Cobertura" \
-title:"Weaviate C# Client Coverage"
- name: Upload HTML coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report-html
path: ./coveragereport
retention-days: 30
- name: Add coverage to PR comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
header: coverage
path: ./coveragereport/Summary.md
- name: Download all test results
uses: actions/download-artifact@v4
continue-on-error: true
with:
pattern: test-results-*
path: ./all-test-results
- name: Generate test summary
run: |
if [[ "${{ needs.setup.outputs.dry-run }}" == "true" ]]; then
echo "🏃 DRY-RUN MODE: Skipping test summary generation"
elif [ -d "./all-test-results" ] && [ -n "$(find ./all-test-results -name "*.trx" 2>/dev/null)" ]; then
echo "📊 Generating test summary from TRX files..."
dotnet tool update -g dotnet-trx
find ./all-test-results -name "*.trx" -exec trx {} \;
else
echo "✅ No test failures - all tests passed!"
fi
- name: Check test status
run: |
if [ "${{ needs.unit-tests.result }}" != "success" ]; then
echo "Unit tests failed"
exit 1
fi
if [ "${{ needs.test-weaviate-versions.result }}" != "success" ]; then
echo "Integration tests failed on one or more Weaviate versions"
exit 1
fi
build-and-publish:
name: Build and Publish to NuGet
needs: [test-summary]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
permissions:
contents: write
steps:
- name: Check for required secrets
run: |
if [ -z "${{ secrets.NUGET_APIKEY }}" ]; then echo "Warning: NUGET_APIKEY is not set"; fi
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
fetch-tags: true
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/.*proj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Create NuGet package
run: dotnet pack -c Release -o out src/Weaviate.Client/
- name: Push package to NuGet
run: dotnet nuget push './out/*.nupkg' --skip-duplicate --api-key ${{ secrets.NUGET_APIKEY }} --source https://api.nuget.org/v3/index.json
- name: GH Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
draft: true
files: ./out/*.nupkg