-
Notifications
You must be signed in to change notification settings - Fork 38
/
config.yml
190 lines (179 loc) · 5.85 KB
/
config.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
178
179
180
181
182
183
184
185
186
187
188
189
190
version: 2.1
orbs:
aws-s3: circleci/aws-s3@1.0.16
codecov: codecov/codecov@1.1.1
executors:
default:
docker:
- image: cimg/go:1.17.6
commands:
install-node-npm:
description: Install Node.js and npm
steps:
- run:
name: "Install Node.js and npm"
command: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
echo 'export NVM_DIR=$HOME/.nvm' >> $BASH_ENV
echo 'source $NVM_DIR/nvm.sh' >> $BASH_ENV
nvm install 16.9.1
- run:
name: Check current version of node
command: node -v
- run:
name: Check current version of NPM
command: npm -v
npm-dependencies:
description: "Get JavaScript dependencies"
steps:
- restore_cache:
name: Restore npm cache
key: v2-npm-{{ checksum "./webapp/package-lock.json" }}-{{ arch }}
- run:
name: Getting JavaScript dependencies
command: |
cd webapp
NODE_ENV=development npm install --ignore-scripts --no-save
- save_cache:
name: Save npm cache
key: v2-npm-{{ checksum "./webapp/package-lock.json" }}-{{ arch }}
paths:
- ./webapp/node_modules
install-golangci-lint:
description: Install golangci-lint
parameters:
version:
type: string
default: 1.42.1
gobin:
type: string
default: /home/circleci/go/bin
prefix:
type: string
default: v1
description: Prefix for cache key to store the binary.
steps:
- restore_cache:
name: Restore golangci-lint cache
keys: [ '<< parameters.prefix >>-golangci-lint-{{ arch }}-<< parameters.version >>' ]
- run:
name: Install golangci-lint
command: |
mkdir -p << parameters.gobin >>
command -v << parameters.gobin >>/golangci-lint && exit
download=https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh
wget -O- -q $download | sh -s -- -b << parameters.gobin >>/ v<< parameters.version >>
- save_cache:
name: Save golangci-lint cache
key: '<< parameters.prefix >>-golangci-lint-{{ arch }}-<< parameters.version >>'
paths: [ << parameters.gobin >>/golangci-lint ]
aliases:
- &restore_cache
restore_cache:
key: go-mod-v1-{{ checksum "go.sum" }}
- &save_cache
save_cache:
key: go-mod-v1-{{ checksum "go.sum" }}
paths:
- "/home/circleci/go/pkg/mod"
jobs:
lint:
executor:
name: default
steps:
- checkout
- install-golangci-lint
- *restore_cache
- install-node-npm
- npm-dependencies
- run:
name: Checking code style
command: make check-style
- run: go mod tidy -v
- run:
name: Checking diff of go mod files
command: |
git --no-pager diff --exit-code go.mod go.sum || (echo "Please run \"go mod tidy\" and commit the changes in go.mod and go.sum." && exit 1)
- run: make apply
- run:
name: Checking diff of generated manifest files
command: |
git --no-pager diff --exit-code *manifest.* || (echo "Please run \"make apply\" and commit the changes in the generated manifests." && exit 1)
- run: make i18n-extract
- run:
name: Checking diff of i18n files
command: |
git --no-pager diff --exit-code webapp/i18n/en.json || (echo "Please run \"make i18n-extract\" and commit the changes in en.json." && exit 1)
- *save_cache
test:
executor:
name: default
steps:
- checkout
- *restore_cache
- install-node-npm
- npm-dependencies
- run: make test
- *save_cache
build:
executor:
name: default
steps:
- checkout
- install-node-npm
- npm-dependencies
- run:
name: Building Plugin Bundle
command: make dist-ci
- run:
name: Generating Release Notes
command: |
printf "Supported Mattermost Server Versions: **$(cat plugin.json | jq .min_server_version -r)+** \n## Commits\n" >> dist/release-notes.md
if [[ $(git tag -l | wc -l) -eq 1 ]]; then
git log --pretty='format:- %h %s' --abbrev-commit --no-decorate --no-color $(git rev-list --max-parents=0 HEAD) HEAD >> dist/release-notes.md
else
git log --pretty='format:- %h %s' --abbrev-commit --no-decorate --no-color $(git describe --tags --abbrev=0 $(git describe --tags --abbrev=0)^)..HEAD >> dist/release-notes.md
fi
- persist_to_workspace:
root: dist
paths:
- "*.tar.gz"
- "release-notes.md"
- store_artifacts:
path: dist
deploy-release-github:
docker:
- image: cibuilds/github:0.13
steps:
- attach_workspace:
at: dist
- run:
name: "Publish Release on Github"
command: |
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -b "$(< ./dist/release-notes.md)" -c ${CIRCLE_SHA1} -n ${CIRCLE_TAG} -delete ${CIRCLE_TAG} dist/*.tar.gz
workflows:
version: 2
ci:
jobs:
- lint
- test
- build:
context: mattermost-plugin-calls-production
filters:
tags:
only: /^v.*/
- deploy-release-github:
context: matterbuild-github-token
filters:
# ignore any commit on any branch by default
branches:
ignore: /.*/
# only act on version tags
tags:
only: /^v.*/
requires:
- lint
- test
- build