forked from serverless/serverless-google-cloudfunctions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
150 lines (134 loc) · 7.2 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
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
language: node_js
git:
# Minimize git history, but ensure to not break things:
# - Merging multiple PR's around same time may introduce a case where it's not
# the last merge commit that is to be tested
# - Aside of merge commit we need a previous commit to be able to detect a version switch
depth: 30
cache:
# Not relying on 'npm' shortcut, as per Travis docs it's the only 'node_modules' that it'll cache
directories:
- $HOME/.npm
- node_modules
branches:
only: # Do not build PR branches
# Release branches
- master
# Release tags
- /^v\d+\.\d+\.\d+$/ # Ensure to build release tags
stages:
- name: Test
if: tag IS NOT present
- name: Tag on Release
if: branch = master AND type = push
- name: Deploy
if: tag =~ ^v\d+\.\d+\.\d+$
env:
global:
- FORCE_COLOR=1 # Ensure colored output (color support is not detected in some cases)
# Ensure to install dependencies at their latest versions
install:
# Note: `npm update` has issues which we need to workaround:
# - There seems no way to update all project dependency groups in one run
# Hence different calls for prod and dev dependencies
# - The bigger depth, the longer update takes (-9999 as proposed in npm docs hangs the process).
# Therefore we keep at 3 which should ensure most of dependencies are at latest versions
# - Depth setting makes optional dependencies not optional (install error crashes process)
# Hence we skip install of optional dependencies completely, with --no-optional
# Note: this patch works only for npm@5+
# - npm documents --dev option for dev dependencies update, but it's only --save-dev that works
- npm update --depth 3 --no-optional --no-save
- npm update --depth 3 --save-dev --no-save
before_script:
# Fail build right after first script fails. Travis doesn't ensure that: https://github.com/travis-ci/travis-ci/issues/1066
# More info on below line: https://www.davidpashley.com/articles/writing-robust-shell-scripts/#idm5413512
- set -e
- git config --global user.email "[email protected]"
- git config --global user.name "Serverless CI"
jobs:
include:
# In most cases it's best to configure one job per platform & Node.js version combination
# (job boot & setup takes ca 1 minute, one task run lasts ca few seconds)
# PR's from branches
# Ensure commit messages follow CC, and confirm on changelog in case of release PR's
- name: 'Prettier check updated, Lint updated, Commitlint, Changelog confirm (on release), Unit Tests - Node.js v12'
if: type = pull_request AND fork = false
node_js: 12
script:
- npm run prettier-check:updated
- npm run lint:updated
- npm run commitlint:pull-request
# If release PR, confirm we have a changelog
- |
tagName=`git diff -U0 master package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || :
if [ -n "$tagName" ];
then
npx dump-release-notes-from-cc-changelog $tagName
fi
- npm test
# PR's from forks
# Do not validate commit messages,
# (if user didn't ensure CC, PR should be squash merged with a valid CC commit message)
- name: 'Prettier check updated, Lint updated, Unit Tests - Node.js v12'
if: type = pull_request AND fork = true
node_js: 12
script:
- npm run prettier-check:updated
- npm run lint:updated
- npm test
# master branch
- name: 'Unit Tests - Node.js v12'
if: type != pull_request
node_js: 12
- name: 'Unit Tests, Coverage - Node.js v13'
node_js: 13
script:
- npm run coverage
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
- name: 'Unit Tests - Node.js v10'
node_js: 10
- name: 'Unit Tests - Node.js v8'
node_js: 8
- stage: Tag on Release
name: 'Tag on Release'
node_js: 12
env:
# GITHUB_TOKEN
- secure: Eu4uYULeMcBVkj3AJxKTGTytCkGBDZAl5z/26Jnv1sH3hK02UQeJdE2L8gTk/TfMS/MMLInSb0YqD4S8qEz6C3zg4Q9z9/N653JaKSbpQPjjc8BsOaZlgo0rrUJWu/BwdYLou1zAhAGd4cUtyAAnIkvJW30XAnH6A73EyGY3GgRRIUGb/PxUB2cHrqalq/V/u6kuNw5Sf26SmVVdJMhj5/es+kQdI2EeykEQMO2FRXKV2GRXs5TFikW/doTENHQAK6QPWJbVX1PHF4Via9vJuLhaOo4QjH3XCpDYX5UYsR7gvOChSsY3VMjHgLkjgTyabiv0mnrhjsLkkvlVsSzmmYmMShyGbJSjnqAa+C69oGFJo9Tim5qQOEJIZ5R7A1ctS8wZSmb2YUc7YU/1/kTjQ8ccU1MgAPp4w9drdwCZXLTQ8fc1MYPo4+sDoAdJVSpS9YQ5qsenZH1lgyJ3iV+RwLjzltdRTs4FjeAOxCaEjpdhXkVZpH58wiDYm4F4OfzfvvSYPSxa2eoZVSI+YV4YEtHQrFgxWwNHgIt8rH8zETKjhlva6PCirZdWfmQg1LU/3Jly1lNw9fkTy9UzAfsLaSQM8hEbjOR6nh7AQCUqp9Fq7jH7lV/t/yGEIH5Ie/qW/uFcZpV1RLicgeGAnI+7RM55vSB9tyO8tiJcWBQZgLw=
script:
- |
tagName=`git diff -U0 HEAD^ package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || :
if [ -n "$tagName" ];
then
git tag v$tagName
git push -q https://[email protected]/serverless/serverless-google-cloudfunctions --tags
fi
# version tag
- stage: Deploy
env:
# GITHUB_TOKEN
- secure: Eu4uYULeMcBVkj3AJxKTGTytCkGBDZAl5z/26Jnv1sH3hK02UQeJdE2L8gTk/TfMS/MMLInSb0YqD4S8qEz6C3zg4Q9z9/N653JaKSbpQPjjc8BsOaZlgo0rrUJWu/BwdYLou1zAhAGd4cUtyAAnIkvJW30XAnH6A73EyGY3GgRRIUGb/PxUB2cHrqalq/V/u6kuNw5Sf26SmVVdJMhj5/es+kQdI2EeykEQMO2FRXKV2GRXs5TFikW/doTENHQAK6QPWJbVX1PHF4Via9vJuLhaOo4QjH3XCpDYX5UYsR7gvOChSsY3VMjHgLkjgTyabiv0mnrhjsLkkvlVsSzmmYmMShyGbJSjnqAa+C69oGFJo9Tim5qQOEJIZ5R7A1ctS8wZSmb2YUc7YU/1/kTjQ8ccU1MgAPp4w9drdwCZXLTQ8fc1MYPo4+sDoAdJVSpS9YQ5qsenZH1lgyJ3iV+RwLjzltdRTs4FjeAOxCaEjpdhXkVZpH58wiDYm4F4OfzfvvSYPSxa2eoZVSI+YV4YEtHQrFgxWwNHgIt8rH8zETKjhlva6PCirZdWfmQg1LU/3Jly1lNw9fkTy9UzAfsLaSQM8hEbjOR6nh7AQCUqp9Fq7jH7lV/t/yGEIH5Ie/qW/uFcZpV1RLicgeGAnI+7RM55vSB9tyO8tiJcWBQZgLw=
node_js: 12
script: skip
# Ensure to fail build if deploy fails, Travis doesn't ensure that: https://github.com/travis-ci/travis-ci/issues/921
before_deploy:
- set -e
# Remove eventual old npm logs
- rm -rf ~/.npm/_logs
after_deploy:
- |
# npm creates log only on failure
if [ -d ~/.npm/_logs ]
then
# Undocumented way to force Travis build to fail
travis_terminate 1
fi
- npx github-release-from-cc-changelog $TRAVIS_TAG
deploy:
edge: true # Workaorund Travis regression: https://travis-ci.community/t/missing-api-key-when-deploying-to-github-releases/5761
provider: npm
email: [email protected]
on:
tags: true
api_key:
secure: GxHxrCEjTIwzcHW6EEJm6/6Lwm3H+aTmOSrDHgwMwiwg98fTqQ2pD1L06CppSiaq9T33RPEim4kuBHIpTtmiJwVVQMIdEQheUfE05OwWBWcOEta2h3ahbGPX8iA48aVdRuXD4/Vpiho2a7zPuVBIsgDH1OzLO/WiYx10afzqlOOvwBITOkRy6eKD/I/Omxid6KjvMwfrHYScWvL9JTo7aV0MhFL4MV+9fN3nutF5+wSSIjfkzTmhxKmHEi/nlcuFCVS8yfutX7sMLugxNilqbv815SbjHMrkgZwkzrnalTbF3B2ohV8zYcuCrUEwDPRlrWbmoFMGJdcuXE90HPiHagn2Olv5e28f5ToQGFzwzYWrAO2Rc4l6gyUn8uwonN/xrK6N8ucEti9b/vzQz2/bH3rB+S++ZPiYAUcgZ8eLUp6TXkFoxanRuH/k2I8kfBj3bQrfvJofbaQKcrsGPFmR+AEsxDiZ2fCQfZHuZS4t8JD5VtDXacTSbbZzqwiKHF0sdJIIzE8EXQ7OejK8UQ2nSUZMlVUzvwuAnhPgjOC9QCNpQwprSX2Hn5d8lvcxI+TDj7XWYxqbhIlRHxPLghKTMicIH/luwy3OpCP4769Hjmy4e2M6kjyUKjhrV7BvrBVZSVPSP0vuh3oZCPGZSRXl3JfelQGXrUNufxomZu/gLZM=