diff --git a/.github/actions/setup-rust/action.yaml b/.github/actions/setup-rust/action.yaml new file mode 100644 index 0000000..2433071 --- /dev/null +++ b/.github/actions/setup-rust/action.yaml @@ -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 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4f6ce40 --- /dev/null +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f668cc8 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e9ba62e --- /dev/null +++ b/.github/workflows/test.yml @@ -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