Skip to content

Commit

Permalink
Merge pull request #263 from ralexstokes/fix-dockerfile-and-ci
Browse files Browse the repository at this point in the history
Fix dockerfile and ci
  • Loading branch information
ralexstokes committed May 14, 2024
2 parents 0236310 + 22778ae commit 239499f
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 103 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# cribbed from: https://github.com/paradigmxyz/reth/blob/21db2936e617d1018c0bfa5690d8f035dee2843f/.github/workflows/book.yml
name: book

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
# test:
# runs-on: ubuntu-latest
Expand Down Expand Up @@ -47,39 +45,31 @@ jobs:

# - name: Run linkcheck
# run: mdbook-linkcheck --standalone

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly

- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Install mdbook
run: |
mkdir mdbook
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.14/mdbook-v0.4.14-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH
- name: Build book
run: mdbook build

- name: Build docs
run: RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo +nightly doc --all --no-deps

- name: Move docs to book folder
run: |
mv target/doc target/book/docs
- name: Archive artifact
shell: sh
run: |
Expand All @@ -94,30 +84,25 @@ jobs:
--exclude=.git \
--exclude=.github \
.
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: github-pages
path: ${{ runner.temp }}/artifact.tar
retention-days: 1
if-no-files-found: error

deploy:
# Only deploy if a push to main
if: github.ref_name == 'main' && github.event_name == 'push'
runs-on: ubuntu-latest
needs: [build]

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy to GitHub Pages
id: deployment
Expand Down
17 changes: 2 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,49 @@
name: CI suite

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]

branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Read toolchain file
id: rust-toolchain
run: |
RUST_TOOLCHAIN=$(grep 'channel' rust-toolchain.toml | awk '{split($0,a," = "); print a[2]}' | tr -d '"')
echo "RUST_TOOLCHAIN=$RUST_TOOLCHAIN" >> $GITHUB_OUTPUT
shell: bash

- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.rust-toolchain.outputs.RUST_TOOLCHAIN }}

- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Build
run: cargo build --all-targets --all-features --all --verbose

- name: Run tests
run: cargo test --all --verbose

- name: Validate config
run: cargo run config example.config.toml

lint:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy

- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Check format
run: cargo +nightly fmt --all --check

- name: Check clippy
run: cargo +nightly clippy --all-targets --all-features --all --verbose -- -D warnings
85 changes: 40 additions & 45 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,51 @@
name: docker

on:
push:
branches:
- main
tags:
- v*

branches:
- main
tags:
- v*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
IMAGE_NAME: ${{ github.repository_owner}}/mev-rs

jobs:
extract-version:
runs-on: ubuntu-22.04
steps:
- name: Extract version (if main)
if: github.event.ref == 'refs/heads/main'
run: |
echo "VERSION=latest" >> $GITHUB_ENV
- name: Extract version (if tagged release)
if: startsWith(github.event.ref, 'refs/tags')
run: |
echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
outputs:
VERSION: ${{ env.VERSION }}
runs-on: ubuntu-22.04
steps:
- name: Extract version (if main)
if: github.event.ref == 'refs/heads/main'
run: |
echo "VERSION=latest" >> $GITHUB_ENV
- name: Extract version (if tagged release)
if: startsWith(github.event.ref, 'refs/tags')
run: |
echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
outputs:
VERSION: ${{ env.VERSION }}
build-docker:
name: build-docker-${{ matrix.binary }}
runs-on: ubuntu-22.04
strategy:
matrix:
binary: [x86_64]
include:
- profile: maxperf

needs: [extract-version]
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME}}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}
name: build-docker-${{ matrix.binary }}
runs-on: ubuntu-22.04
strategy:
matrix:
binary: [x86_64]
include:
- profile: maxperf
needs: [extract-version]
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME}}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}
36 changes: 9 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name: Release suite

on:
push:
tags:
- v*

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
extract-version:
runs-on: ubuntu-latest
Expand All @@ -22,60 +19,51 @@ jobs:
name: Build Release
strategy:
matrix:
arch: [x86_64-unknown-linux-gnu,
x86_64-apple-darwin]
arch: [x86_64-unknown-linux-gnu, x86_64-apple-darwin]
include:
- arch: x86_64-unknown-linux-gnu
platform: ubuntu-latest
- arch: x86_64-apple-darwin
platform: macos-latest

- arch: x86_64-unknown-linux-gnu
platform: ubuntu-latest
- arch: x86_64-apple-darwin
platform: macos-latest
runs-on: ${{ matrix.platform }}
needs: extract-version
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Read toolchain file
id: rust-toolchain
run: |
RUST_TOOLCHAIN=$(grep 'channel' rust-toolchain.toml | awk '{split($0,a," = "); print a[2]}' | tr -d '"')
echo "RUST_TOOLCHAIN=$RUST_TOOLCHAIN" >> $GITHUB_OUTPUT
shell: bash

- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.rust-toolchain.outputs.RUST_TOOLCHAIN }}

# ==============================
# Build
# ==============================

- name: Build mev-rs
run: |
run: |
cargo install --profile maxperf --path bin/mev --locked
mkdir artifacts
mv ~/.cargo/bin/mev ./artifacts
cd artifacts
tar -czf mev-rs-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz mev
mv *tar.gz* ..
# =======================================================================
# Upload artifacts
# This is required to share artifacts between different jobs
# =======================================================================

- name: Upload artifact
uses: actions/upload-artifact@v4
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: mev-rs-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz
path: mev-rs-${{ needs.extract-version.outputs.VERSION }}-${{ matrix.arch }}.tar.gz
compression-level: 0

draft-release:
name: Draft Release
needs: [build, extract-version]
needs: [build, extract-version]
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
Expand All @@ -85,30 +73,24 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

# ==============================
# Download artifacts
# ==============================

- name: Download artifacts
uses: actions/download-artifact@v4

# ==============================
# Create release draft
# ==============================

- name: Generate Full Changelog
id: changelog
run: |
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "$(git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 ${{ env.VERSION }}^)..${{ env.VERSION }})" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release Draft
env:
GITHUB_USER: ${{ github.repository_owner }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# The formatting here is adapted from OpenEthereum: https://github.com/openethereum/openethereum/blob/main/.github/workflows/build.yml
run: |
body=$(cat <<- "ENDBODY"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ WORKDIR /app

EXPOSE 18550
EXPOSE 28545
COPY --from=builder mev /usr/local/bin
COPY --from=builder /app/mev /usr/local/bin

ENTRYPOINT [ "/usr/local/bin/mev" ]

0 comments on commit 239499f

Please sign in to comment.