-
Notifications
You must be signed in to change notification settings - Fork 9
/
orb.yml
193 lines (179 loc) · 5.96 KB
/
orb.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
191
192
193
version: 2.1
description: |
Stuff to do CI for mattermost plugins.
Note that if an `.nvmrc` file is present in the plugin project's root directory, this file will be used to determine what version of node to install for CI.
orbs:
aws-s3: circleci/aws-s3@1.0.16
codecov: codecov/codecov@1.1.1
executors:
default:
docker:
- image: cimg/go:1.19
commands:
deploy:
parameters:
bucket:
type: string
filename:
type: string
steps:
- aws-s3/copy:
from: << parameters.filename >>
to: << parameters.bucket >>
arguments: '--acl public-read --cache-control no-cache'
install-node:
description: Install node
steps:
- run:
name: Install Node
command: |
set +e
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install || nvm install 13.14 # use `.nvmrc` if it exists, otherwise use 13.14
nvm alias default $(node --version)
echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
install-golangci-lint:
description: Install golangci-lint
parameters:
version:
type: string
default: 1.49.0
gobin:
type: string
default: $GOPATH/bin
prefix:
type: string
default: v2
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-v2-{{ checksum "go.sum" }}
- &save_cache
save_cache:
key: go-mod-v2-{{ checksum "go.sum" }}
paths:
- "$GOPATH/pkg/mod"
jobs:
lint:
executor:
name: default
resource_class: xlarge
steps:
- checkout
- install-golangci-lint
- install-node
- *restore_cache
- 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)
- *save_cache
test:
executor:
name: default
steps:
- checkout
- install-node
- *restore_cache
- run: make test
- *save_cache
coverage:
executor:
name: default
steps:
- checkout
- install-node
- *restore_cache
- run:
name: Generating Coverage Results
command: make coverage
- *save_cache
- codecov/upload:
file: server/coverage.txt
build:
executor:
name: default
steps:
- checkout
- install-node
- run:
name: Building Plugin Bundle
command: make dist
- run:
name: Generating Release Notes
command: |
printf "Supported Mattermost Server Versions: **$(cat plugin.json | jq .min_server_version -r)+** \n## Enhancements\n\n## Fixes\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-ci:
docker:
- image: cimg/python:2.7
steps:
- attach_workspace:
at: dist
- run: 'mv dist/*.tar.gz dist/$CIRCLE_PROJECT_REPONAME-ci.tar.gz'
- deploy:
filename: "dist/*.tar.gz"
bucket: "s3://mattermost-plugins-ci/ci/"
deploy-release:
docker:
- image: cimg/python:2.7
steps:
- attach_workspace:
at: dist
- run: 'mv dist/*.tar.gz dist/$CIRCLE_PROJECT_REPONAME-latest.tar.gz'
- run: 'cp dist/$CIRCLE_PROJECT_REPONAME-latest.tar.gz dist/$CIRCLE_PROJECT_REPONAME-$CIRCLE_TAG.tar.gz'
- deploy:
filename: "dist/$CIRCLE_PROJECT_REPONAME-latest.tar.gz"
bucket: "s3://mattermost-plugins-ci/release/"
- deploy:
filename: "dist/$CIRCLE_PROJECT_REPONAME-$CIRCLE_TAG.tar.gz"
bucket: "s3://mattermost-plugins-ci/release/"
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