Skip to content

Commit d642b89

Browse files
authored
Add PR validation pipeline to GitHub Actions (#4976)
* Add PR validation * Add needs * Compress less files * Fix pipe * Remove cache * Add babel-jest * Add babel.config.json * Add deps * Fix syntax * Fix run jest * Fix Docker * Add Dockerfile * Add serve-test.json * Add sharding * Update matrix name * Add unit tests * Add names * Scale chrome=2 * Use Jest 28 * Fix --testPathPattern * Use babel-jest@28 * Run jest@28 in unit tests * Skip nightly tests * Fix run Jest * Run npm ci * Run npm ci under packages/test/harness/ * Remove jest-version * 20 shards * Add test results * Add needs * Fix docker-compose down * Use a different continue-on-error pattern * Disable fail-fast * Add GitHub Actions reporter * Down to 10 * Add timeout minutes * Add timeout minutes to unit tests * Remove chrome.dockerfile * Use 20 shards * Use 19 shards * Change downloads folder * Run precommit * Rename lint to static code analysis * Use 18 shards * Build during SCA * 20 shards * Upload cobertura-coverage.xml * Merge and print coverage * Add branch coverage * Add lcov and NODE_ENV * Fix lcov file extension * Print Docker logs * Disable coverage * Wait until WebDriver hub is ready * Simplify * Disable pipefail * Enable instrumentation * Fix unit test coverage * Disable Gcovr * Install lcov * Add branch coverage * Better print coverage * Remove Cobertura * Remove pipefail * Upload failing snapshots * Typo * Packing bundle/core src * Add types to unit test * Move types test to packages * Use Node 18 * Clean up and enable secure feed * Better coverage merging * Add tracefile individually * Add mutable performance * Use Node.js 18.18 * Fix flaky * Add comments * Fix flaky * Add entry * Enable Terrapin before setting up Node to improve cache
1 parent a03e74d commit d642b89

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+492
-47
lines changed
Lines changed: 310 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,310 @@
1+
name: Pull request validation
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
paths-ignore:
9+
- .github
10+
- .vscode
11+
12+
push:
13+
branches:
14+
- feat-github-workflow # Keeping the branch here so we can try out something later quickly
15+
16+
workflow_dispatch: {}
17+
18+
defaults:
19+
run:
20+
shell: bash
21+
22+
env:
23+
CI_PULL_REQUEST: 1 # Skip nightly tests
24+
NODE_ENV: test # Add instrumentation code
25+
node-version: 18.18 # Need to bump jest@29 to resolve something in https://github.com/facebook/react-native/issues/35701
26+
skip-secure-feed: false
27+
28+
jobs:
29+
build:
30+
name: Build
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- if: "env.skip-secure-feed != 'true'"
37+
name: Enable secure feed
38+
run: npx https://aka.ms/EnableSecureFeed
39+
40+
- name: Use Node.js ${{ env.node-version }}
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: ${{ env.node-version }}
44+
cache: npm
45+
46+
- run: npm clean-install
47+
48+
- run: npm run bootstrap
49+
50+
- run: npm run build --if-present
51+
52+
- name: Pack Docker artifact
53+
run: |
54+
zip docker.zip -r@ <<EOF
55+
./__tests__/
56+
./babel-jest-config.js
57+
./babel-passthru-transformer.js
58+
./babel.config.json
59+
./docker-compose-wsl2.yml
60+
./jest.config.js
61+
./package.json
62+
./package-lock.json
63+
./packages/bundle/dist/
64+
./packages/test/harness/
65+
./packages/test/page-object/dist/
66+
./serve-test.json
67+
./testharness.dockerfile
68+
./testharness2.dockerfile
69+
EOF
70+
71+
- run: ls -l docker.zip
72+
73+
- name: Upload Docker artifact
74+
uses: actions/upload-artifact@v3
75+
with:
76+
name: docker
77+
path: docker.zip
78+
retention-days: 1
79+
80+
static-code-analysis:
81+
name: Static code analysis
82+
runs-on: ubuntu-latest
83+
84+
steps:
85+
- uses: actions/checkout@v4
86+
87+
- if: "env.skip-secure-feed != 'true'"
88+
name: Enable secure feed
89+
run: npx https://aka.ms/EnableSecureFeed
90+
91+
- name: Use Node.js ${{ env.node-version }}
92+
uses: actions/setup-node@v4
93+
with:
94+
node-version: ${{ env.node-version }}
95+
cache: npm
96+
97+
- run: npm clean-install
98+
99+
- run: npm run bootstrap
100+
101+
- run: npm run build --if-present
102+
103+
- run: npm run precommit --if-present
104+
105+
unit-test:
106+
name: Unit test
107+
runs-on: ubuntu-latest
108+
109+
steps:
110+
- uses: actions/checkout@v4
111+
112+
- if: "env.skip-secure-feed != 'true'"
113+
name: Enable secure feed
114+
run: npx https://aka.ms/EnableSecureFeed
115+
116+
- name: Use Node.js ${{ env.node-version }}
117+
uses: actions/setup-node@v4
118+
with:
119+
node-version: ${{ env.node-version }}
120+
cache: npm
121+
122+
- run: npm clean-install
123+
124+
- run: npm run bootstrap
125+
126+
- run: npm run build --if-present
127+
128+
- name: Run jest --testPathPattern packages/
129+
run: |
130+
./node_modules/.bin/jest \
131+
--ci \
132+
--coverage true \
133+
--forceExit \
134+
--logHeapUsage \
135+
--runInBand \
136+
--testPathPattern=/packages/\
137+
timeout-minutes: 10
138+
139+
- if: always()
140+
name: Append ID to test result
141+
run: |
142+
ls -laR .
143+
144+
mv jest.json jest-unit.json
145+
mv lcov.info lcov-unit.info
146+
mv nunit3.xml nunit3-unit.xml
147+
mv result.trx result-unit.trx
148+
working-directory: ./coverage
149+
150+
- if: always()
151+
name: Upload test results
152+
uses: actions/upload-artifact@v3
153+
with:
154+
name: test-result
155+
path: |
156+
./coverage/jest-*.json
157+
./coverage/lcov-*.info
158+
./coverage/nunit3-*.xml
159+
./coverage/result-*.trx
160+
161+
html-test:
162+
name: HTML test (${{ format('{0}/{1}', matrix.shard-index, matrix.shard-count) }})
163+
needs:
164+
- build
165+
runs-on: ubuntu-latest
166+
strategy:
167+
fail-fast: false
168+
matrix:
169+
shard-index: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
170+
shard-count: [20]
171+
172+
steps:
173+
- if: "env.skip-secure-feed != 'true'"
174+
name: Enable secure feed
175+
run: npx https://aka.ms/EnableSecureFeed
176+
177+
- name: Use Node.js ${{ env.node-version }}
178+
uses: actions/setup-node@v4
179+
with:
180+
node-version: ${{ env.node-version }}
181+
182+
- name: Download Docker artifact
183+
uses: actions/download-artifact@v3
184+
with:
185+
name: docker
186+
187+
- run: unzip docker.zip
188+
189+
- run: rm docker.zip
190+
191+
- run: npm clean-install
192+
193+
- name: Run docker-compose build
194+
run: docker-compose -f docker-compose-wsl2.yml build --build-arg REGISTRY=mcr.microsoft.com/mirror/docker/library
195+
196+
- name: Run docker-compose up
197+
run: docker-compose -f docker-compose-wsl2.yml up --detach --scale chrome=2
198+
199+
- name: Wait for Docker to be ready
200+
run: |
201+
set +e # Disable per-command fail, we will handle cURL fail.
202+
203+
while true
204+
do
205+
curl http://localhost:4444/wd/hub/status > /tmp/wd-status.json
206+
207+
[[ $? -eq 0 ]] && cat /tmp/wd-status.json | jq -r 'if (.value.ready != true) then halt_error(1) else empty end'
208+
[[ $? -eq 0 ]] && break
209+
210+
sleep 1
211+
done
212+
213+
- name: Run jest --shard=${{ format('{0}/{1}', matrix.shard-index, matrix.shard-count) }}
214+
run: |
215+
./node_modules/.bin/jest \
216+
--ci \
217+
--coverage true \
218+
--forceExit \
219+
--logHeapUsage \
220+
--runInBand \
221+
--shard=${{ format('{0}/{1}', matrix.shard-index, matrix.shard-count) }}
222+
timeout-minutes: 10
223+
224+
- if: always()
225+
name: Print Docker logs
226+
run: docker-compose -f docker-compose-wsl2.yml logs
227+
228+
- if: always()
229+
name: Append ID to test result
230+
run: |
231+
ls -laR .
232+
233+
mv jest.json jest-${{ matrix.shard-index }}.json
234+
mv lcov.info lcov-${{ matrix.shard-index }}.info
235+
mv nunit3.xml nunit3-${{ matrix.shard-index }}.xml
236+
mv result.trx result-${{ matrix.shard-index }}.trx
237+
working-directory: ./coverage
238+
239+
- if: always()
240+
name: Upload test results
241+
uses: actions/upload-artifact@v3
242+
with:
243+
name: test-result
244+
path: |
245+
./coverage/jest-*.json
246+
./coverage/lcov-*.info
247+
./coverage/nunit3-*.xml
248+
./coverage/result-*.trx
249+
250+
- if: failure()
251+
name: Upload test snapshot diffs
252+
uses: actions/upload-artifact@v3
253+
with:
254+
name: test-snapshot-diff
255+
path: ./__tests__/__image_snapshots__/*/__diff_output__/*
256+
257+
merge-test-result:
258+
if: always()
259+
name: Merge test result
260+
needs:
261+
- html-test
262+
- unit-test
263+
runs-on: ubuntu-latest
264+
265+
steps:
266+
- name: Download test results
267+
uses: actions/download-artifact@v3
268+
with:
269+
name: test-result
270+
271+
- name: Install lcov
272+
run: sudo apt install -y lcov
273+
274+
- name: Merge lcov-*.info
275+
run: |
276+
lcov \
277+
--rc lcov_branch_coverage=1 \
278+
--add-tracefile lcov-1.info \
279+
--add-tracefile lcov-2.info \
280+
--add-tracefile lcov-3.info \
281+
--add-tracefile lcov-4.info \
282+
--add-tracefile lcov-5.info \
283+
--add-tracefile lcov-6.info \
284+
--add-tracefile lcov-7.info \
285+
--add-tracefile lcov-8.info \
286+
--add-tracefile lcov-9.info \
287+
--add-tracefile lcov-10.info \
288+
--add-tracefile lcov-11.info \
289+
--add-tracefile lcov-12.info \
290+
--add-tracefile lcov-13.info \
291+
--add-tracefile lcov-14.info \
292+
--add-tracefile lcov-15.info \
293+
--add-tracefile lcov-16.info \
294+
--add-tracefile lcov-17.info \
295+
--add-tracefile lcov-18.info \
296+
--add-tracefile lcov-19.info \
297+
--add-tracefile lcov-20.info \
298+
--add-tracefile lcov-unit.info \
299+
--output-file lcov.info
300+
301+
- if: always()
302+
name: Print coverage list
303+
run: lcov --rc lcov_branch_coverage=1 --list lcov.info
304+
305+
- if: always()
306+
name: Print coverage summary
307+
run: |
308+
echo \`\`\` >> $GITHUB_STEP_SUMMARY
309+
lcov --rc lcov_branch_coverage=1 --summary lcov.info | tee --append $GITHUB_STEP_SUMMARY
310+
echo \`\`\` >> $GITHUB_STEP_SUMMARY

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2222

2323
## [Unreleased]
2424

25+
### Changed
26+
27+
- Moved pull request validation pipeline to GitHub Actions, by [@compulim](https://github.com/compulim), in PR [#4976](https://github.com/microsoft/BotFramework-WebChat/pull/4976)
28+
2529
## [4.16.0] - 2023-11-16
2630

2731
### Breaking changes

__tests__/html/updateActivity.sameActivityId.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
// WHEN: All images (in the carousel) are loaded.
6969
await pageConditions.allImagesLoaded();
7070

71+
// WHEN: Scroll to bottom completed.
72+
await pageConditions.scrollToBottomCompleted();
73+
7174
// THEN: It should show 3 messages: 2 outgoing messages and 1 incoming message (carousel).
7275
await host.snapshot();
7376
});

__tests__/html/updateActivity.undefinedActivityId.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en-US">
33
<head>
44
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
@@ -61,6 +61,9 @@
6161
// WHEN: All images are loaded.
6262
await pageConditions.allImagesLoaded();
6363

64+
// WHEN: Scroll to bottom completed.
65+
await pageConditions.scrollToBottomCompleted();
66+
6467
// THEN: It should show 5 messages in total.
6568
await host.snapshot();
6669
});

__tests__/types/__typescript__/pass/additional-style-options-in-full.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

__tests__/types/__typescript__/pass/correct-type-dir.tsx

Lines changed: 0 additions & 3 deletions
This file was deleted.

__tests__/types/__typescript__/pass/import-component-send-text-box.tsx

Lines changed: 0 additions & 5 deletions
This file was deleted.

__tests__/types/__typescript__/pass/import-create-direct-line.tsx

Lines changed: 0 additions & 3 deletions
This file was deleted.

chrome.dockerfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

docker-compose-wsl2.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ services:
44
# On Windows, run with COMPOSE_CONVERT_WINDOWS_PATHS=1
55

66
chrome:
7-
build:
8-
context: ./
9-
dockerfile: chrome.dockerfile
7+
image: selenium/node-chrome:110.0
108
depends_on:
119
- selenium-hub
1210
- webchat
@@ -18,6 +16,8 @@ services:
1816
SE_OPTS: '--log-level WARNING'
1917
SE_NODE_SESSION_TIMEOUT: '300'
2018
shm_size: '2.5gb'
19+
volumes:
20+
- ./__tests__/setup/local/:/home/seluser/Downloads
2121

2222
selenium-hub:
2323
image: selenium/hub:4.8.1

0 commit comments

Comments
 (0)