Skip to content

Commit

Permalink
Attempt to run workers in separator jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbobbio committed Jan 1, 2025
1 parent e6d6a96 commit b398738
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,44 @@ jobs:
- name: Test
run: ./scripts/run-tests-on-maelstrom.sh "${{ env.ACTIONS_RUNTIME_TOKEN }}" "${{ env.ACTIONS_RESULTS_URL }}"

run_worker:
strategy:
matrix:
worker_number: [1, 2, 3, 4, 5, 6]
name: Run Worker
runs-on: ubuntu-24.04
steps:
- name: Get Repository from Git
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Set up Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@main
# For some reason, GitHub provides Rust for us. The problem is that, when
# executing the recursive cargo invocation, the cargo in ~/.cargo/bin ends
# up prepended to PATH, which then causes problems.
- name: Remove Rust provided by GitHub.
run: rm -rf ~/.cargo/bin ~/.rustup
- name: Disable apparmor container restrictions
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
- name: Install Nix Flake
run: nix develop --command echo done
- name: Get Rust version
run: echo "RUST_VERSION=$(nix develop --command rustc --version | cut -d' ' -f2)" >> $GITHUB_ENV
- name: Set up Rust Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: maelstrom-${{ hashFiles('Cargo.lock', 'flake.lock') }}-${{ env.RUST_VERSION }}
- name: Expose GitHub Action Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Run Worker
run: ./scripts/run-worker.sh "${{ env.ACTIONS_RUNTIME_TOKEN }}" "${{ env.ACTIONS_RESULTS_URL }}"

github_api_tests:
strategy:
matrix:
Expand Down
7 changes: 5 additions & 2 deletions scripts/run-tests-on-maelstrom-inner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ BROKER_ARGS=""
WORKER_ARGS=""
CARGO_ARGS="--profile=release"
PYTEST_ARGS=""
START_WORKER=1

if [[ $# -gt 0 ]]; then
export ACTIONS_RUNTIME_TOKEN=$1
export ACTIONS_RESULTS_URL=$2
BROKER_ARGS="$BROKER_ARGS --artifact-transfer-strategy github"
WORKER_ARGS="$WORKER_ARGS --artifact-transfer-strategy github --broker-connection github"
START_WORKER=0
CARGO_ARGS="$CARGO_ARGS --artifact-transfer-strategy github"
PYTEST_ARGS="$PYTEST_ARGS --artifact-transfer-strategy github"
echo "using github for artifact transfer"
Expand All @@ -30,7 +31,9 @@ PORT=$( \
| awk '/\<addr: / { print $0; exit}' \
| sed -Ee 's/^.*\baddr: [^,]*:([0-9]+),.*$/\1/' \
)
cargo run --release --bin maelstrom-worker -- --broker=localhost:$PORT $WORKER_ARGS &
if [[ $START_WORKER -gt 0 ]]; then
cargo run --release --bin maelstrom-worker -- --broker=localhost:$PORT $WORKER_ARGS &
fi

cargo run --release --bin cargo-maelstrom -- --broker=localhost:$PORT $CARGO_ARGS
CARGO_MAELSTROM_STATUS=$?
Expand Down
9 changes: 9 additions & 0 deletions scripts/run-worker-inner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -ex

export ACTIONS_RUNTIME_TOKEN=$1
export ACTIONS_RESULTS_URL=$2
WORKER_ARGS="--artifact-transfer-strategy github --broker-connection github"

cargo run --release --bin maelstrom-worker -- --broker=0.0.0.0:0 $WORKER_ARGS &
1 change: 1 addition & 0 deletions scripts/run-worker.sh

0 comments on commit b398738

Please sign in to comment.