Skip to content

Commit e44e837

Browse files
committed
Fix CI
1 parent fbf6909 commit e44e837

File tree

3 files changed

+144
-78
lines changed

3 files changed

+144
-78
lines changed

.circleci/config.yml

Lines changed: 108 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,125 @@
1-
aliases:
2-
- &update-npm
3-
name: Update npm to the latest version
4-
command: sudo npm install -g npm@latest
1+
version: 2.1
52

6-
- &save-dependencies-cache
7-
key: v1-dependency-cache-{{ checksum "package.json" }}
8-
paths:
9-
- ./node_modules
3+
executors:
4+
node:
5+
docker:
6+
- image: circleci/node:11.10.0
7+
working_directory: ~/ERC777
108

11-
- &restore-dependencies-cache
12-
keys:
13-
- v1-dependency-cache-{{ checksum "package.json" }}
14-
- v1-dependency-cache-
15-
16-
- &save-build-cache
17-
key: v1-build-cache-{{ .BuildNum }}
18-
paths:
19-
- ./artifacts
20-
21-
- &restore-build-cache
22-
keys:
23-
- v1-build-cache-{{ .BuildNum }}
24-
- v1-build-cache-
25-
- &filter-all-tags
26-
tags:
27-
only: /.*/
9+
commands:
10+
restore-dependencies:
11+
steps:
12+
- restore_cache:
13+
keys:
14+
- v1-dependency-cache-{{ checksum "package.json" }}
15+
- v1-dependency-cache-
2816

29-
defaults: &defaults
30-
docker:
31-
- image: circleci/node:10.6.0
32-
working_directory: ~/erc777
17+
restore-build:
18+
steps:
19+
- restore_cache:
20+
keys:
21+
- v1-build-cache-{{ .BuildNum }}
22+
- v1-build-cache-
3323

34-
version: 2
24+
restore-solc:
25+
steps:
26+
- run:
27+
name: Set write permissions
28+
command: sudo chmod go+w /opt
29+
- restore_cache:
30+
keys:
31+
- v1-solc-cache-{{ .BuildNum }}
32+
- v1-solc-cache-
33+
- run:
34+
name: Update $PATH
35+
command: echo 'export PATH="/opt:$PATH"' >> $BASH_ENV
3536

