Skip to content

Commit c861835

Browse files
authored
ci(circleci): move forward to CircleCI (#49)
* ci(circleci): init the config of circleci * fix(vectors): remove test-vectors * ci(daily-check): remove daily check * ci(jobs): clean jobs * ci(rust_setup): install rust toolchain without prompt * ci(format): optimize format step * ci(compile): verbose output * ci(timeout): set no_output_timeout * ci(circleci): remove verbose output in circle ci * ci(docker): setup docker jobs * ci(docker): remove docker ci in github actions * ci(docker): add executor to docker jobs * ci(docker): fix typo in job names * ci(docker): setup docker executor * ci(docker): fix docker-build target directory * ci(docker): persist docker image * ci(docker): stringify dockerb build arguments * ci(docker): fix the fucking format of the circleci config * ci(docker): checkout before building image * ci(docker): set no_output_timeout * ci(machine): use ubuntu-2004 * ci(docker): use xlarge resource for docker builder * ci(docker): remove docker executor * ci(executor): fix the indent of machine config * ci(executor): move environment out of machine config * ci(docker): add docker syntax * ci(docker): enable docker buildkit * ci(cache): use sccache cache * ci(cache): unset rustc wrapper for installing sccache * ci(cache): fetch sccache before fetching packages * ci(cache): cache sccache binary * ci(docker): make login dockerhub as a command * ci(docker): fix type of command login_dockerhub * ci(cache): cache sccache and cargo-audit binaries ( under 20MB ) * ci(cache): fix the cache of cargo binaries * ci(cache): squash the cahce of cargo-audit and sccache binaries * ci(cache): fix the typo of the condition of cargo-audit * ci(cache): fix the cache condition of sccache * ci(cache): modify sccache-cache storage key to trigger CI * ci(cache): fix cache paths * Add sccache to CircleCI (#53) * ci(cache): download sccahce binary directly * ci(cach): sudo privilege to moving sccache binary * ci(cache): use x86_64 sccache for the testing machine * ci(cache): correct the url of sccache resource * ci(sccache): clean the indent * ci(security): requires reust_setup only * ci(cache): use optional feature to run rust_setup conditionally * ci(rust_setup): fix installing sccache * ci(rust_setup): clean rust_setup * ci(workflow): requires prefetch-cache * ci(format): add rust_setup to format job * ci(cache): add sccache to rust_setup * ci(curl): fix the test script about downloading from links * ci(condition): use if-else * ci(prefetch): remove prefetch-crates * ci(security): force installing rust-toolchain in job security * ci(cache): use cache for security checking * ci(security): remove os deps in security check * ci(chore): uppercase job names * ci(machine): use xlarge resource * ci(trigger): trigger build and test cache * ci(cache): embed restore_cache into rust_setup * ci(chore): trigger building
1 parent f366a7a commit c861835

File tree

5 files changed

+451
-324
lines changed

5 files changed

+451
-324
lines changed

.circleci/config.yml

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
version: 2.1
2+
3+
executors:
4+
test-executor:
5+
resource_class: xlarge
6+
machine:
7+
image: ubuntu-2004:202010-01
8+
docker_layer_caching: true
9+
environment:
10+
IMAGE_NAME: chainsafe/pint
11+
CARGO_AUDIT: /home/circleci/.cargo/bin/cargo-audit
12+
RUSTC_WRAPPER: /home/circleci/.cargo/bin/sccache
13+
RUSTC_TOOLCHAIN: nightly-2021-04-18
14+
SCCACHE_CACHE_SIZE: 5G
15+
16+
commands:
17+
install_deps:
18+
steps:
19+
- run:
20+
name: Download Substrate Dependencies
21+
command: sudo apt-get update && sudo apt-get install -y git clang curl libssl-dev
22+
cargo_audit_setup:
23+
description: Install cargo-audit
24+
steps:
25+
- restore_cache:
26+
key: cargo-audit-{{ arch }}
27+
- run:
28+
name: Sets up cargo-audit
29+
command: |
30+
[[ ! -f ${CARGO_AUDIT} ]] && RUSTC_WRAPPER='' cargo install cargo-audit
31+
cargo audit --version
32+
- save_cache:
33+
key: cargo-audit-{{ arch }}
34+
paths:
35+
- ../.cargo/bin/cargo-audit
36+
sccache_setup:
37+
steps:
38+
- restore_cache:
39+
key: sccache-{{ arch }}
40+
- run:
41+
name: Sets up Sccache
42+
command: |
43+
[[ ! -f ${RUSTC_WRAPPER} ]] \
44+
&& curl -L https://github.com/mozilla/sccache/releases/download/\
45+
v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz \
46+
| tar -zxvf - sccache-v0.2.15-x86_64-unknown-linux-musl/sccache \
47+
&& sudo mv sccache-v0.2.15-x86_64-unknown-linux-musl/sccache ${RUSTC_WRAPPER} \
48+
&& sudo chmod +x ${RUSTC_WRAPPER}
49+
sccache -s
50+
- save_cache:
51+
key: sccache-{{ arch }}
52+
paths:
53+
- ../.cargo/bin/sccache
54+
rust_setup:
55+
description: Sets up Rust Toolchain
56+
steps:
57+
- run:
58+
name: Sets up Rust Toolchain
59+
command: |
60+
curl https://sh.rustup.rs -sSf | sh -s -- -y \
61+
--default-toolchain "$RUSTC_TOOLCHAIN" \
62+
-c clippy rustfmt \
63+
-t wasm32-unknown-unknown \
64+
--profile minimal
65+
- restore_cache:
66+
key: cargo-package-cache-{{ checksum "Cargo.lock" }}-{{ arch }}
67+
- sccache_setup
68+
build_setup:
69+
description: Sets up environment for future jobs
70+
steps:
71+
- checkout
72+
- rust_setup
73+
- install_deps
74+
save_build_cache:
75+
description: Save cargo package cache for subsequent jobs
76+
steps:
77+
- save_cache:
78+
key: cargo-package-cache-{{ checksum "Cargo.lock" }}-{{ arch }}
79+
paths:
80+
- ../.cache/sccache
81+
- ../.cargo/git
82+
- ../.cargo/registry
83+
- ../.cargo/.package-cache
84+
login_dockerhub:
85+
description: Login DockerHub
86+
steps:
87+
- run:
88+
name: Login DockerHub
89+
command: echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
90+
91+
jobs:
92+
format:
93+
executor: test-executor
94+
description: Format Check
95+
steps:
96+
- checkout
97+
- rust_setup
98+
- run:
99+
name: Format check
100+
command: cargo fmt -- --check
101+
lint:
102+
executor: test-executor
103+
description: Lint Code
104+
steps:
105+
- build_setup
106+
- run:
107+
name: Clippy Check
108+
command: cargo clippy --all-targets
109+
- save_build_cache
110+
test:
111+
executor: test-executor
112+
description: Run tests
113+
steps:
114+
- build_setup
115+
- run:
116+
name: Run Tests
117+
command: cargo test --all
118+
- save_build_cache
119+
security:
120+
executor: test-executor
121+
description: Cargo audit
122+
steps:
123+
- checkout
124+
- rust_setup
125+
- cargo_audit_setup
126+
- run:
127+
name: Check for known security issues in dependencies
128+
command: cargo audit
129+
docker-build:
130+
executor: test-executor
131+
description: Build Docker Image
132+
steps:
133+
- checkout
134+
- run:
135+
name: Build docker image
136+
command: BUILDKIT_PROGRESS=plain DOCKER_BUILDKIT=1 docker build -t $IMAGE_NAME:latest .
137+
- run:
138+
name: Archive Docker image
139+
command: docker save -o image.tar $IMAGE_NAME
140+
- persist_to_workspace:
141+
root: .
142+
paths:
143+
- ./image.tar
144+
docker-publish-latest:
145+
executor: test-executor
146+
description: Publish latest Docker Image
147+
steps:
148+
- attach_workspace:
149+
at: /tmp/workspace
150+
- run:
151+
name: Load Archived Docker Image
152+
command: docker load -i /tmp/workspace/image.tar
153+
- login_dockerhub
154+
- run:
155+
name: Publish Latest Docker Image
156+
command: docker push $IMAGE_NAME:latest
157+
docker-publish-tag:
158+
executor: test-executor
159+
description: Publish Tagged Docker Image
160+
steps:
161+
- attach_workspace:
162+
at: /tmp/workspace
163+
- run:
164+
name: Load Archived Docker Image
165+
command: docker load -i /tmp/workspace/image.tar
166+
- login_dockerhub
167+
- run:
168+
name: Publish Tagged Docker Image
169+
command: |
170+
IMAGE_TAG=${CIRCLE_TAG/v/''}
171+
docker tag $IMAGE_NAME:latest $IMAGE_NAME:$IMAGE_TAG
172+
docker push $IMAGE_NAME:latest
173+
docker push $IMAGE_NAME:$IMAGE_TAG
174+
175+
workflows:
176+
test-code:
177+
jobs:
178+
- format
179+
- lint
180+
- test
181+
security:
182+
jobs:
183+
- security
184+
docker:
185+
jobs:
186+
- docker-build
187+
- docker-publish-latest:
188+
requires:
189+
- docker-build
190+
filters:
191+
branches:
192+
only: main
193+
- docker-publish-tag:
194+
requires:
195+
- docker-publish-latest
196+
filters:
197+
tags:
198+
only: /^v.*/
199+
branches:
200+
only: main

.github/workflows/docker.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/test-code.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)