Skip to content

Commit

Permalink
Add basic CI (solana-labs#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalu authored Jun 12, 2022
1 parent 3e8fbfb commit bbbf0c9
Show file tree
Hide file tree
Showing 13 changed files with 313 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
38 changes: 38 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build
on:
workflow_call:
secrets:
ACCESS_TOKEN:
required: true
DOCKERHUB_ORG:
required: true
DEPLOYER_SSH_KEY:
required: true
inputs:
TAG:
required: true
type: string

jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
ssh-key: ${{ secrets.DEPLOYER_SSH_KEY }}
# https://github.com/moby/buildkit/issues/1368#issuecomment-731466205
# Seeing conflicting build caching between this and other repos in CI
- name: Docker prune
if: always()
run: docker builder prune -f
- name: Docker image prune
if: always()
run: docker image prune -f
- name: Build containers
run: docker compose --env-file ./env/.env.dev build --progress=plain
env:
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
ORG: ${{ secrets.DOCKERHUB_ORG }}
TAG: ${{ inputs.TAG }}
35 changes: 35 additions & 0 deletions .github/workflows/clean_code.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Clean Code Check
on:
workflow_call:
secrets:
GHUB_TOKEN:
required: true
ACCESS_TOKEN:
required: true
DEPLOYER_SSH_KEY:
required: true
jobs:
clippy_and_udeps_check:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
ssh-key: ${{ secrets.DEPLOYER_SSH_KEY }}
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GHUB_TOKEN }}
args: --all-features
- uses: actions-rs/cargo@v1
with:
command: install
args: cargo-udeps --locked
- name: cargo udeps
uses: actions-rs/cargo@v1
with:
command: udeps
41 changes: 41 additions & 0 deletions .github/workflows/master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Master
on:
push:
branches:
- master

jobs:
clean_code_check:
uses: ./.github/workflows/clean_code.yaml
secrets:
GHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
DEPLOYER_SSH_KEY: ${{ secrets.DEPLOYER_SSH_KEY }}

build_images:
needs: clean_code_check
uses: ./.github/workflows/build.yaml
with:
TAG: "latest"
secrets:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
DOCKERHUB_ORG: ${{ secrets.DOCKERHUB_ORG }}
DEPLOYER_SSH_KEY: ${{ secrets.DEPLOYER_SSH_KEY }}

run_tests:
needs: build_images
uses: ./.github/workflows/test.yaml
secrets:
DOCKERHUB_ORG: ${{ secrets.DOCKERHUB_ORG }}
with:
TAG: "latest"

push_images:
needs: run_tests
uses: ./.github/workflows/push_images.yaml
secrets:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_PWD: ${{ secrets.DOCKERHUB_PWD }}
DOCKERHUB_ORG: ${{ secrets.DOCKERHUB_ORG }}
with:
TAG: "latest"
29 changes: 29 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Pull Request
on:
pull_request:

jobs:
clean_code_check:
uses: ./.github/workflows/clean_code.yaml
secrets:
GHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
DEPLOYER_SSH_KEY: ${{ secrets.DEPLOYER_SSH_KEY }}

build_images:
needs: clean_code_check
uses: ./.github/workflows/build.yaml
with:
TAG: ${{ github.sha }}
secrets:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
DOCKERHUB_ORG: ${{ secrets.DOCKERHUB_ORG }}
DEPLOYER_SSH_KEY: ${{ secrets.DEPLOYER_SSH_KEY }}

run_tests:
needs: build_images
uses: ./.github/workflows/test.yaml
secrets:
DOCKERHUB_ORG: ${{ secrets.DOCKERHUB_ORG }}
with:
TAG: ${{ github.sha }}
28 changes: 28 additions & 0 deletions .github/workflows/push_images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Push Images
on:
workflow_call:
secrets:
DOCKERHUB_USER:
required: true
DOCKERHUB_PWD:
required: true
DOCKERHUB_ORG:
required: true
inputs:
TAG:
required: true
type: string

jobs:
push:
name: Docker Push
runs-on: self-hosted
steps:
# login to registry
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PWD }}
- name: Push relayer image
run: docker push ${{ secrets.DOCKERHUB_ORG }}/jito-transaction-relayer:${{ inputs.TAG }}
43 changes: 43 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release
on:
push:
tags:
- 'v*.*.*'
env:
TAG: "$(git rev-parse --short HEAD)"

jobs:
clean_code_check:
uses: ./.github/workflows/clean_code.yaml
secrets:
GHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
DEPLOYER_SSH_KEY: ${{ secrets.DEPLOYER_SSH_KEY }}

build_images:
needs: clean_code_check
uses: ./.github/workflows/build.yaml
with:
TAG: ${{ github.ref_name }}-${{ github.sha }}
secrets:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
DOCKERHUB_ORG: ${{ secrets.DOCKERHUB_ORG }}
DEPLOYER_SSH_KEY: ${{ secrets.DEPLOYER_SSH_KEY }}

