-
Notifications
You must be signed in to change notification settings - Fork 2
177 lines (143 loc) · 4.28 KB
/
cicd.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
167
168
169
170
171
172
173
174
175
176
177
name: CI/CD
on:
push:
branches: [ master, next ]
pull_request:
branches: [ master, next ]
jobs:
lint:
name: Code Quality
runs-on: ubuntu-latest
env:
node-version: 16.x
steps:
- name: git checkout HEAD
uses: actions/checkout@v2
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci --prefer-offline --no-fund --no-audit
- name: Lint
run: npm run lint
lint-scripts:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- name: git checkout HEAD
uses: actions/checkout@v2
- name: Install ShellCheck
run: sudo apt update && sudo apt install shellcheck
- name: simulate husky install
# husky does not install when in CI env
# but file is needed so shellcheck does not throw errors for missing file
run: mkdir -p .husky/_ && touch .husky/_/husky.sh
- name: Shellcheck
run: shellcheck -x
.devcontainer/*.sh
.husky/commit-msg
.husky/hook-utils.sh
.husky/post-checkout
.husky/post-merge
.husky/post-rewrite
.husky/pre-commit
.husky/pre-push
.husky/prepare-commit-msg
# - name: shell format
# run: shfmt
lint-commits:
name: Semantic commits
runs-on: ubuntu-latest
env:
node-version: 16.x
steps:
- name: git checkout HEAD
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci --prefer-offline --no-fund --no-audit
- name: Commits lint check
if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
env:
BASE_COMMIT_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
NEWEST_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.event.after }}
run: npx commitlint --verbose
--from "$BASE_COMMIT_SHA"
--to "$NEWEST_COMMIT_SHA"
build:
name: Build
runs-on: ubuntu-latest
env:
node-version: 16.x
steps:
- name: git checkout HEAD
uses: actions/checkout@v2
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci --prefer-offline --no-fund --no-audit
- name: Run build
run: npm run build --if-present
- name: Run unit-tests
run: npm run test:unit
- name: Upload bundle
uses: actions/upload-artifact@v2.2.4
with:
name: dist-bundle
path: dist/*
if-no-files-found: error
retention-days: 1
integration:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
steps:
- name: git checkout HEAD
uses: actions/checkout@v2
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.node-version }}
cache: 'npm'
- name: Download bundle
uses: actions/download-artifact@v2
with:
name: dist-bundle
path: dist/
- name: Install dependencies
run: npm ci --prefer-offline --no-fund --no-audit
- name: Run plugin tests
run: npm run test:plugin
release:
needs:
- lint
- lint-commits
- integration
runs-on: ubuntu-latest
steps:
- name: git checkout HEAD
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
cache: 'npm'
- name: Install dependencies
run: npm ci --prefer-offline --no-fund --no-audit
- name: Run semantic-release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}