Skip to content

Commit

Permalink
Run lints and cache in runner
Browse files Browse the repository at this point in the history
  • Loading branch information
Deniallugo committed Jan 10, 2021
1 parent fc5dc1f commit 28400be
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 19 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
!docker/exit-tool/configs
!docker/keybase-secrets/entrypoint.sh
!docker/ci-integration-test/entrypoint.sh
!docker/zk/entrypoint.sh
!etc/env/dev.env.example
!etc/tokens
!keys/packed
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: test
run: docker-compose -f docker-compose-runner.yml up -d geth postgres
- name: start-services
run: docker-compose -f docker-compose-runner.yml up -d geth postgres zk
- name: cache
run: docker-compose -f docker-compose-runner.yml exec sh infrastructure/ci-scripts/find_cache.sh
- name: init
run: docker-compose -f docker-compose-runner.yml exec zk init
- name: lints
run: docker-compose -f docker-compose-runner.yml exec sh infrastructure/ci-scripts/lints.sh



# - name: link-setup-keys
# run: ln -s ~/setup keys/setup
Expand Down
15 changes: 15 additions & 0 deletions docker-compose-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,18 @@ services:
command: --cfg /tesseracts.toml -vvv
ports:
- "8000:8000"
zk:
build:
context: .
dockerfile: docker/zk/Dockerfile
depends_on:
- postgres
- geth
command: tail -f /dev/null
volumes:
- .:/usr/src/zksync
- /usr/src/cache:/usr/src/cache
- /usr/src/keys:/usr/src/keys
environment:
- IN_DOCKER=true
- CACHE_DIR=/usr/src/cache
15 changes: 4 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,13 @@ services:
source: ./volumes/tesseracts
target: /var/lib/tesseracts/data

zk:
build:
context: .
dockerfile: docker/zk/Dockerfile
volumes:
- .:/usr/src/zksync

runner:
image: myoung34/github-runner:latest
environment:
REPO_URL: https://github.com/matter-labs/zksync-dev
RUNNER_NAME: example-name
RUNNER_TOKEN: AB5IZDXCJNZXBCONB6HESOK77LQYI
RUNNER_TOKEN: AB5IZDTSBRUNUZCLXD3M4TS77MWVC
RUNNER_WORKDIR: /tmp/runner/work
RUNNER_GROUP: my-group
ORG_RUNNER: 'false'
Expand All @@ -64,7 +58,6 @@ services:
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /tmp/runner:/tmp/runner
- .:/usr/src/zksync
# note: a quirk of docker-in-docker is that this path
# needs to be the same path on host and inside the container,
# docker mgmt cmds run outside of docker but expect the paths from within
- /Users/danillugovskoy/cache:/usr/src/cache
- ./keys:/usr/src/keys

6 changes: 3 additions & 3 deletions docker/zk/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
FROM matterlabs/geth:latest as geth
FROM debian:buster-slim

WORKDIR /usr/src/zksync
Expand Down Expand Up @@ -28,7 +27,8 @@ RUN mv solc-static-linux /usr/local/bin/solc
ENV ZKSYNC_HOME=/usr/src/zksync
ENV PATH="${ZKSYNC_HOME}/bin:${PATH}"
ENV CI=1
COPY docker/zk/entrypoint.sh /usr/local/bin/

COPY docker/zk/entrypoint.sh /usr/local/bin/entrypoint.sh

ENTRYPOINT "/usr/local/bin/entrypoint.sh"

#ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
4 changes: 1 addition & 3 deletions docker/zk/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/bash -ue

# Run geth
nohup /usr/local/bin/geth-entry.sh &>/dev/null &

zk
# Prepare dummy-prover in the contract (so the redeployed version will be OK)
zk dummy-prover enable --no-redeploy

Expand Down
8 changes: 8 additions & 0 deletions infrastructure/ci-scripts/cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

rust_hash=$(md5sum Cargo.toml | awk '{ print $1 }')
if [ ! -d "$CACHE_DIR/$rust_hash" ]; then
mkdir -p "$CACHE_DIR/$rust_hash"
fi
rm -rf $CACHE_DIR/$rust_hash/target
cp -r ./target $CACHE_DIR/$rust_hash/target
9 changes: 9 additions & 0 deletions infrastructure/ci-scripts/find_cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

rust_hash=$(md5sum Cargo.toml | awk '{ print $1 }')
if [ -d "$CACHE_DIR/$rust_hash" ]; then
rm -rf ./target
cp -r $CACHE_DIR/$rust_hash/target ./target
echo "Load from cache"
fi

10 changes: 10 additions & 0 deletions infrastructure/ci-scripts/lints.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
zk fmt --check
yarn lint:md
yarn lint:sol
zk dummy-prover ensure-disabled
ulimit -S -c unlimited
cargo fmt --all -- --check
zk f cargo clippy --tests --benches -- -D warnings
pushd sdk/zksync-crypto
cargo fmt -- --check
cargo clippy --all --tests --benches -- -D warnings
17 changes: 17 additions & 0 deletions infrastructure/zk/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ export function reload() {
for (const envVar in env) {
process.env[envVar] = env[envVar];
}
load_docker();
}

export function load_docker() {
if (!process.env.IN_DOCKER) {
return;
}
const envFile = process.env.DOCKER_ENV_FILE as string;
const env = dotenv.parse(fs.readFileSync(envFile));
for (const envVar in env) {
process.env[envVar] = env[envVar];
}
}

// loads environment variables
Expand All @@ -53,15 +65,20 @@ export function load() {
const zksyncEnv =
process.env.ZKSYNC_ENV || (fs.existsSync(current) ? fs.readFileSync(current).toString().trim() : 'dev');
const envFile = `etc/env/${zksyncEnv}.env`;
const dockerEnvFile = `etc/env/docker.env`;
if (zksyncEnv == 'dev' && !fs.existsSync('etc/env/dev.env')) {
fs.copyFileSync('etc/env/dev.env.example', 'etc/env/dev.env');
}
if (!fs.existsSync(envFile)) {
throw new Error('ZkSync config file not found: ' + envFile);
}
if (fs.existsSync(dockerEnvFile)) {
process.env.DOCKER_ENV_FILE = dockerEnvFile;
}
process.env.ZKSYNC_ENV = zksyncEnv;
process.env.ENV_FILE = envFile;
dotenv.config({ path: envFile });
load_docker();
}

// replaces an env variable in current .env file
Expand Down

0 comments on commit 28400be

Please sign in to comment.