Skip to content
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
71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: CI

on:
push:
branches: [main]
pull_request:

jobs:
changes:
runs-on: ubuntu-latest
outputs:
core: ${{ steps.filter.outputs.core }}
echo: ${{ steps.filter.outputs.echo }}
unique_ids: ${{ steps.filter.outputs.unique_ids }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
core:
- 'Dockerfile'
- 'Cargo.toml'
- 'src/maelstrom/**'
- 'src/maelstrom-build/**'
echo:
- 'src/echo/**'
unique_ids:
- 'src/unique-ids/**'

test-echo:
needs: changes
if: needs.changes.outputs.core == 'true' || needs.changes.outputs.echo == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build image
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: gossipglomers-maelstrom:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test
run: just test echo
- name: Verify result
run: ./scripts/verify-maelstrom.sh

test-unique-ids:
needs: changes
if: needs.changes.outputs.core == 'true' || needs.changes.outputs.unique_ids ==
'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build image
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: gossipglomers-maelstrom:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test
run: just test unique-ids 3 30 "--rate 1000 --availability total --nemesis
partition"
- name: Verify result
run: ./scripts/verify-maelstrom.sh
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
services:
maelstrom:
build: .
image: gossipglomers-maelstrom:latest
volumes:
- .:/app
- cargo-registry:/usr/local/cargo/registry
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ shell:
# just test echo 3 30
# just test unique-ids 3 30 "--rate 1000 --availability total --nemesis partition"
test binary nodes="1" seconds="10" extra="":
docker compose run --rm -it maelstrom bash -c \
docker compose run --rm maelstrom bash -c \
"cargo build --bin {{binary}} && \
maelstrom test \
-w {{binary}} \
Expand Down
30 changes: 30 additions & 0 deletions scripts/verify-maelstrom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Verify the most recent Maelstrom run succeeded.
#
# Maelstrom exits non-zero on failure, but we also parse store/latest/results.edn
# for the top-level :valid? flag as a belt-and-suspenders check — useful when the
# JVM exits cleanly but the checker found anomalies without a non-zero exit code.
#
# Usage: ./scripts/verify-maelstrom.sh
# Exit: 0 = valid, 1 = invalid or results not found

set -euo pipefail

RESULTS="store/latest/results.edn"

if [[ ! -f "$RESULTS" ]]; then
echo "error: $RESULTS not found — did the test run complete?" >&2
exit 1
fi

# The top-level :valid? key appears last in the file (after all sub-checker keys).
# We match only the final occurrence to avoid false positives from nested maps.
if grep -qE '^ *:valid\? true\}$' "$RESULTS"; then
echo "maelstrom: run is valid"
exit 0
else
echo "maelstrom: run is INVALID" >&2
echo "--- $RESULTS ---" >&2
cat "$RESULTS" >&2
exit 1
fi
Loading