Skip to content

Commit

Permalink
ci: build for antithesis (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgazelka authored Dec 19, 2024
1 parent b92f90b commit b359594
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 1 deletion.
52 changes: 52 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,58 @@ 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: Update test server
env:
KEY: ${{ secrets.TEST_SERVER_KEY }}
run: curl -X POST -H "Key: $KEY" https://hyperion-test.duckdns.org





publish:
runs-on: ubuntu-latest
permissions:
Expand Down
50 changes: 49 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
ARG RUST_NIGHTLY_VERSION=nightly-2024-11-29
ARG RUSTFLAGS="-Z share-generics=y -Z threads=8"
ARG CARGO_HOME=/usr/local/cargo

# Install essential build packages
FROM ubuntu:24.04 AS packages
ENV DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -85,6 +84,40 @@ COPY --from=fmt /app/fmt-done /app/fmt-done
COPY --from=nextest /app/nextest-done /app/nextest-done
COPY --from=doc /app/doc-done /app/doc-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 \
-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=/app/target \
cargo build --frozen && \
cp target/debug/hyperion-proxy /app/hyperion-proxy && \
cp target/debug/tag /app/tag

# Verify instrumentation was successful
#RUN nm target/debug/hyperion-proxy | grep "sanitizer_cov_trace_pc_guard" && \
# ldd target/debug/hyperion-proxy | grep "libvoidstar" && \
# nm target/debug/tag | grep "sanitizer_cov_trace_pc_guard" && \
# ldd target/debug/tag | grep "libvoidstar"

# Release builder
FROM builder-base AS build-release

Expand Down Expand Up @@ -122,3 +155,18 @@ LABEL org.opencontainers.image.source="https://github.com/andrewgazelka/hyperion
org.opencontainers.image.version="0.1.0"
ENTRYPOINT ["/tag"]
CMD ["--ip", "0.0.0.0", "--port", "35565"]

FROM 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 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"
2 changes: 2 additions & 0 deletions Dockerfile-antithesis
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM scratch
COPY antithesis/docker-compose.yaml /docker-compose.yaml
29 changes: 29 additions & 0 deletions antithesis/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
services:
hyperion-proxy:
image: ghcr.io/hyperion-mc/hyperion/antithesis-hyperion-proxy:latest
ports:
- "25565:25565"
command: [ "--server", "tag:35565", "0.0.0.0:25565" ]
restart: unless-stopped
environment:
- RUST_LOG=info
networks:
- proxy-network
depends_on:
- tag
tag:
image: ghcr.io/hyperion-mc/hyperion/antithesis-tag:latest
ports:
- "27750:27750"
expose:
- "35565"
command: [ ]
restart: unless-stopped
environment:
- RUST_LOG=info
networks:
- proxy-network

networks:
proxy-network:
driver: bridge
Binary file added libvoidstar.so
Binary file not shown.

0 comments on commit b359594

Please sign in to comment.