-
Notifications
You must be signed in to change notification settings - Fork 34
157 lines (143 loc) · 5.98 KB
/
integrate.yml
File metadata and controls
157 lines (143 loc) · 5.98 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
# master only
name: Integrate
on:
push:
branches: [master]
env:
FORCE_COLOR: 1
jobs:
validate:
name: Validate
runs-on: ubuntu-latest
env:
SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}
steps:
- name: Resolve last validated commit hash (for `git diff` purposes)
env:
# See https://github.com/serverlessinc/setup-cicd-resources
GET_LAST_VALIDATED_COMMIT_HASH_URL: ${{ secrets.GET_LAST_VALIDATED_COMMIT_HASH_URL }}
PUT_LAST_VALIDATED_COMMIT_HASH_URL: ${{ secrets.PUT_LAST_VALIDATED_COMMIT_HASH_URL }}
run: |
curl -f "$GET_LAST_VALIDATED_COMMIT_HASH_URL" -o /home/runner/last-validated-commit-hash || :
curl -v -X PUT -H "User-Agent:" -H "Accept:" -H "Content-Type:" -d "$GITHUB_SHA" "$PUT_LAST_VALIDATED_COMMIT_HASH_URL"
- name: Store last validated commit hash (as it's to be used in other job)
uses: actions/upload-artifact@v2
with:
name: last-validated-commit-hash
path: /home/runner/last-validated-commit-hash
- name: Checkout repository
uses: actions/checkout@v2
- name: Retrieve ~/.npm from cache
uses: actions/cache@v1
with:
path: ~/.npm
key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('**package*.json') }}
restore-keys: npm-v14-${{ runner.os }}-${{ github.ref }}-
- name: Retrieve node_modules from cache
id: cacheNodeModules
uses: actions/cache@v1
with:
path: node_modules
key: node-modules-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }}
restore-keys: node-modules-v14-${{ runner.os }}-${{ github.ref }}-
- name: Retrieve src/node_modules from cache
id: cacheSrcNodeModules
uses: actions/cache@v1
with:
path: src/node_modules
key: src/node-modules-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('src/package*.json') }}
restore-keys: src/node-modules-v14-${{ runner.os }}-${{ github.ref }}-
- name: Retrieve src/_express/node_modules from cache
id: cacheSrcExpressNodeModules
uses: actions/cache@v1
with:
path: src/_express/node_modules
key: src/_express/node-modules-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('src/_express/package*.json') }}
restore-keys: src/_express/node-modules-v14-${{ runner.os }}-${{ github.ref }}-
- name: Retrieve src/_src/node_modules from cache
id: cacheSrcSrcNodeModules
uses: actions/cache@v1
with:
path: src/_src/node_modules
key: src/_src/node-modules-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('src/_src/package*.json') }}
restore-keys: src/_src/node-modules-v14-${{ runner.os }}-${{ github.ref }}-
- name: Retrieve test/src/node_modules from cache
id: cacheTestSrcNodeModules
uses: actions/cache@v1
with:
path: test/src/node_modules
key: test/src/node-modules-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('test/src/package.json') }}
restore-keys: test/src/node-modules-v14-${{ runner.os }}-${{ github.ref }}-
- name: Install Node.js and npm
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Install root dependencies
if: steps.cacheNodeModules.outputs.cache-hit != 'true'
run: npm update --save-dev --no-save
- name: Install src dependencies
if: steps.cacheSrcNodeModules.outputs.cache-hit != 'true'
run: |
cd src
npm ci
- name: Install src/_express dependencies
if: steps.cacheSrcExpressNodeModules.outputs.cache-hit != 'true'
run: |
cd src/_express
npm ci
- name: Install src/_src dependencies
if: steps.cacheSrcSrcNodeModules.outputs.cache-hit != 'true'
run: |
cd src/_src
npm ci
- name: Install test/src dependencies
if: steps.cacheTestSrcNodeModules.outputs.cache-hit != 'true'
run: |
cd test/src
npm update --no-save
# Ensure no parallel runs
# See: https://github.community/t/how-to-limit-concurrent-workflow-runs/16844/21
- name: Turnstyle
uses: softprops/turnstyle@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish "dev" version
run: npm run publish:dev
- name: Integration tests
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: npm test
tagIfNewVersion:
name: Tag if new version
runs-on: ubuntu-latest
needs: validate
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# Ensure to have complete history of commits pushed with given push operation
# It's loose and imperfect assumption that no more than 30 commits will be pushed at once
fetch-depth: 30
# Tag needs to be pushed with real user token
# (hence we're not relying on actions secrets.GITHUB_TOKEN)
# Otherwise pushed tag won't trigger the actions workflow
token: ${{ secrets.USER_GITHUB_TOKEN }}
- name: Resolve last validated commit hash (for `git diff` purposes)
uses: actions/download-artifact@v4.1.7
continue-on-error: true
with:
name: last-validated-commit-hash
path: /home/runner
- name: Tag if new version
run: |
LAST_VALIDATED_COMMIT_HASH=`cat /home/runner/last-validated-commit-hash` || :
if [ -n "$LAST_VALIDATED_COMMIT_HASH" ];
then
NEW_VERSION=`git diff -U0 $LAST_VALIDATED_COMMIT_HASH serverless.component.yml | grep 'version: ' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || :
if [ -n "$NEW_VERSION" ];
then
git tag v$NEW_VERSION
git push --tags
fi
fi