-
-
Notifications
You must be signed in to change notification settings - Fork 407
/
.travis.yml
109 lines (106 loc) · 4.14 KB
/
.travis.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
###############################################################################################################
# DEPRECATED
# Previously we used travis-ci for all builds, but now use circlci
# Code is retained mostly for reference and will likely need updates in needed again in future
###############################################################################################################
language: node_js
node_js:
- "12"
dist: xenial
cache:
# cache yarn cache and cypress binary
yarn: true
directories:
- ./.yarn/cache
- ~/.cache
addons:
chrome: stable
firefox: latest
apt:
packages:
# Required for cypress parallel tests
- libgconf-2-4
branches:
only:
- master
- production
env:
# cy - use firefox in headless mode for CI
- global:
- DEBUG=True
- MOZ_HEADLESS=1
install:
# fix ENOSPC: System limit for number of file wathcers reached bug
- echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- yarn install --immutable
# add the current github branch as an environment variable
before_script:
- echo "MATRIX=$MATRIX_VAR"
- export REACT_APP_BRANCH=$TRAVIS_BRANCH
- echo "REACT_APP_BRANCH=$REACT_APP_BRANCH"
- export CI_BUILD_ID=$TRAVIS_BUILD_ID
- echo "CI_BUILD_ID=$CI_BUILD_ID"
###############################################################################################################
# E2E Tests (cypress)
###############################################################################################################
# create common test script to be triggered by test jobs
# see https://docs.travis-ci.com/user/build-matrix/#job-uniqueness-and-duplicate-jobs
# and https://medium.com/@tommyvn/travis-yml-dry-with-anchors-8b6a3ac1b027
_test_defaults: &_test_defaults
if: (branch = master OR branch = production) AND type = push
# Skip tests on PRs (currently handled by circleci)
script:
- echo "group=$CI_GROUP browser=$CI_BROWSER"
- export TZ=UTC
# A bit ugly to look into, but this starts the platform server with ci environment variables,
# waits until it's fully responsive, and then executes cypress tests for a given browser and parallel node
# see https://docs.cypress.io/guides/guides/parallelization.html
- npm run test ci
# to kill all background jobs (like "npm start &")
- kill $(jobs -p) || true
# Create common predeploy steps which can be included as part of other deploy scripts (data not persisted between jobs otherwise)
_predeploy_defaults: &_predeploy_defaults
- npm run build
- npm install -g firebase-tools
- export FIREBASE_TOKEN=$(if [ "$TRAVIS_BRANCH" == "production" ]; then echo "$FIREBASE_PRODUCTION_TOKEN"; else echo "$FIREBASE_STAGING_TOKEN"; fi)
# Jobs run in parallel, so split chrome and firefox tests running each across 2 machines.
# CI_NODE var just ensures job env unique (otherwise won't run), others are passed to default script
jobs:
include:
# Test - Run 4 test stages in parallel
# TODO - possibly create a single build before test and use for tests and deploy
# (might be tricky: https://docs.travis-ci.com/user/build-stages/#data-persistence-between-stages-and-jobs)
- stage: Test
env:
- CI_GROUP=2x-chrome
- CI_BROWSER=chrome
- CI_NODE=0
<<: *_test_defaults
- env:
- CI_GROUP=2x-chrome
- CI_BROWSER=chrome
- CI_NODE=1
<<: *_test_defaults
- env:
- CI_GROUP=2x-firefox
- CI_BROWSER=firefox
- CI_NODE=0
<<: *_test_defaults
- env:
- CI_GROUP=2x-firefox
- CI_BROWSER=firefox
- CI_NODE=1
<<: *_test_defaults
# Note, Travis jobs combined with regular stage scripts below
# Deploy - Firebase deployment to dev/prod depending on branch on push (not PR)
- stage: Deploy Dev
if: branch = master AND type = push
script:
# Note - syntax different from above as merging into array instead of creating key:value
- *_predeploy_defaults
- bash scripts/deploy.dev.sh
- stage: Deploy Production
if: branch = production AND type = push
script:
- *_predeploy_defaults
- bash scripts/deploy.prod.sh