Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: cleanup #803

Merged
merged 4 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI

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

jobs:
fmt:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Read rust-toolchain.toml
id: toolchain
run: echo "version=$(grep 'channel' rust-toolchain.toml | cut -d'"' -f2)" >> "$GITHUB_OUTPUT"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.toolchain.outputs.version }}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"
- name: Check formatting
run: cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Read rust-toolchain.toml
id: toolchain
run: echo "version=$(grep 'channel' rust-toolchain.toml | cut -d'"' -f2)" >> "$GITHUB_OUTPUT"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.toolchain.outputs.version }}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"
- name: Clippy check
run: cargo clippy --all-targets --all-features -- -D warnings

doc:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Read rust-toolchain.toml
id: toolchain
run: echo "version=$(grep 'channel' rust-toolchain.toml | cut -d'"' -f2)" >> "$GITHUB_OUTPUT"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.toolchain.outputs.version }}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"
- name: Check documentation
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc --no-deps --all-features

test:
name: Tests (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, macos-14] # macos-14 is for Apple Silicon
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Read rust-toolchain.toml
id: toolchain
run: echo "version=$(grep 'channel' rust-toolchain.toml | cut -d'"' -f2)" >> "$GITHUB_OUTPUT"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.toolchain.outputs.version }}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: "true"
- name: Run tests
run: cargo test --all-features
36 changes: 0 additions & 36 deletions .github/workflows/lint.yml

This file was deleted.

76 changes: 12 additions & 64 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,6 @@ on:
push:
branches: [ main ]
jobs:
antithesis:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push hyperion-proxy
uses: depot/build-push-action@v1
with:
project: qln0fqqvvd
token: ${{ secrets.DEPOT_TOKEN }}
context: .
target: antithesis-hyperion-proxy
platforms: linux/amd64
push: true
tags: |
ghcr.io/${{ github.repository }}/antithesis-hyperion-proxy:latest
ghcr.io/${{ github.repository }}/antithesis-hyperion-proxy:${{ github.sha }}
- name: Build and push tag
uses: depot/build-push-action@v1
with:
project: qln0fqqvvd
token: ${{ secrets.DEPOT_TOKEN }}
context: .
target: antithesis-tag
platforms: linux/amd64
push: true
tags: |
ghcr.io/${{ github.repository }}/antithesis-tag:latest
ghcr.io/${{ github.repository }}/antithesis-tag:${{ github.sha }}

- name: Build and push antithesis-bot
uses: depot/build-push-action@v1
with:
project: qln0fqqvvd
token: ${{ secrets.DEPOT_TOKEN }}
context: .
target: antithesis-bot
platforms: linux/amd64
push: true
tags: |
ghcr.io/${{ github.repository }}/antithesis-bot:latest
ghcr.io/${{ github.repository }}/antithesis-bot:${{ github.sha }}
publish:
runs-on: ubuntu-latest
permissions:
Expand All @@ -70,38 +14,42 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Depot CLI
uses: depot/setup-action@v1

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push hyperion-proxy
uses: depot/build-push-action@v1
uses: docker/build-push-action@v5
with:
project: qln0fqqvvd
token: ${{ secrets.DEPOT_TOKEN }}
context: .
target: hyperion-proxy
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}/hyperion-proxy:latest
ghcr.io/${{ github.repository }}/hyperion-proxy:${{ github.sha }}

- name: Build and push tag
uses: depot/build-push-action@v1
uses: docker/build-push-action@v5
with:
project: qln0fqqvvd
token: ${{ secrets.DEPOT_TOKEN }}
context: .
target: tag
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}/tag:latest
ghcr.io/${{ github.repository }}/tag:${{ github.sha }}

