From 5bb1043b4b8b95a1a6f83478c75268791fbacef7 Mon Sep 17 00:00:00 2001 From: Andrew Gazelka Date: Sun, 23 Feb 2025 23:05:04 -0700 Subject: [PATCH 1/2] test: integration --- .github/workflows/integration.yml | 40 +++++++++++++++++++++++++++++++ .github/workflows/publish.yml | 12 +++++----- Cargo.toml | 8 ++++++- Dockerfile | 16 ++++++++++--- docker-compose.yml | 18 ++++++++++++-- justfile | 4 ++-- 6 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/integration.yml diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 00000000..e39999d8 --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,40 @@ +name: Integration Test + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Build services + run: docker compose build + + - name: Start services + run: docker compose up -d + + - name: Wait 60 seconds + run: sleep 60 + + # 1) Show the logs for debug + - name: Docker Compose Logs + run: docker compose logs + + # 2) Check if any containers have exited with an error + - name: Check containers status + run: | + # If any container's STATUS shows "Exit" or "exited", fail + # because that means the container died or crashed. + if docker compose ps | grep -q 'Exit'; then + echo "A container has exited with an error." + exit 1 + fi + + - name: Tear down + run: docker compose down diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7486263a..07caa619 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,7 +1,7 @@ name: Publish on: push: - branches: [ main ] + branches: [main] jobs: publish: runs-on: ubuntu-latest @@ -14,17 +14,17 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 1 - + - 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: docker/build-push-action@v5 with: @@ -35,7 +35,7 @@ jobs: tags: | ghcr.io/${{ github.repository }}/hyperion-proxy:latest ghcr.io/${{ github.repository }}/hyperion-proxy:${{ github.sha }} - + - name: Build and push tag uses: docker/build-push-action@v5 with: @@ -51,4 +51,4 @@ jobs: env: KEY: ${{ secrets.TEST_SERVER_KEY }} run: | - curl -X POST -H "Key: $KEY" https://hyperion-test.duckdns.org \ No newline at end of file + curl -X POST -H "Key: $KEY" https://hyperion-test.duckdns.org diff --git a/Cargo.toml b/Cargo.toml index 192bf883..46b9da18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,6 +76,7 @@ heapless = '0.8.0' heed = "0.21.0" hex = '0.4.3' humantime = '2.1.0' +hyperion-proxy = { path = "crates/hyperion-proxy" } itertools = "0.14.0" kanal = '0.1.0-pre8' libc = '0.2.155' @@ -113,7 +114,6 @@ toml = '0.8.14' tracing-appender = '0.2.3' uuid = '1.12.0' - [workspace.dependencies.bvh] git = 'https://github.com/andrewgazelka/bvh-data' @@ -298,6 +298,12 @@ git = 'https://github.com/andrewgazelka/valence' branch = 'feat-open' git = 'https://github.com/andrewgazelka/valence' +[workspace.dependencies.tag] +path = "events/tag" + +[workspace.dependencies.rust-mc-bot] +path = "tools/rust-mc-bot" + [workspace.lints] [workspace.lints.clippy] cast_precision_loss = 'allow' diff --git a/Dockerfile b/Dockerfile index 081dd5ec..08da267a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -82,7 +82,8 @@ RUN --mount=type=cache,target=${CARGO_HOME}/registry \ 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/ + cp target/release-full/tag /app/build/ && \ + cp target/release-full/rust-mc-bot /app/build/ # Runtime base image FROM ubuntu:24.04 AS runtime-base @@ -102,11 +103,20 @@ LABEL org.opencontainers.image.source="https://github.com/andrewgazelka/hyperion 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"] \ No newline at end of file +CMD ["--ip", "0.0.0.0", "--port", "35565"] + +FROM runtime-base AS rust-mc-bot +COPY --from=build-release /app/build/rust-mc-bot / +LABEL org.opencontainers.image.source="https://github.com/andrewgazelka/rust-mc-bot" \ + org.opencontainers.image.description="Rust Minecraft Bot" \ + org.opencontainers.image.version="0.1.0" +ENTRYPOINT ["/rust-mc-bot"] +CMD ["hyperion-proxy:25565", "500", "4"] + diff --git a/docker-compose.yml b/docker-compose.yml index e87fd2e3..b520d37d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: ports: - "25565:25565" command: [ "--server", "tag:35565", "0.0.0.0:25565" ] - restart: unless-stopped + # restart: unless-stopped environment: - RUST_LOG=info networks: @@ -26,7 +26,21 @@ services: expose: - "35565" command: [ ] - restart: unless-stopped + # restart: unless-stopped + environment: + - RUST_LOG=info + networks: + - proxy-network + rust-mc-bot: + # image: ghcr.io/hyperion-mc/hyperion/rust-mc-bot:latest + build: + context: . + dockerfile: Dockerfile + target: rust-mc-bot + command: [ "hyperion-proxy:25565", "100", "1" ] + # restart: unless-stopped + depends_on: + - hyperion-proxy environment: - RUST_LOG=info networks: diff --git a/justfile b/justfile index c3416a9c..2d000f9c 100644 --- a/justfile +++ b/justfile @@ -83,7 +83,7 @@ watch: debug: #!/usr/bin/env -S parallel --shebang --ungroup --jobs 3 RUST_BACKTRACE=full RUN_MODE=debug-{{arch}} cargo watch --postpone --no-vcs-ignores -w {{project_root}}/.trigger-debug -s './target/debug/tag' - RUST_BACKTRACE=full ulimit -Sn {{fds}} && cargo run --bin hyperion-proxy --release + RUST_BACKTRACE=full ulimit -Sn {{fds}} && cargo run --bin hyperion-proxy --release-full -- --server "127.0.0.1:35565" "0.0.0.0:25565" cargo watch -w '{{project_root}}/crates/hyperion' -w '{{project_root}}/events/tag' -s 'cargo check -p tag && cargo build -p tag' -s 'touch {{project_root}}/.trigger-debug' # run in release mode with tracy; auto-restarts on changes @@ -96,7 +96,7 @@ release: release-full: #!/usr/bin/env -S parallel --shebang --ungroup --jobs 2 RUN_MODE=release-f-{{arch}} cargo run --profile release-full -p tag' - ulimit -Sn {{fds}} && cargo run --bin hyperion-proxy --profile release-full + ulimit -Sn {{fds}} && cargo run --bin hyperion-proxy --profile release-full # run a given number of bots to connect to hyperion bots ip='127.0.0.1:25565' count='1000': From b43dd93d5de4b5540fce6d00b2e1f5d6305423b6 Mon Sep 17 00:00:00 2001 From: Andrew Gazelka Date: Sun, 23 Feb 2025 23:34:09 -0700 Subject: [PATCH 2/2] more bots in integration --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index b520d37d..f6e1bdf6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,7 +37,7 @@ services: context: . dockerfile: Dockerfile target: rust-mc-bot - command: [ "hyperion-proxy:25565", "100", "1" ] + command: [ "hyperion-proxy:25565", "500", "2" ] # restart: unless-stopped depends_on: - hyperion-proxy