Add presubmit CI test that runs "tilt ci"

- Use "npm ci" instead of "npm install" in a couple of places.

- Migrate generate-wasm.sh to a Dockerfile so it can be cached.

- Disable namespace creation and explorer build in CI.

Change-Id: I2e6ee806438863ca81ada701e14684f9f4cc0a76
This commit is contained in:
Leo 2021-08-22 21:52:48 +02:00
parent eace2fcfea
commit aeb673a164
7 changed files with 100 additions and 69 deletions

View File

@ -13,19 +13,18 @@ RUN --mount=type=cache,target=/root/.cache \
ADD ethereum /usr/src/ethereum ADD ethereum /usr/src/ethereum
WORKDIR /usr/src/ethereum WORKDIR /usr/src/ethereum
RUN --mount=type=cache,target=/usr/src/ethereum/node_modules \ RUN --mount=type=cache,target=/root/.cache \
npm install --mount=type=cache,target=/root/.npm \
npm ci
ADD clients/token_bridge /usr/src/clients/token_bridge ADD clients/token_bridge /usr/src/clients/token_bridge
WORKDIR /usr/src/clients/token_bridge WORKDIR /usr/src/clients/token_bridge
RUN --mount=type=cache,target=/usr/src/ethereum/node_modules \ RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/usr/src/clients/token_bridge/node_modules \ --mount=type=cache,target=/root/.npm \
npm install && \ set -xe && \
npm run build-contracts && \ npm ci && \
npm run build && \ npm run build-contracts && \
cp -r node_modules node_modules_cached npm run build
RUN rm -rf node_modules && mv node_modules_cached node_modules # Make cached node_modules part of the image
ADD solana /usr/src/solana ADD solana /usr/src/solana
ADD proto /usr/src/proto ADD proto /usr/src/proto
@ -35,9 +34,9 @@ ENV EMITTER_ADDRESS="11111111111111111111111111111115"
ENV BRIDGE_ADDRESS="Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o" ENV BRIDGE_ADDRESS="Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o"
RUN --mount=type=cache,target=/root/.cache \ RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=target \
--mount=type=cache,target=bridge/target \ --mount=type=cache,target=bridge/target \
--mount=type=cache,target=modules/token_bridge/target \ --mount=type=cache,target=modules/token_bridge/target \
set -xe && \
cargo build --manifest-path ./bridge/Cargo.toml --package client --release && \ cargo build --manifest-path ./bridge/Cargo.toml --package client --release && \
cargo build --manifest-path ./modules/token_bridge/Cargo.toml --package client --release && \ cargo build --manifest-path ./modules/token_bridge/Cargo.toml --package client --release && \
cp /usr/local/cargo/bin/solana /usr/local/bin && \ cp /usr/local/cargo/bin/solana /usr/local/bin && \

View File

