Skip to content

Commit

Permalink
Test adding ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ebin-mathews committed Jan 9, 2024
1 parent ae88e1d commit 1ff810f
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/actions/setup-rust/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Setup Rust
description: Installs rust in a bare metal fashion
inputs:
caller-workflow-name:
description: 'Name of workflow used for creating a cache key in ASCII format.'
required: true
default: ''

runs:
using: composite
steps:
- name: Generate cache key
working-directory: ./proxy_server
id: cache-key-generator
run: echo "cache-key=$(echo ${{inputs.caller-workflow-name}} | tr ' ' '_')" >> $GITHUB_OUTPUT
shell: bash

- name: Check cache key
working-directory: ./proxy_server
run: "echo Cache key: ${{ steps.cache-key-generator.outputs.cache-key }}"
shell: bash

- name: cache dependencies
working-directory: ./proxy_server
uses: actions/cache@v3
with:
path: |
~/.cargo
key: ${{ runner.os }}-cargo-${{ steps.cache-key-generator.outputs.cache-key }}-${{ hashFiles('**/Cargo.lock') }}

- name: cache rust files
working-directory: ./proxy_server
uses: actions/cache@v3
with:
path: |
target/
key: ${{ runner.os }}-cargo-${{ steps.cache-key-generator.outputs.cache-key }}-${{ hashFiles('**/*.rs') }}

- name: Check rust version
working-directory: ./proxy_server
run: |
rustc --version || true;
cargo --version || true;
cargo clippy --version || true;
cargo fmt --version || true;
shell: bash
47 changes: 47 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: build

on:
pull_request:

jobs:
build:
runs-on: ubuntu-20.04-16c-64g
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Sanity Check
run: |
cat /proc/cpuinfo
- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
caller-workflow-name: test

- name: Clippy check
working-directory: ./proxy_server
run: cargo clippy --all-features --all-targets --tests -- -D warnings

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# see https://docs.docker.com/build/ci/github-actions/cache/#cache-backend-api
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PWD }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./proxy_server/Dockerfile
push: true
tags: jitolabs/block-engine-proxy-server:${{github.sha}}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/arm64,linux/x86_64
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: release

on:
push:
# branches:
# - master
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-20.04-16c-64g
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Sanity Check
run: |
cat /proc/cpuinfo
- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
caller-workflow-name: test

- name: Clippy check
working-directory: ./proxy_server
run: cargo clippy --all-features --all-targets --tests -- -D warnings

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# see https://docs.docker.com/build/ci/github-actions/cache/#cache-backend-api
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PWD }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
file: ./proxy_server/Dockerfile
tags: jitolabs/block-engine-proxy-server:${{github.ref_name}}, jitolabs/block-engine-proxy-server:latest
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/arm64,linux/x86_64

- name: Copy artifact from container
run: |
docker run --rm --platform linux/x86_64 --entrypoint cat jitolabs/block-engine-proxy-server:${{github.ref_name}} /app/jito-block-engine-proxy-server > ./block-engine-proxy-server-x86_64-unknown-linux-gnu
ls -lh .
file ./block-engine-proxy-server-x86_64-unknown-linux-gnu
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
./block-engine-proxy-server-x86_64-unknown-linux-gnu
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: test

on:
pull_request:

jobs:
test:
runs-on: ubuntu-20.04-16c-64g
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
caller-workflow-name: test

- name: Run tests
run: |
pushd proxy_server && ./run_proxy_server.sh && ./stop_proxy_server.sh && popd

0 comments on commit 1ff810f

Please sign in to comment.