-
-
Notifications
You must be signed in to change notification settings - Fork 128
166 lines (131 loc) · 3.89 KB
/
test.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
name: Tests
run-name: Tests
on:
workflow_call:
inputs:
node-version:
description: "Node.js version to use"
required: true
type: string
jobs:
unit-test:
name: Run Unit Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs['node-version'] }}
- name: Install Dependencies
run: npm ci
- name: Install React 18.3.1
run: |
npm uninstall react react-dom
npm install [email protected] [email protected]
- name: Start App
run: |
npm run start &
- name: Run Unit Tests
run: npm run unit:test
integration-test:
needs: unit-test
name: Run Integration Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs['node-version'] }}
- name: Install Dependencies
run: npm ci
- name: Install React 18.3.1
run: |
npm uninstall react react-dom
npm install [email protected] [email protected]
- name: Start App
run: |
npm run start &
- name: Run Integration Tests
run: npm run int:test
package-library:
needs: integration-test
name: Package Library
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs['node-version'] }}
- name: Install Dependencies
run: npm ci
- name: Build Project
run: npm run build --if-present
- name: Package Library
id: package
run: |
npm pack
echo "PACKAGE_NAME=$(ls *.tgz)" >> $GITHUB_ENV
- name: Upload Package
uses: actions/upload-artifact@v4
with:
name: react-chatbotify-package
path: ${{ env.PACKAGE_NAME }}
retention-days: 1
compatibility-test:
needs: package-library
name: Run Compatibility Test
runs-on: ubuntu-latest
strategy:
matrix:
react-version: ["16.14.0", "17.0.2", "18.3.1", "rc"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs['node-version'] }}
- name: Install Dependencies
run: npm ci
- name: Download Packaged Library
uses: actions/download-artifact@v4
with:
name: react-chatbotify-package
- name: Create Test Project
run: |
npx create-vite@latest test-project --template react-ts
- name: Copy Template File
run: |
cp ./cypress/fixtures/templates/ChatBotApp.tsx ./test-project/src/App.tsx
if [[ "${{ matrix.react-version }}" =~ ^(18|rc) ]]; then
cp ./src/devIndex.tsx ./test-project/src/main.tsx
else
cp ./cypress/fixtures/templates/pre_react_18/index.tsx ./test-project/src/main.tsx
fi
- name: Install Dependencies in Test Project
run: |
cd ./test-project
npm install
npm install -g vite
- name: Install Specific React Version in Test Project
run: |
cd ./test-project
npm uninstall react react-dom
npm install react@${{ matrix.react-version }} react-dom@${{ matrix.react-version }}
- name: Install React ChatBotify (.tgz) into Test Project
run: |
cd ./test-project
npm install ../*.tgz
- name: Start App
run: |
cd ./test-project
vite --port 3000 &
- name: Run Library Tests
run: |
npm run int:test