Skip to content
This repository was archived by the owner on Dec 4, 2022. It is now read-only.

Commit 41959a3

Browse files
committed
first circle configuration
1 parent 43a0bed commit 41959a3

File tree

2 files changed

+260
-0
lines changed

2 files changed

+260
-0
lines changed

.circleci/config.yml

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
default_image: &default_image
2+
docker:
3+
- image: circleci/node:8.12.0
4+
5+
default_resource_class: &default_resource_class
6+
resource_class: small
7+
8+
default_working_dir: &default_working_dir
9+
working_directory: ~/bit-javascript
10+
11+
defaults: &defaults
12+
<<: *default_image
13+
<<: *default_resource_class
14+
<<: *default_working_dir
15+
16+
semver_tags_only_filters: &semver_tags_only_filters
17+
filters:
18+
# ignore any commit on any branch by default
19+
branches:
20+
ignore: /.*/
21+
# only act on version tags
22+
tags:
23+
only: /^v[0-9]+(\.[0-9]+)*$/
24+
25+
version: 2
26+
jobs:
27+
checkout_code:
28+
<<: *defaults
29+
steps:
30+
- checkout
31+
-
32+
persist_to_workspace:
33+
root: /home/circleci
34+
paths:
35+
- bit-javascript
36+
install_npm_deps:
37+
<<: *defaults
38+
steps:
39+
-
40+
attach_workspace:
41+
at: ./
42+
-
43+
run:
44+
name: 'save SHA to a file'
45+
command: 'echo $CIRCLE_SHA1 > .circle-sha'
46+
-
47+
run:
48+
name: 'Install npm dependencies'
49+
command: 'cd bit-javascript && npm install'
50+
-
51+
persist_to_workspace:
52+
root: .
53+
paths:
54+
- bit-javascript/node_modules
55+
validate-git-tag-and-version:
56+
<<: *defaults
57+
steps:
58+
-
59+
attach_workspace:
60+
at: ./
61+
- run:
62+
name: Setup bit version environment variables
63+
command: cd bit && echo "export BIT_JS_VERSION=$(cat ./package.json | jq .version -r)" >> $BASH_ENV && source $BASH_ENV
64+
-
65+
run:
66+
name: 'installing semver tool'
67+
command: 'sudo npm i -g semver'
68+
-
69+
run:
70+
name: 'validate version in package.json does not contains pre release tags'
71+
# This will return code 1 when the version contains pre release tags
72+
command: 'semver $BIT_JS_VERSION -r x.x.x'
73+
-
74+
run:
75+
name: 'validate tag match version in package.json'
76+
command: 'cd bit && ./scripts/compare-versions.sh $CIRCLE_TAG v$BIT_JS_VERSION'
77+
npm-publish:
78+
<<: *defaults
79+
steps:
80+
-
81+
attach_workspace:
82+
at: ./
83+
- run:
84+
name: Authenticate with registry
85+
command: echo "//registry.npmjs.org/:_authToken=$npmToken" > ~/.npmrc
86+
-
87+
run:
88+
name: Publish bit to the npm registry
89+
command: 'cd bit && npm publish'
90+
github-release:
91+
<<: *defaults
92+
steps:
93+
-
94+
attach_workspace:
95+
at: ./
96+
# - run:
97+
# name: set GitHub token
98+
# command: export GH_RELEASE_GITHUB_API_TOKEN=$ghToken
99+
-
100+
run: 'cd bit && npm run release:circle'
101+
build:
102+
<<: *defaults
103+
steps:
104+
-
105+
run:
106+
name: 'save SHA to a file'
107+
command: 'echo $CIRCLE_SHA1 > .circle-sha'
108+
-
109+
attach_workspace:
110+
at: ./
111+
-
112+
run:
113+
name: 'Build bit javascript source code'
114+
command: 'cd bit-javascript && npm run build'
115+
-
116+
persist_to_workspace:
117+
root: .
118+
paths:
119+
- bit-javascript/dist
120+
unit_test:
121+
<<: *defaults
122+
steps:
123+
-
124+
run:
125+
name: 'save SHA to a file'
126+
command: 'echo $CIRCLE_SHA1 > .circle-sha'
127+
-
128+
attach_workspace:
129+
at: ./
130+
-
131+
run: 'cd bit-javascript && mkdir junit'
132+
-
133+
run:
134+
name: 'Run unit tests'
135+
command: 'cd bit-javascript && npm run test-circle'
136+
environment:
137+
MOCHA_FILE: junit/unit-test-results.xml
138+
when: always
139+
-
140+
store_test_results:
141+
path: bit-javascript/junit
142+
-
143+
store_artifacts:
144+
path: bit-javascript/junit
145+
lint:
146+
<<: *defaults
147+
resource_class: medium
148+
steps:
149+
-
150+
run:
151+
name: 'save SHA to a file'
152+
command: 'echo $CIRCLE_SHA1 > .circle-sha'
153+
-
154+
restore_cache:
155+
keys:
156+
- 'repo-{{ checksum ".circle-sha" }}'
157+
-
158+
attach_workspace:
159+
at: ./
160+
-
161+
run:
162+
name: 'run ESLint'
163+
command: 'cd bit-javascript && npm run lint-circle'
164+
-
165+
store_test_results:
166+
path: bit-javascript/junit
167+
-
168+
store_artifacts:
169+
path: bit-javascript/junit
170+
check_types:
171+
<<: *defaults
172+
resource_class: medium
173+
steps:
174+
-
175+
run:
176+
name: 'save SHA to a file'
177+
command: 'echo $CIRCLE_SHA1 > .circle-sha'
178+
-
179+
restore_cache:
180+
keys:
181+
- 'repo-{{ checksum ".circle-sha" }}'
182+
-
183+
attach_workspace:
184+
at: ./
185+
-
186+
run:
187+
name: 'run TSC'
188+
command: 'cd bit-javascript && npm run check-types'
189+
-
190+
store_test_results:
191+
path: bit-javascript/junit
192+
-
193+
store_artifacts:
194+
path: bit-javascript/junit
195+
workflows:
196+
version: 2
197+
build_and_test:
198+
jobs:
199+
- checkout_code
200+
-
201+
install_npm_deps:
202+
requires:
203+
- checkout_code
204+
-
205+
build:
206+
requires:
207+
- install_npm_deps
208+
-
209+
unit_test:
210+
requires:
211+
- build
212+
-
213+
-
214+
lint:
215+
requires:
216+
- install_npm_deps
217+
-
218+
check_types:
219+
requires:
220+
- install_npm_deps
221+
deploy:
222+
jobs:
223+
- checkout_code:
224+
<<: *semver_tags_only_filters
225+
-
226+
validate-git-tag-and-version:
227+
<<: *semver_tags_only_filters
228+
requires:
229+
- checkout_code
230+
-
231+
install_npm_deps:
232+
<<: *semver_tags_only_filters
233+
requires:
234+
- validate-git-tag-and-version
235+
- checkout_code
236+
-
237+
build:
238+
<<: *semver_tags_only_filters
239+
requires:
240+
- install_npm_deps
241+
-
242+
npm-publish:
243+
<<: *semver_tags_only_filters
244+
requires:
245+
- build
246+
-
247+
github-release:
248+
<<: *semver_tags_only_filters
249+
requires:
250+
- pack

scripts/compare-versions.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
echo "compare $1 to $2"
4+
if [ $1 == $2 ]; then
5+
echo "Versions match"
6+
exit 0;
7+
else
8+
echo "Versions not match"
9+
exit 1;
10+
fi

0 commit comments

Comments
 (0)