-
Notifications
You must be signed in to change notification settings - Fork 4.5k
298 lines (262 loc) · 11.1 KB
/
client.yml
File metadata and controls
298 lines (262 loc) · 11.1 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
name: Appsmith Client Workflow
on:
push:
branches: [release, master]
# Only trigger if files have changed in this specific path
paths:
- 'app/client/**'
- '!app/client/cypress/manual_TestSuite/**'
pull_request_target:
branches: [release, master]
paths:
- 'app/client/**'
- '!app/client/cypress/manual_TestSuite/**'
# Change the working directory for all the jobs in this workflow
defaults:
run:
working-directory: app/client
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/client
shell: bash
steps:
# Checkout the code
- name: Checkout the merged commit from PR and base branch
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v2
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- name: Checkout the head commit of the branch
if: ${{ github.event_name == 'push' }}
uses: actions/checkout@v2
- name: Figure out the PR number
run: echo ${{ github.event.pull_request.number }}
- name: Use Node.js 10.16.3
uses: actions/setup-node@v1
with:
node-version: "10.16.3"
# Retrieve npm dependencies from cache. After a successful run, these dependencies are cached again
- name: Cache npm dependencies
uses: actions/cache@v2
env:
cache-name: cache-yarn-dependencies
with:
# Node dependencies are stored in `./node_modules` on Linux/macOS
path: |
'**/node_modules'
'~/.npm'
key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
# Install all the dependencies
- name: Install dependencies
run: yarn install
- name: Set the build environment based on the branch
id: vars
run: |
REACT_APP_ENVIRONMENT="DEVELOPMENT"
if [ ${GITHUB_REF} == '/refs/heads/master' ]; then
REACT_APP_ENVIRONMENT="PRODUCTION"
elif [ ${GITHUB_REF} == '/refs/heads/release' ]; then
REACT_APP_ENVIRONMENT="STAGING"
fi
echo ::set-output name=REACT_APP_ENVIRONMENT::${REACT_APP_ENVIRONMENT}
- name: Run the jest tests
run: REACT_APP_ENVIRONMENT=${{steps.vars.outputs.REACT_APP_ENVIRONMENT}} yarn run test:unit
# We burn React environment & the Segment analytics key into the build itself.
# This is to ensure that we don't need to configure it in each installation
- name: Create the bundle
run: REACT_APP_ENVIRONMENT=${{steps.vars.outputs.REACT_APP_ENVIRONMENT}} REACT_APP_FUSIONCHARTS_LICENSE_KEY=${{ secrets.APPSMITH_FUSIONCHARTS_LICENSE_KEY }} REACT_APP_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} yarn build
# Upload the build artifact so that it can be used by the test & deploy job in the workflow
- name: Upload react build bundle
uses: actions/upload-artifact@v2
with:
name: build
path: app/client/build/
ui-test:
needs: build
# Only run if the build step is successful
if: success()
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/client
shell: bash
strategy:
fail-fast: false
matrix:
job: [0, 1, 2, 3, 4, 5, 6]
# Service containers to run with this job. Required for running tests
services:
# Label used to access the service container
redis:
# Docker Hub image for Redis
image: redis
ports:
# Opens tcp port 6379 on the host and service container
- 6379:6379
mongo:
image: mongo
ports:
- 27017:27017
steps:
# Checkout the code
- name: Checkout the merged commit from PR and base branch
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v2
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- name: Checkout the head commit of the branch
if: ${{ github.event_name == 'push' }}
uses: actions/checkout@v2
- name: Use Node.js 10.16.3
uses: actions/setup-node@v1
with:
node-version: "10.16.3"
# Retrieve npm dependencies from cache. After a successful run, these dependencies are cached again
- name: Cache npm dependencies
uses: actions/cache@v2
env:
cache-name: cache-yarn-dependencies
with:
# Node dependencies are stored in `./node_modules` on Linux/macOS
path: |
'**/node_modules'
'~/.npm'
key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
# Install all the dependencies
- name: Install dependencies
run: yarn install
- name: Download the react build artifact
uses: actions/download-artifact@v2
with:
name: build
path: app/client/build
- name: Pull release server docker container and start it locally
if: github.ref == 'refs/heads/release'
shell: bash
run: |
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
docker run -d --net=host --name appsmith-internal-server -p 8080:8080 \
--env APPSMITH_MONGODB_URI=mongodb://localhost:27017/appsmith \
--env APPSMITH_REDIS_URL=redis://localhost:6379 \
--env APPSMITH_ENCRYPTION_PASSWORD=password \
--env APPSMITH_ENCRYPTION_SALT=salt \
--env APPSMITH_IS_SELF_HOSTED=false \
appsmith/appsmith-server:release
- name: Pull master server docker container and start it locally
if: github.ref == 'refs/heads/master'
shell: bash
run: |
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
docker run -d --net=host --name appsmith-internal-server -p 8080:8080 \
--env APPSMITH_MONGODB_URI=mongodb://localhost:27017/appsmith \
--env APPSMITH_REDIS_URL=redis://localhost:6379 \
--env APPSMITH_ENCRYPTION_PASSWORD=password \
--env APPSMITH_ENCRYPTION_SALT=salt \
--env APPSMITH_IS_SELF_HOSTED=false \
appsmith/appsmith-server:nightly
- name: Installing Yarn serve
run: |
yarn global add serve
echo "$(yarn global bin)" >> $GITHUB_PATH
- name: Setting up the cypress tests
shell: bash
env:
APPSMITH_SSL_CERTIFICATE: ${{ secrets.APPSMITH_SSL_CERTIFICATE }}
APPSMITH_SSL_KEY: ${{ secrets.APPSMITH_SSL_KEY }}
CYPRESS_URL: ${{ secrets.CYPRESS_URL }}
CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
CYPRESS_TESTUSERNAME1: ${{ secrets.CYPRESS_TESTUSERNAME1 }}
CYPRESS_TESTPASSWORD1: ${{ secrets.CYPRESS_TESTPASSWORD1 }}
CYPRESS_TESTUSERNAME2: ${{ secrets.CYPRESS_TESTUSERNAME2 }}
CYPRESS_TESTPASSWORD2: ${{ secrets.CYPRESS_TESTPASSWORD1 }}
APPSMITH_DISABLE_TELEMETRY: true
APPSMITH_GOOGLE_MAPS_API_KEY: ${{ secrets.APPSMITH_GOOGLE_MAPS_API_KEY }}
POSTGRES_PASSWORD: postgres
run: |
./cypress/setup-test.sh
- name: Run the cypress test
uses: cypress-io/github-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
CYPRESS_TESTUSERNAME1: ${{ secrets.CYPRESS_TESTUSERNAME1 }}
CYPRESS_TESTPASSWORD1: ${{ secrets.CYPRESS_TESTPASSWORD1 }}
CYPRESS_TESTUSERNAME2: ${{ secrets.CYPRESS_TESTUSERNAME2 }}
CYPRESS_TESTPASSWORD2: ${{ secrets.CYPRESS_TESTPASSWORD1 }}
APPSMITH_DISABLE_TELEMETRY: true
APPSMITH_GOOGLE_MAPS_API_KEY: ${{ secrets.APPSMITH_GOOGLE_MAPS_API_KEY }}
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
with:
browser: chrome
headless: true
record: true
install: false
parallel: true
group: "Electrons on Github Action"
spec: "cypress/integration/Smoke_TestSuite/*/*"
working-directory: app/client
# tag will be either "push" or "pull_request_target"
tag: ${{ github.event_name }}
env: "NODE_ENV=development"
# Upload the screenshots as artifacts if there's a failure
- uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots-${{ matrix.job }}
path: app/client/cypress/screenshots/
package:
needs: ui-test
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/client
# Run this job only if all the previous steps are a success and the reference if the release or master branch
if: success() && (github.ref == 'refs/heads/release' || github.ref == 'refs/heads/master')
steps:
# Checkout the code
- name: Checkout the merged commit from PR and base branch
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v2
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
- name: Checkout the head commit of the branch
if: ${{ github.event_name == 'push' }}
uses: actions/checkout@v2
- name: Download the react build artifact
uses: actions/download-artifact@v2
with:
name: build
path: app/client/build
# Here, the GITHUB_REF is of type /refs/head/<branch_name>. We extract branch_name from this by removing the
# first 11 characters. This can be used to build images for several branches
- name: Get the version to tag the Docker image
id: branch_name
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:11})
# Build release Docker image and push to Docker Hub
- name: Push release image to Docker Hub
if: success() && github.ref == 'refs/heads/release' && github.event_name == 'push'
run: |
docker build -t appsmith/appsmith-editor:${{steps.branch_name.outputs.tag}} .
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
docker push appsmith/appsmith-editor
# Build master Docker image and push to Docker Hub
- name: Push production image to Docker Hub with commit tag
if: success() && github.ref == 'refs/heads/master' && github.event_name == 'push'
run: |
docker build -t appsmith/appsmith-editor:${GITHUB_SHA} .
docker build -t appsmith/appsmith-editor:nightly .
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
docker push appsmith/appsmith-editor