@ -6,9 +6,15 @@
# #
load("ext://namespace", "namespace_create", "namespace_inject") load("ext://namespace", "namespace_create", "namespace_inject")
load('ext://secret', 'secret_yaml_generic') load("ext://secret", "secret_yaml_generic")
allow_k8s_contexts("ci")
# Disable telemetry by default
analytics_settings(False)
# Runtime configuration # Runtime configuration
config.define_bool("ci", False, "We are running in CI")
config.define_string("num", False, "Number of guardian nodes to run") config.define_string("num", False, "Number of guardian nodes to run")
@ -30,10 +36,12 @@ namespace = cfg.get("namespace", "wormhole")
bigTablePersistence = cfg.get("bigTablePersistence", False) bigTablePersistence = cfg.get("bigTablePersistence", False)
gcpProject = cfg.get("gcpProject", None) gcpProject = cfg.get("gcpProject", None)
bigTableKeyPath = cfg.get("bigTableKeyPath", "./bigtable-writer.json") bigTableKeyPath = cfg.get("bigTableKeyPath", "./bigtable-writer.json")
ci = cfg.get("ci", False)
# namespace # namespace
namespace_create(namespace) if not ci:
namespace_create(namespace)
def k8s_yaml_with_ns(objects): def k8s_yaml_with_ns(objects):
return k8s_yaml(namespace_inject(objects, namespace)) return k8s_yaml(namespace_inject(objects, namespace))
@ -61,8 +69,8 @@ if bigTablePersistence:
k8s_yaml_with_ns( k8s_yaml_with_ns(
secret_yaml_generic( secret_yaml_generic(
"bridge-bigtable-key", "bridge-bigtable-key",
from_file = "bigtable-key.json=" + bigTableKeyPath from_file = "bigtable-key.json=" + bigTableKeyPath,
) ),
) )
docker_build( docker_build(
@ -85,7 +93,7 @@ def build_bridge_yaml():
container["command"] += [ container["command"] += [
"--bigTablePersistenceEnabled", "--bigTablePersistenceEnabled",
"--bigTableGCPProject", "--bigTableGCPProject",
gcpProject gcpProject,
] ]
return encode_yaml_stream(bridge_yaml) return encode_yaml_stream(bridge_yaml)
@ -101,7 +109,7 @@ k8s_resource("guardian", resource_deps = ["proto-gen", "solana-devnet"], port_fo
docker_build( docker_build(
ref = "pyth", ref = "pyth",
context = ".", context = ".",
dockerfile = "third_party/pyth/Dockerfile" dockerfile = "third_party/pyth/Dockerfile",
) )
k8s_yaml_with_ns("./devnet/pyth.yaml") k8s_yaml_with_ns("./devnet/pyth.yaml")
@ -114,7 +122,7 @@ k8s_yaml_with_ns("./devnet/envoy-proxy.yaml")
k8s_resource( k8s_resource(
"envoy-proxy", "envoy-proxy",
resource_deps = ["guardian"], resource_deps = ["guardian"],
objects = ["envoy-proxy:ConfigMap:wormhole"], objects = ["envoy-proxy:ConfigMap"],
port_forwards = [ port_forwards = [
port_forward(8080, name = "gRPC proxy for guardian's publicRPC data [:8080]"), port_forward(8080, name = "gRPC proxy for guardian's publicRPC data [:8080]"),
port_forward(9901, name = "gRPC proxy admin [:9901]"), # for proxy debugging port_forward(9901, name = "gRPC proxy admin [:9901]"), # for proxy debugging
@ -179,26 +187,28 @@ k8s_resource("eth-devnet", port_forwards = [
# explorer web app # explorer web app
docker_build( # TOOD: the explorer web app does not currently build
ref = "explorer", if not ci:
context = "./explorer", docker_build(
dockerfile = "./explorer/Dockerfile", ref = "explorer",
ignore = ["./explorer/node_modules"], context = "./explorer",
live_update = [ dockerfile = "./explorer/Dockerfile",
sync("./explorer/src", "/home/node/app/src"), ignore = ["./explorer/node_modules"],
sync("./explorer/public", "/home/node/app/public"), live_update = [
], sync("./explorer/src", "/home/node/app/src"),
) sync("./explorer/public", "/home/node/app/public"),
],
)
k8s_yaml_with_ns("devnet/explorer.yaml") k8s_yaml_with_ns("devnet/explorer.yaml")
k8s_resource( k8s_resource(
"explorer", "explorer",
resource_deps = ["envoy-proxy", "proto-gen-web"], resource_deps = ["envoy-proxy", "proto-gen-web"],
port_forwards = [ port_forwards = [
port_forward(8001, name = "Explorer Web UI [:8001]"), port_forward(8001, name = "Explorer Web UI [:8001]"),
], ],
) )
# terra devnet # terra devnet

View File

@ -11,7 +11,6 @@ import (
"golang.org/x/crypto/acme" "golang.org/x/crypto/acme"
"golang.org/x/crypto/acme/autocert" "golang.org/x/crypto/acme/autocert"
"google.golang.org/grpc" "google.golang.org/grpc"
"log"
"net" "net"
"net/http" "net/http"
"strings" "strings"

View File

@ -200,4 +200,4 @@ spec:
- name: TYPEORM_ENTITIES - name: TYPEORM_ENTITIES
value: "src/orm/*Entity.ts" value: "src/orm/*Entity.ts"
restartPolicy: Always restartPolicy: Always
serviceName: terra-fcd serviceName: terra-fcd

View File

@ -4,32 +4,5 @@ set -euo pipefail
( (
cd solana cd solana
mkdir -p ../sdk/js/src/solana/core DOCKER_BUILDKIT=1 docker build -f Dockerfile.wasm -o type=local,dest=.. .
mkdir -p ../sdk/js/src/solana/token
docker build -t localhost/certusone/wormhole-wasmpack:latest -f Dockerfile.wasm .
docker run --rm -it --workdir /usr/src/bridge/bridge/program \
-v $(pwd)/../sdk/js/src/solana/core:/usr/src/bridge/bridge/program/pkg \
-e EMITTER_ADDRESS=11111111111111111111111111111115 \
-e BRIDGE_ADDRESS=11111111111111111111111111111115 \
localhost/certusone/wormhole-wasmpack:latest \
/usr/local/cargo/bin/wasm-pack build --target bundler -- --features wasm
docker run --rm -it --workdir /usr/src/bridge/modules/token_bridge/program \
-v $(pwd)/../sdk/js/src/solana/token:/usr/src/bridge/modules/token_bridge/program/pkg \
-e EMITTER_ADDRESS=11111111111111111111111111111115 \
-e BRIDGE_ADDRESS=11111111111111111111111111111115 \
localhost/certusone/wormhole-wasmpack:latest \
/usr/local/cargo/bin/wasm-pack build --target bundler -- --features wasm
docker run --rm -it --workdir /usr/src/bridge/bridge/program \
-v $(pwd)/../clients/solana/pkg:/usr/src/bridge/bridge/program/pkg \
-e EMITTER_ADDRESS=11111111111111111111111111111115 \
-e BRIDGE_ADDRESS=11111111111111111111111111111115 \
localhost/certusone/wormhole-wasmpack:latest \
/usr/local/cargo/bin/wasm-pack build --target nodejs -- --features wasm
cp $(pwd)/../clients/solana/pkg/. $(pwd)/../clients/token_bridge/pkg/core -R
docker run --rm -it --workdir /usr/src/bridge/modules/token_bridge/program \
-v $(pwd)/../clients/token_bridge/pkg/token:/usr/src/bridge/modules/token_bridge/program/pkg \
-e EMITTER_ADDRESS=11111111111111111111111111111115 \
-e BRIDGE_ADDRESS=11111111111111111111111111111115 \
localhost/certusone/wormhole-wasmpack:latest \
/usr/local/cargo/bin/wasm-pack build --target nodejs -- --features wasm
) )

View File

@ -1,3 +1,5 @@
final kubeCleanup = "kubectl delete --namespace=\$DEPLOY_NS service,statefulset,configmap,pod --all"
pipeline { pipeline {
agent none agent none
stages { stages {
@ -12,15 +14,35 @@ pipeline {
} }
steps { steps {
gerritCheck checks: ['jenkins:test': 'RUNNING'], message: "Running on ${env.NODE_NAME}" gerritCheck checks: ['jenkins:test': 'RUNNING'], message: "Running on ${env.NODE_NAME}"
sh "git show HEAD"
echo "Gerrit change: ${GERRIT_CHANGE_URL}"
echo "Tilt progress dashboard: https://${DASHBOARD_URL}"
sh """
kubectl config set-context ci --namespace=$DEPLOY_NS
kubectl config use-context ci
"""
sh kubeCleanup
sh "./generate-wasm.sh"
timeout(time: 60, unit: 'MINUTES') {
sh "tilt ci -- --ci --namespace=$DEPLOY_NS --num=1"
}
} }
post { post {
success { success {
gerritReview labels: [Verified: 1]
gerritCheck checks: ['jenkins:test': 'SUCCESSFUL'] gerritCheck checks: ['jenkins:test': 'SUCCESSFUL']
} }
unsuccessful { unsuccessful {
gerritReview labels: [Verified: -1]
gerritCheck checks: ['jenkins:test': 'FAILED'] gerritCheck checks: ['jenkins:test': 'FAILED']
} }
cleanup {
sh kubeCleanup
}
} }
} }
} }

View File

@ -1,5 +1,5 @@
# syntax=docker.io/docker/dockerfile:experimental@sha256:de85b2f3a3e8a2f7fe48e8e84a65f6fdd5cd5183afa6412fff9caa6871649c44 # syntax=docker.io/docker/dockerfile:experimental@sha256:de85b2f3a3e8a2f7fe48e8e84a65f6fdd5cd5183afa6412fff9caa6871649c44
FROM docker.io/library/rust:1.49@sha256:a50165ea96983c21832578afb1c8c028674c965bc1ed43b607871b1f362e06a5 FROM docker.io/library/rust:1.49@sha256:a50165ea96983c21832578afb1c8c028674c965bc1ed43b607871b1f362e06a5 AS build
RUN apt-get update && apt-get install -y libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang RUN apt-get update && apt-get install -y libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang
RUN rustup component add rustfmt RUN rustup component add rustfmt
@ -11,7 +11,35 @@ RUN cargo install wasm-pack
ENV RUST_LOG="solana_runtime::system_instruction_processor=trace,solana_runtime::message_processor=trace,solana_bpf_loader=debug,solana_rbpf=debug" ENV RUST_LOG="solana_runtime::system_instruction_processor=trace,solana_runtime::message_processor=trace,solana_bpf_loader=debug,solana_rbpf=debug"
ENV EMITTER_ADDRESS="11111111111111111111111111111115" ENV EMITTER_ADDRESS="11111111111111111111111111111115"
ENV BRIDGE_ADDRESS="Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o"
COPY bridge bridge COPY bridge bridge
COPY modules modules COPY modules modules
COPY solitaire solitaire COPY solitaire solitaire
# Compile Wormhole
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=bridge/target \
cd bridge/program && /usr/local/cargo/bin/wasm-pack build --target bundler -d bundler -- --features wasm
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=bridge/target \
cd bridge/program && /usr/local/cargo/bin/wasm-pack build --target nodejs -d nodejs -- --features wasm
# Compile Token Bridge
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=modules/token_bridge/target \
cd modules/token_bridge/program && /usr/local/cargo/bin/wasm-pack build --target bundler -d bundler -- --features wasm
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=modules/token_bridge/target \
cd modules/token_bridge/program && /usr/local/cargo/bin/wasm-pack build --target nodejs -d nodejs -- --features wasm
FROM scratch AS export
COPY --from=build /usr/src/bridge/bridge/program/bundler sdk/js/src/solana/core
COPY --from=build /usr/src/bridge/modules/token_bridge/program/bundler sdk/js/src/solana/token
COPY --from=build /usr/src/bridge/bridge/program/nodejs clients/solana/pkg
COPY --from=build /usr/src/bridge/bridge/program/nodejs clients/token_bridge/pkg/core
COPY --from=build /usr/src/bridge/modules/token_bridge/program/nodejs clients/token_bridge/pkg/token