- name: Update test server
env:
KEY: ${{ secrets.TEST_SERVER_KEY }}
Expand Down
112 changes: 20 additions & 92 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y \
binutils \
build-essential \
cmake \
curl \
gcc \
libclang-dev \
libclang1 \
libssl-dev \
linux-headers-generic \
llvm-dev \
perl \
pkg-config \
binutils \
build-essential \
cmake \
curl \
gcc \
libclang-dev \
libclang1 \
libssl-dev \
linux-headers-generic \
llvm-dev \
perl \
pkg-config \
&& rm -rf /var/lib/apt/lists/*

# Base builder stage with Rust installation
Expand Down Expand Up @@ -58,7 +58,7 @@ RUN --mount=type=cache,target=${CARGO_HOME}/registry \
--mount=type=cache,target=${CARGO_HOME}/git \
--mount=type=cache,target=/app/target \
cargo clippy --workspace --benches --tests --examples --all-features --frozen -- -D warnings && \
# cargo doc --all-features --workspace --frozen --no-deps && \
# cargo doc --all-features --workspace --frozen --no-deps && \
cargo nextest run --all-features --frozen && \
touch ci-done

Expand All @@ -73,51 +73,13 @@ COPY --from=machete /app/machete-done /app/machete-done
COPY --from=fmt /app/fmt-done /app/fmt-done
COPY --from=builder-ci /app/ci-done /app/ci-done

FROM builder-base AS antithesis

# todo: assert target is amd64
# https://antithesis.com/docs/using_antithesis/sdk/rust/instrumentation/

COPY ./libvoidstar.so /usr/lib/libvoidstar.so

# Assumes libvoidstar.so is in /usr/lib
ENV LIBVOIDSTAR_PATH=/usr/lib
ENV LD_LIBRARY_PATH=/usr/lib

ENV RUSTFLAGS="-Ccodegen-units=1 \
-Cpasses=sancov-module \
-Cllvm-args=-sanitizer-coverage-level=3 \
-Cllvm-args=-sanitizer-coverage-trace-pc-guard \
-Clink-args=-Wl,--build-id \
-Clink-args=-Wl,-z,nostart-stop-gc \
-L/usr/lib \
-lvoidstar"

ENV LIBVOIDSTAR_PATH=/usr/lib
ENV LD_LIBRARY_PATH=/usr/lib

RUN --mount=type=cache,target=${CARGO_HOME}/registry \
--mount=type=cache,target=${CARGO_HOME}/git \
--mount=type=cache,target=/antithesis-target \
cargo build --frozen --target-dir /antithesis-target && \
cp /antithesis-target/debug/hyperion-proxy /app/hyperion-proxy && \
cp /antithesis-target/debug/tag /app/tag && \
cp /antithesis-target/debug/antithesis-bot /app/antithesis-bot

# Verify instrumentation was successful
RUN --mount=type=cache,target=/antithesis-target \
nm /antithesis-target/debug/hyperion-proxy | grep "sanitizer_cov_trace_pc_guard" && \
ldd /antithesis-target/debug/hyperion-proxy | grep "libvoidstar" && \
nm /antithesis-target/debug/tag | grep "sanitizer_cov_trace_pc_guard" && \
ldd /antithesis-target/debug/tag | grep "libvoidstar"

# Release builder
FROM builder-base AS build-release

RUN --mount=type=cache,target=${CARGO_HOME}/registry \
--mount=type=cache,target=${CARGO_HOME}/git \
--mount=type=cache,target=/app/target \
cargo build --profile release-full --frozen --workspace --exclude antithesis-bot && \
cargo build --profile release-full --frozen --workspace && \
mkdir -p /app/build && \
cp target/release-full/hyperion-proxy /app/build/ && \
cp target/release-full/tag /app/build/
Expand All @@ -126,7 +88,7 @@ RUN --mount=type=cache,target=${CARGO_HOME}/registry \
FROM ubuntu:24.04 AS runtime-base
RUN apt-get update && \
apt-get install -y \
ca-certificates \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
ENV RUST_BACKTRACE=1 \
RUST_LOG=info
Expand All @@ -135,50 +97,16 @@ ENV RUST_BACKTRACE=1 \
FROM runtime-base AS hyperion-proxy
COPY --from=build-release /app/build/hyperion-proxy /
LABEL org.opencontainers.image.source="https://github.com/andrewgazelka/hyperion" \
org.opencontainers.image.description="Hyperion Proxy Server" \
org.opencontainers.image.version="0.1.0"
org.opencontainers.image.description="Hyperion Proxy Server" \
org.opencontainers.image.version="0.1.0"
EXPOSE 8080
ENTRYPOINT ["/hyperion-proxy"]
CMD ["0.0.0.0:8080"]
# NYC Release
FROM runtime-base AS tag
COPY --from=build-release /app/build/tag /
LABEL org.opencontainers.image.source="https://github.com/andrewgazelka/hyperion" \
org.opencontainers.image.description="Hyperion Tag Event" \
org.opencontainers.image.version="0.1.0"
ENTRYPOINT ["/tag"]
CMD ["--ip", "0.0.0.0", "--port", "35565"]

FROM runtime-base AS antithesis-runtime-base

COPY --from=antithesis /usr/lib/libvoidstar.so /usr/lib/libvoidstar.so
ENV LD_LIBRARY_PATH=/usr/lib

FROM antithesis-runtime-base AS antithesis-hyperion-proxy

COPY --from=antithesis /app/hyperion-proxy /
LABEL org.opencontainers.image.source="https://github.com/andrewgazelka/hyperion" \
org.opencontainers.image.description="Hyperion Proxy Server" \
org.opencontainers.image.version="0.1.0"
EXPOSE 8080
ENTRYPOINT ["/hyperion-proxy"]
CMD ["0.0.0.0:8080"]

FROM antithesis-runtime-base AS antithesis-tag

COPY --from=antithesis /app/tag /
LABEL org.opencontainers.image.source="https://github.com/andrewgazelka/hyperion" \
org.opencontainers.image.description="Hyperion Tag Event" \
org.opencontainers.image.version="0.1.0"

org.opencontainers.image.description="Hyperion Tag Event" \
org.opencontainers.image.version="0.1.0"
ENTRYPOINT ["/tag"]
CMD ["--ip", "0.0.0.0", "--port", "35565"]

FROM antithesis-runtime-base AS antithesis-bot

COPY --from=antithesis /app/antithesis-bot /
LABEL org.opencontainers.image.source="https://github.com/andrewgazelka/hyperion" \
org.opencontainers.image.description="Hyperion Antithesis Bot" \
org.opencontainers.image.version="0.1.0"

ENTRYPOINT ["/antithesis-bot"]
CMD ["--ip", "0.0.0.0", "--port", "35565"]
Loading