3637
jobs:
37-
install-dependencies:
38-
<<: *defaults
38+
install solc:
39+
executor: node
40+
steps:
41+
- run:
42+
name: Download solc
43+
command: curl -L "https://github.com/ethereum/solidity/releases/download/v0.5.3/solc-static-linux" -o /tmp/solc
44+
- run:
45+
name: Verify solc download
46+
command: echo "be08eb95cb3a1da52e918cf51a0c0397fbe7f0693145eb31835bf2924209f1e0 /tmp/solc" | sha256sum -c -
47+
- run:
48+
name: Make solc executable
49+
command: chmod +x /tmp/solc
50+
- run:
51+
name: Install solc
52+
command: sudo mv /tmp/solc /opt/solc
53+
- save_cache:
54+
key: v1-solc-cache-{{ .BuildNum }}
55+
paths:
56+
- /opt/solc
57+
- run:
58+
name: Solc version
59+
command: /opt/solc --version
60+
61+
install dependencies:
62+
executor: node
3963
steps:
40-
- run: *update-npm
4164
- checkout
4265
- run:
4366
name: Install npm dependencies with npm ci
4467
command: npm ci
45-
- save_cache: *save-dependencies-cache
68+
- save_cache:
69+
key: v1-dependency-cache-{{ checksum "package.json" }}
70+
paths:
71+
- ./node_modules
72+
4673
build:
47-
<<: *defaults
74+
executor: node
4875
steps:
49-
- run: *update-npm
5076
- checkout
51-
- restore_cache: *restore-dependencies-cache
77+
- restore-solc
78+
- restore-dependencies
5279
- run:
5380
name: Build Solidity
5481
command: npm run build
55-
- save_cache: *save-build-cache
56-
lint-solidity:
57-
<<: *defaults
82+
- save_cache:
83+
key: v1-build-cache-{{ .BuildNum }}
84+
paths:
85+
- ./artifacts
86+
87+
lint solidity:
88+
executor: node
5889
steps:
5990
- checkout
60-
- restore_cache: *restore-dependencies-cache
91+
- restore-dependencies
6192
- run:
6293
name: Lint Solidity
6394
command: npm run lint:sol
64-
lint-javascript:
65-
<<: *defaults
95+
96+
lint javascript:
97+
executor: node
6698
steps:
67-
- run: *update-npm
6899
- checkout
69-
- restore_cache: *restore-dependencies-cache
100+
- restore-dependencies
70101
- run:
71-
name: Lint Javascript
102+
name: Lint JavaScript
72103
command: npm run lint:js
104+
73105
test:
74-
<<: *defaults
106+
executor: node
75107
steps:
76-
- run: *update-npm
77108
- checkout
78-
- restore_cache: *restore-dependencies-cache
79-
- restore_cache: *restore-build-cache
109+
- restore-dependencies
110+
- restore-build
111+
- restore-solc
80112
- run:
81113
name: Test
82114
command: npm run test
115+
83116
coverage:
84-
<<: *defaults
117+
executor: node
85118
steps:
86-
- run: *update-npm
87119
- checkout
88-
- restore_cache: *restore-dependencies-cache
89-
- restore_cache: *restore-build-cache
120+
- restore-dependencies
121+
- restore-build
122+
- restore-solc
90123
- run:
91124
name: Tests with coverage
92125
command: npm run coverage
@@ -99,13 +132,17 @@ jobs:
99132
- run:
100133
name: Enforce minimum coverage threshold
101134
command: npx istanbul check-coverage --statements 95 --functions 95 --branches 95 --lines 95
135+
102136
publish:
103-
<<: *defaults
137+
executor: node
104138
steps:
105-
- run: *update-npm
106139
- checkout
107-
- restore_cache: *restore-dependencies-cache
108-
- restore_cache: *restore-build-cache
140+
- run:
141+
name: Verify branch & version tag
142+
command: .circleci/deploy-check.sh
143+
- restore-dependencies
144+
- restore-build
145+
- restore-solc
109146
- run:
110147
name: Set npm auth token
111148
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
@@ -117,37 +154,31 @@ workflows:
117154
version: 2
118155
ci_cd:
119156
jobs:
120-
- install-dependencies:
121-
filters: *filter-all-tags
157+
- install solc
158+
- install dependencies
122159
- build:
123160
requires:
124-
- install-dependencies
125-
filters: *filter-all-tags
126-
- lint-solidity:
161+
- install solc
162+
- install dependencies
163+
- lint solidity:
127164
requires:
128-
- install-dependencies
129-
filters: *filter-all-tags
130-
- lint-javascript:
165+
- install dependencies
166+
- lint javascript:
131167
requires:
132-
- install-dependencies
133-
filters: *filter-all-tags
168+
- install dependencies
134169
- test:
135170
requires:
171+
- lint solidity
172+
- lint javascript
136173
- build
137-
filters: *filter-all-tags
138174
- coverage:
139175
requires:
176+
- lint solidity
177+
- lint javascript
140178
- build
141-
filters: *filter-all-tags
142179
- publish:
143180
requires:
144-
- build
145181
- test
146-
- coverage
147-
- lint-solidity
148-
- lint-javascript
149182
filters:
150-
tags:
151-
only: /v[0-9]+(\.[0-9]+)*/
152183
branches:
153-
ignore: /.*/
184+
only: master

.circleci/deploy-check.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
# Simple script to make sure the current build is on the production branch and
4+
# has the correct version tag.
5+
# This script is used as a check to prevent from deploying a wrong version to
6+
# the docs.
7+
8+
DIR=$(dirname "$(realpath $0)")
9+
10+
say() {
11+
printf "[%s] %s\n" "$0" "$*" >&2
12+
}
13+
14+
die() {
15+
say "$*"
16+
exit 100
17+
}
18+
19+
check_branch() {
20+
if [[ "$CIRCLE_BRANCH" != "master" ]]; then
21+
die "Error: Invalid branch name '$CIRCLE_BRANCH', expected master"
22+
fi
23+
}
24+
25+
check_tag() {
26+
NPM_VERSION=$(node -p "require('${DIR}/../package.json').version")
27+
DISTANCE=$(git rev-list --count "v$NPM_VERSION..HEAD")
28+
if [[ "$DISTANCE" != "0" ]]; then
29+
die "Error: Production branch must point to the current version tag ($DISTANCE commits ahead)"
30+
fi
31+
}
32+
33+
check_branch
34+
check_tag
35+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"build": "npm run clean && npm run build:sol",
2323
"test": "mocha",
2424
"test-old": "scripts/test.sh --network 'test-old'",
25-
"coverage": "SOLIDITY_COVERAGE=true scripts/test.sh",
25+
"coverage": "echo 'Coverage not supported with Solidity v0.5' && exit 1",
2626
"check": "npm run lint && npm run build && npm run test",
2727
"clean": "rm -rf ./build ./coverage ./coverage.json"
2828
},

0 commit comments

Comments
 (0)