run_tests:
needs: build_images
uses: ./.github/workflows/test.yaml
secrets:
DOCKERHUB_ORG: ${{ secrets.DOCKERHUB_ORG }}
with:
TAG: ${{ github.ref_name }}-${{ github.sha }}

push_images:
needs: run_tests
uses: ./.github/workflows/push_images.yaml
secrets:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_PWD: ${{ secrets.DOCKERHUB_PWD }}
DOCKERHUB_ORG: ${{ secrets.DOCKERHUB_ORG }}
with:
TAG: ${{ github.ref_name }}-${{ github.sha }}
17 changes: 17 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Test
on:
workflow_call:
secrets:
DOCKERHUB_ORG:
required: true
inputs:
TAG:
required: true
type: string

jobs:
test:
runs-on: self-hosted
steps:
- name: Run tests
run: RUST_LOG=info cargo test
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# syntax=docker/dockerfile:1.4.0
FROM rust:1.59.0-slim-buster as builder

RUN apt-get update && apt-get install -y libudev-dev clang pkg-config libssl-dev build-essential cmake
RUN rustup component add rustfmt
RUN update-ca-certificates

ENV HOME=/home/root
WORKDIR $HOME/app
COPY . .

RUN --mount=type=cache,mode=0777,target=/home/root/app/target \
--mount=type=cache,mode=0777,target=/usr/local/cargo/registry \
cargo build --release && cp target/release/jito-* ./

FROM debian:buster-slim as jito-transaction-relayer

# needed for HTTPS
RUN \
apt-get update && \
apt-get -y install ca-certificates && \
apt-get clean

WORKDIR /app
COPY --from=builder /home/root/app/jito-transaction-relayer ./
ENTRYPOINT ./jito-transaction-relayer
18 changes: 18 additions & 0 deletions b
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env sh
# Build the relayer container
set -e

TAG=$(git describe --match=NeVeRmAtCh --always --abbrev=8 --dirty)
ORG="jitolabs"

COMPOSE_DOCKER_CLI_BUILD=1 \
DOCKER_BUILDKIT=1 \
TAG="${TAG}" \
ORG="${ORG}" \
docker-compose --env-file ./env/.env.dev build --progress=plain

COMPOSE_DOCKER_CLI_BUILD=1 \
DOCKER_BUILDKIT=1 \
TAG="${TAG}" \
ORG="${ORG}" \
docker-compose --env-file ./env/.env.dev up --remove-orphans
30 changes: 30 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# See ./b for running instructions
version: "3.8"
services:
transaction_relayer:
image: $ORG/jito-transaction-relayer:$TAG
container_name: jito-transaction-relayer
build:
context: .
dockerfile: Dockerfile
target: jito-transaction-relayer
environment:
- RUST_LOG=info
- TPU_BIND_IP=0.0.0.0
- TPU_PORT=$TPU_PORT
- TPU_FWD_PORT=$TPU_FWD_PORT
- TPU_QUIC_PORT=$TPU_QUIC_PORT
- TPU_QUIC_FWD_PORT=$TPU_QUIC_FWD_PORT
- GRPC_BIND_IP=0.0.0.0
- GRPC_BIND_PORT=$GRPC_BIND_PORT
- NUM_TPU_BINDS=32
- NUM_TPU_FWD_BINDS=16
- RPC_SERVERS=$RPC_SERVERS
- WEBSOCKET_SERVERS=$WEBSOCKET_SERVERS
restart: on-failure
ports:
- "$TPU_PORT:$TPU_PORT/udp"
- "$TPU_FWD_PORT:$TPU_FWD_PORT/udp"
- "$TPU_QUIC_PORT:$TPU_QUIC_PORT/udp"
- "$TPU_QUIC_FWD_PORT:$TPU_QUIC_FWD_PORT/udp"
- "$GRPC_BIND_PORT:$GRPC_BIND_PORT/tcp"
7 changes: 7 additions & 0 deletions env/.env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TPU_PORT=8005
TPU_FWD_PORT=8006
TPU_QUIC_PORT=8007
TPU_QUIC_FWD_PORT=8008
GRPC_BIND_PORT=42069
RPC_SERVERS="https://api.mainnet-beta.solana.com"
WEBSOCKET_SERVERS="wss://api.mainnet-beta.solana.com"
1 change: 0 additions & 1 deletion relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ solana-core = "1.10.24"
tokio-stream = "0.1.9"
tokio = "1.14.1"
tonic = "0.7.2"
uuid = { version = "1.1.2", features = ["v4"] }

0 comments on commit bbbf0c9

Please sign in to comment.