-
-
Notifications
You must be signed in to change notification settings - Fork 749
257 lines (223 loc) · 7.2 KB
/
ci.yml
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
name: CI
on:
pull_request:
branches:
- main
- main-version-*
concurrency:
group: ci-new-2-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
check-changes:
name: Check for Changes
runs-on: ubuntu-latest
outputs:
website_changes: ${{ steps.check-website.outputs.website_changes }}
library_changes: ${{ steps.check-library.outputs.library_changes }}
src_changes: ${{ steps.check-src.outputs.src_changes }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 2
show-progress: false
- name: Check for changes in website directory
id: check-website
run: |
changes=$(git diff --name-only HEAD~1 HEAD -- ./website)
if [[ -n "$changes" ]]; then
echo "::set-output name=website_changes::true"
else
echo "::set-output name=website_changes::false"
fi
- name: Check for changes outside website directory
id: check-library
run: |
changes=$(git diff --name-only HEAD~1 HEAD -- ':!./website')
if [[ -n "$changes" ]]; then
echo "::set-output name=library_changes::true"
else
echo "::set-output name=library_changes::false"
fi
- name: Check for changes in src directory
id: check-src
run: |
changes=$(git diff --name-only HEAD~1 HEAD -- ./src)
if [[ -n "$changes" ]]; then
echo "::set-output name=src_changes::true"
else
echo "::set-output name=src_changes::false"
fi
spellcheck:
name: "Spellcheck Documentation"
runs-on: ubuntu-latest
needs: check-changes
if: needs.check-changes.outputs.website_changes == 'true'
steps:
- uses: actions/checkout@v4
name: Check out the code
with:
show-progress: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: "yarn"
cache-dependency-path: "website/yarn.lock"
- name: Install cspell
run: npm install -g cspell
- name: run cspell
run: cspell --config ./cspell.json "website/src/**/*.md" --no-progress --no-cache
linting:
name: "Markdown linting"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Check out the code
with:
show-progress: false
- uses: actions/setup-node@v4
name: Setup node
with:
node-version: 22
- run: npm install -g markdownlint-cli2
name: Install markdownlint-cli2
- run: markdownlint-cli2 "*.md" "website/src/**/*.md"
name: run Markdownlint
website-tests:
name: "Website Tests"
needs: check-changes
if: needs.check-changes.outputs.website_changes == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
show-progress: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: "yarn"
cache-dependency-path: "website/yarn.lock"
- name: Cache Yarn Packages
uses: actions/cache@v4
with:
path: |
website/.yarn/cache
website/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('website/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Packages
run: yarn --immutable --network-timeout 100000
working-directory: website
- name: Build Website
run: yarn build --prefix-paths
working-directory: website
configure:
name: Generate Test Matrix
runs-on: ubuntu-latest
needs: check-changes
if: needs.check-changes.outputs.library_changes == 'true'
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout to repository
uses: actions/checkout@v4
with:
show-progress: false
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
- name: Generate Test Matrix
run: dotnet run --project ./.build -- GenerateMatrix
- name: Export Test Matrix
id: set-matrix
run: echo "matrix=$(jq -c . < ./matrix.json)" >> $GITHUB_OUTPUT
library-tests:
name: Run ${{ matrix.name }}
runs-on: ubuntu-latest
needs: [configure, check-changes]
if: needs.check-changes.outputs.library_changes == 'true'
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.configure.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: false
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.x
9.x
- name: Run Build
id: run-build
run: dotnet build ${{ matrix.path }} --framework net9.0 --verbosity q
timeout-minutes: 5
- name: Run tests
id: run-tests
timeout-minutes: 15
continue-on-error: false
run: >
dotnet test ${{ matrix.path }}
--collect:"XPlat Code Coverage;Format=opencover"
--framework net9.0
--logger trx
--no-build
--
DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.ExcludeByFile="**/test/**"
env:
CI_BUILD: true
- name: Upload Test Results as Artifact
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.name }}
path: ${{ matrix.directoryPath }}/TestResults/*.trx
- name: Upload Coverage File as Artifact
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.name }}
# The * matches a single directory that is named with a GUID.
# Take note of https://github.com/microsoft/vstest/issues/2334.
path: ${{ matrix.directoryPath }}/TestResults/*/coverage.opencover.xml
- name: Upload mismatch files as Artifact
if: steps.run-tests.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: mismatch-files-${{ matrix.name }}
path: ${{ matrix.directoryPath }}/**/__mismatch__/*
upload-coverage:
name: Upload Coverage
needs: library-tests
runs-on: ubuntu-latest
steps:
- name: Download all coverage artifacts
uses: actions/download-artifact@v4
with:
path: ./output/download
pattern: coverage-*
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
timeout-minutes: 10
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: graphql-platform
flags: unittests
fail_ci_if_error: true
ci-status-check:
name: "CI Status Check"
needs: [library-tests, website-tests]
if: always()
runs-on: ubuntu-latest
steps:
- name: Check if Library Tests or Website Tests failed
run: exit 1
if: |
always() &&
(needs.library-tests.result == 'failure' ||
needs.website-tests.result == 'failure')