forked from zino-hofmann/graphql-flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yml
270 lines (259 loc) · 8.2 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
version: 2.1
aliases:
- &flutter_environment
- image: cirrusci/flutter:latest-web
- &node_environment
- image: circleci/node:10
- &restore_cache
keys:
# when lock file changes, use increasingly general patterns to restore cache
- pub-packages-v1-{{ checksum "packages/graphql/pubspec.yaml" }}-{{ checksum "packages/graphql_flutter/pubspec.yaml" }}
- pub-packages-v1-{{ checksum "packages/graphql/pubspec.yaml" }}
- pub-packages-v1-
- &install_yaml_processor
name: Install yq yaml processor
command: |
sudo apt update && \
sudo apt install -y wget
wget https://github.com/mikefarah/yq/releases/download/2.4.0/yq_linux_amd64 -O ~/yq
sudo chmod +x ~/yq
sudo apt remove -y wget
- &graphql_from_path
name: Switch to graphql from path
command: |
cd packages/graphql_flutter
~/yq w pubspec.yaml dependencies.graphql.path "../graphql" > patched_pubspec.yaml
rm pubspec.yaml
mv patched_pubspec.yaml pubspec.yaml
- &setup_github_bot
name: Setup Github bot
command: |
git config credential.helper 'cache --timeout=120'
git config user.email "[email protected]"
git config user.name "Zino App (Github bot)"
- &setup_pub_credentials
name: Setup pub credentials
command: |
[[ ! -d ~/.pub-cache ]] && mkdir -p ~/.pub-cache
cat \<<EOF > ~/.pub-cache/credentials.json
{
"accessToken": ${PUB_ACCESS_TOKEN},
"refreshToken": ${PUB_REFRESH_TOKEN},
"tokenEndpoint": "https://accounts.google.com/o/oauth2/token",
"scopes": ["https://www.googleapis.com/auth/userinfo.email", "openid"],
"expiration": ${PUB_EXPIRATION}
}
EOF
jobs:
dependencies:
docker: *flutter_environment
steps:
- checkout
- restore_cache: *restore_cache
- run: *install_yaml_processor
- run: *graphql_from_path
- run:
name: Install dependencies (graphql)
command: |
cd packages/graphql
pub get
- run:
name: Install dependencies (graphql_flutter)
command: |
cd packages/graphql_flutter
flutter packages get
- save_cache:
key: pub-packages-v1-{{ checksum "packages/graphql/pubspec.yaml" }}-{{ checksum "packages/graphql_flutter/pubspec.yaml" }}
paths:
- ~/.pub-cache
lint:
docker: *flutter_environment
steps:
- checkout
- restore_cache: *restore_cache
- run: *install_yaml_processor
- run: *graphql_from_path
- run:
name: Code formating and analyzing (graphql)
command: |
cd packages/graphql
dartfmt **/*.dart -n --set-exit-if-changed
flutter analyze
- run:
name: Code formating and analyzing (graphql_flutter)
command: |
cd packages/graphql_flutter
dartfmt **/*.dart -n --set-exit-if-changed
flutter analyze
coverage:
docker: *flutter_environment
steps:
- checkout
- restore_cache: *restore_cache
- run: *install_yaml_processor
- run: *graphql_from_path
- run:
name: Code coverage (graphql, vm only)
command: |
cd packages/graphql
pub global activate coverage
pub get
pub run test_coverage
dart --enable_asserts --enable-vm-service test/.test_coverage.dart
- run:
name: Code coverage (graphql_flutter)
command: |
cd packages/graphql_flutter
flutter test --coverage
- run:
name: Upload coverage
command: |
bash <(curl -s https://codecov.io/bash) -F graphql_flutter
bash <(curl -s https://codecov.io/bash) -F graphql_flutter -B `git rev-parse --abbrev-ref HEAD`_pseudo_branch_package_graphql_flutter
bash <(curl -s https://codecov.io/bash) -F graphql_client
bash <(curl -s https://codecov.io/bash) -F graphql_client -B `git rev-parse --abbrev-ref HEAD`_pseudo_branch_package_graphql_client
release:
docker: *node_environment
steps:
- checkout
- run:
name: Generate release tags
command: npx -p @semantic-release/changelog -p @semantic-release/[email protected] -p [email protected] semantic-release
sync_with_beta:
docker: *node_environment
steps:
- checkout
- run: *setup_github_bot
- run:
name: Sync master into beta
command: |
git checkout master
git pull
git checkout beta
git merge master --no-commit
git commit --allow-empty -m "ci(Semantic release): Sync master into beta [skip ci]"
# Push quietly to prevent showing the token in log
git push -q https://${GH_TOKEN}@github.com/zino-app/graphql-flutter.git beta
publish:
docker: *flutter_environment
steps:
- checkout
- restore_cache: *restore_cache
- run: *install_yaml_processor
- run: *setup_github_bot
- run: *setup_pub_credentials
- run:
name: Patch pubspec with version (graphql)
command: |
cd packages/graphql
VERSION=${CIRCLE_TAG}
VERSION=${VERSION#"v"}
# patch version
~/yq w pubspec.yaml version $VERSION > patched_pubspec.yaml
rm pubspec.yaml
mv patched_pubspec.yaml pubspec.yaml
- run:
name: Patch pubspec with version (graphql_flutter)
command: |
cd packages/graphql_flutter
VERSION=${CIRCLE_TAG}
VERSION=${VERSION#"v"}
# patch version
~/yq w pubspec.yaml version $VERSION > patched_pubspec.yaml
rm pubspec.yaml
mv patched_pubspec.yaml pubspec.yaml
# patch graphql dependency version
~/yq w pubspec.yaml dependencies.graphql ^$VERSION > patched_pubspec.yaml
rm pubspec.yaml
mv patched_pubspec.yaml pubspec.yaml
- run:
name: Bump version numbers
command: |
if [[ $CIRCLE_TAG =~ ^.*beta.*$ ]]; then BRANCH=beta; else BRANCH=master; fi
git checkout $BRANCH
git add packages/graphql/pubspec.yaml packages/graphql_flutter/pubspec.yaml
git commit --allow-empty -m "build(Pub): Bump version numbers [skip ci]"
# Push quietly to prevent showing the token in log
git push -q https://${GH_TOKEN}@github.com/zino-app/graphql-flutter.git $BRANCH
- run:
name: Pub deployment (graphql)
command: |
cd packages/graphql
pub publish -f
- run:
name: Pub deployment (graphql_flutter)
command: |
cd packages/graphql_flutter
pub publish -f
workflows:
nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- beta
jobs:
- dependencies
- lint:
requires:
- dependencies
- coverage:
requires:
- dependencies
- release:
requires:
- dependencies
- lint
- coverage
weekly:
triggers:
- schedule:
cron: "0 21 * * 1"
filters:
branches:
only:
- master
jobs:
- dependencies
- lint:
requires:
- dependencies
- coverage:
requires:
- dependencies
- release:
requires:
- dependencies
- lint
- coverage
- sync_with_beta:
requires:
- release
default:
jobs:
- dependencies:
filters:
tags:
only: /^.*$/
- lint:
requires:
- dependencies
filters:
tags:
ignore: /^.*$/
- coverage:
requires:
- dependencies
filters:
tags:
ignore: /^.*$/
- publish:
requires:
- dependencies
filters:
tags:
only: /^.*$/
branches:
ignore: /.*/