forked from valkey-io/valkey-glide-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
322 lines (284 loc) · 13.2 KB
/
Copy pathtest.yml
File metadata and controls
322 lines (284 loc) · 13.2 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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
name: Reusable Test Workflow
on:
workflow_call:
inputs:
profile:
required: true
type: string
description: "Test profile. See profiles.json for available profiles."
package-version:
required: false
type: string
description: >-
NuGet package version to test against (e.g. "1.0.0").
When set, project references are replaced with this package version.
When absent, tests run against source (default for CI and FMT).
Required when package-artifact-name is set.
package-artifact-name:
required: false
type: string
description: >-
Name of a workflow artifact containing the .nupkg file.
Used for CD dry-run testing when the package has not been published to nuget.org.
When set, the artifact is downloaded and registered as a local NuGet source.
Requires package-version to also be set.
env:
CARGO_TERM_COLOR: always
GLIDE_VERSION: ${{ inputs.package-version || 'unknown' }}
jobs:
load-matrix:
runs-on: ubuntu-latest
outputs:
host-matrix: ${{ steps.load.outputs.host-matrix }}
container-host-matrix: ${{ steps.load.outputs.container-host-matrix }}
server-matrix: ${{ steps.load.outputs.server-matrix }}
dotnet-matrix: ${{ steps.load.outputs.dotnet-matrix }}
steps:
- name: Validate inputs
shell: bash
env:
PACKAGE_ARTIFACT_NAME: ${{ inputs.package-artifact-name }}
PACKAGE_VERSION: ${{ inputs.package-version }}
run: |
if [[ -n "$PACKAGE_ARTIFACT_NAME" && -z "$PACKAGE_VERSION" ]]; then
echo "ERROR: package-artifact-name requires package-version to also be set"
exit 1
fi
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout: .github/json_matrices
- name: Load and filter matrices
id: load
working-directory: .github/json_matrices
env:
PROFILE: ${{ inputs.profile }}
run: python3 load_matrices.py "$PROFILE"
test-with-runners:
name: net${{ matrix.dotnet }}, ${{ matrix.server.type }} ${{ matrix.server.version }}, ${{ matrix.host.target }}
needs: load-matrix
timeout-minutes: 100
strategy:
fail-fast: false
matrix:
dotnet: ${{ fromJson(needs.load-matrix.outputs.dotnet-matrix) }}
server: ${{ fromJson(needs.load-matrix.outputs.server-matrix) }}
host: ${{ fromJson(needs.load-matrix.outputs.host-matrix) }}
runs-on: ${{ matrix.host.runner }}
env:
VALKEY_GLIDE_DNS_TESTS_ENABLED: "1"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: true
- name: Determine whether to run with coverage
shell: bash
run: |
SERVER_TYPE=$(jq -r '.server_type' dev/coverage/coverage-baseline.json)
SERVER_VERSION=$(jq -r '.server_version' dev/coverage/coverage-baseline.json)
RUN_COVERAGE=false
if [[ "${{ matrix.dotnet }}" == "8.0" \
&& "${{ matrix.server.type }}" == "$SERVER_TYPE" \
&& "${{ matrix.server.version }}" == "$SERVER_VERSION" \
&& "${{ matrix.host.runner }}" == "ubuntu-24.04" ]]; then
RUN_COVERAGE=true
fi
echo "RUN_COVERAGE=$RUN_COVERAGE" >> "$GITHUB_ENV"
- name: Output matrix parameters
env:
MATRIX_JSON: ${{ toJson(matrix) }}
PROFILE: ${{ inputs.profile }}
PACKAGE_VERSION: ${{ inputs.package-version || 'source' }}
run: |
echo "Job running with the following matrix configuration:"
echo "$MATRIX_JSON"
echo "Profile: $PROFILE"
echo "Package version: $PACKAGE_VERSION"
- name: Set up dotnet ${{ matrix.dotnet }}
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
# .NET 10 SDK to build project
# matrix.dotnet SDK for test execution
dotnet-version: |
10
${{ matrix.dotnet }}
env:
DOTNET_INSTALL_DIR: ~/.dotnet
- name: Download package artifact
if: ${{ inputs.package-artifact-name != '' }}
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ inputs.package-artifact-name }}
path: nuget.local
- name: Set up local NuGet source
if: ${{ inputs.package-artifact-name != '' }}
shell: bash
run: |
ls -l "$GITHUB_WORKSPACE/nuget.local"
dotnet nuget add source "$GITHUB_WORKSPACE/nuget.local"
dotnet nuget config paths
- name: Patch project references to NuGet package
if: ${{ inputs.package-version != '' }}
shell: bash
env:
PACKAGE_VERSION: ${{ inputs.package-version }}
run: |
dotnet remove tests/Valkey.Glide.TestUtils reference sources/Valkey.Glide/Valkey.Glide.csproj
dotnet remove tests/Valkey.Glide.IntegrationTests reference sources/Valkey.Glide/Valkey.Glide.csproj
dotnet add tests/Valkey.Glide.TestUtils package Valkey.Glide --version "$PACKAGE_VERSION"
dotnet add tests/Valkey.Glide.IntegrationTests package Valkey.Glide --version "$PACKAGE_VERSION"
git diff
- name: Install shared software dependencies
uses: ./.github/actions/install-shared-dependencies
with:
os: ${{ matrix.host.os }}
target: ${{ matrix.host.target }}
server-version: ${{ matrix.server.version }}
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
if: ${{ inputs.package-version == '' }}
with:
path: rust/target
key: rust-${{ matrix.host.target }}
- name: Install Task
uses: go-task/setup-task@3be4020d41929789a01026e0e427a4321ce0ad44 # v2.0.0
- name: Unit tests - dotnet ${{ matrix.dotnet }}
run: >-
task test:unit
configuration=Debug
verbosity=detailed
${{ env.RUN_COVERAGE == 'true' && 'coverage=true' || '' }}
- name: Configure DNS for integration tests
if: ${{ matrix.host.target != 'aarch64-pc-windows-msvc' }}
shell: bash
run: |
ENTRIES="127.0.0.1 valkey.glide.test.tls.com
127.0.0.1 valkey.glide.test.no_tls.com
::1 valkey.glide.test.tls.com
::1 valkey.glide.test.no_tls.com"
if [[ "${{ runner.os }}" == "Windows" ]]; then
echo "$ENTRIES" >> /c/Windows/System32/drivers/etc/hosts
else
echo "$ENTRIES" | sudo tee -a /etc/hosts
fi
- name: Integration tests - dotnet ${{ matrix.dotnet }}
if: ${{ matrix.host.target != 'aarch64-pc-windows-msvc' }}
env:
AWS_ACCESS_KEY_ID: test_secret_key
AWS_SECRET_ACCESS_KEY: test_access_key
AWS_SESSION_TOKEN: test_session_token
run: >-
task test:integration
configuration=Debug
verbosity=detailed
${{ env.RUN_COVERAGE == 'true' && 'coverage=true' || '' }}
- name: Generate coverage reports and check baseline
if: ${{ env.RUN_COVERAGE == 'true' }}
shell: bash
run: |
task coverage:install
task coverage:report
task coverage:check
test-with-containers:
name: net${{ matrix.dotnet }}, ${{ matrix.server.type }} ${{ matrix.server.version }}, ${{ matrix.host.image }}
needs: load-matrix
if: ${{ needs.load-matrix.outputs.container-host-matrix != '[]' }}
timeout-minutes: 100
strategy:
fail-fast: false
matrix:
dotnet: ${{ fromJson(needs.load-matrix.outputs.dotnet-matrix) }}
server: ${{ fromJson(needs.load-matrix.outputs.server-matrix) }}
host: ${{ fromJson(needs.load-matrix.outputs.container-host-matrix) }}
runs-on: ${{ matrix.host.runner }}
container:
image: ${{ matrix.host.image }}
env:
VALKEY_GLIDE_DNS_TESTS_ENABLED: "1"
steps:
- name: Install container prerequisites
run: |
yum update -y
yum install -y git tar findutils libicu
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: true
- name: Output matrix parameters
env:
MATRIX_JSON: ${{ toJson(matrix) }}
PROFILE: ${{ inputs.profile }}
PACKAGE_VERSION: ${{ inputs.package-version || 'source' }}
run: |
echo "Job running with the following matrix configuration:"
echo "$MATRIX_JSON"
echo "Profile: $PROFILE"
echo "Package version: $PACKAGE_VERSION"
- name: Set up dotnet ${{ matrix.dotnet }}
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
# .NET 10 SDK to build project
# matrix.dotnet SDK for test execution
dotnet-version: |
10
${{ matrix.dotnet }}
- name: Install shared software dependencies
uses: ./.github/actions/install-shared-dependencies
with:
os: ${{ matrix.host.os }}
target: ${{ matrix.host.target }}
server-version: ${{ matrix.server.version }}
- name: Configure DNS for tests
shell: bash
run: |
ENTRIES="127.0.0.1 valkey.glide.test.tls.com
127.0.0.1 valkey.glide.test.no_tls.com
::1 valkey.glide.test.tls.com
::1 valkey.glide.test.no_tls.com"
echo "$ENTRIES" | tee -a /etc/hosts
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: rust/target
key: rust-${{ matrix.host.image }}
- name: Install Task
uses: go-task/setup-task@3be4020d41929789a01026e0e427a4321ce0ad44 # v2.0.0
- name: Test dotnet ${{ matrix.dotnet }}
run: task test verbosity=detailed
# See: https://github.com/valkey-io/valkey-glide-csharp/issues/390
test-modules:
name: Module tests (Docker, net${{ matrix.dotnet }})
needs: load-matrix
runs-on: ubuntu-24.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
dotnet: ${{ fromJson(needs.load-matrix.outputs.dotnet-matrix) }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: true
- name: Set up dotnet ${{ matrix.dotnet }}
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
# .NET 10 SDK to build project
# matrix.dotnet SDK for test execution
dotnet-version: |
10
${{ matrix.dotnet }}
env:
DOTNET_INSTALL_DIR: ~/.dotnet
- name: Install shared software dependencies
uses: ./.github/actions/install-shared-dependencies
with:
os: ubuntu
target: x86_64-unknown-linux-gnu
server-version: "9.0"
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: rust/target
key: rust-x86_64-unknown-linux-gnu
- name: Install Task
uses: go-task/setup-task@3be4020d41929789a01026e0e427a4321ce0ad44 # v2.0.0
- name: Run module tests against Docker servers
run: >-
task test:integration
filter=ServerModules
verbosity=detailed