name: Continuous integration
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
jobs:
changes:
name: changes
runs-on: ubuntu-latest
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
code:
- '**'
- '!**/*.md'
- '!docs/**'
cargo-fmt:
name: cargo-fmt
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --all -- --check
cargo-check:
name: cargo-check
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo check --workspace --all-targets
cargo-check-wasm:
name: cargo-check-wasm
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
with:
key: wasm32
- run: cargo check --target wasm32-unknown-unknown
cargo-clippy:
name: cargo-clippy
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --workspace --all-targets -- -D warnings
cargo-test:
name: cargo-test
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo test --workspace --lib --examples --tests
cargo-test-integration:
name: cargo-test-integration
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: integration
- name: Bring up the algorand test harness
run: ./test-harness.sh up
- name: Dump sandbox.log on harness failure
if: failure()
run: |
test -f test-harness/.sandbox/sandbox.log \
&& cat test-harness/.sandbox/sandbox.log \
|| echo "No sandbox.log to dump."
- name: Run cucumber integration tests
run: cargo test --test cucumber --
- name: Tear down the algorand test harness
if: always()
run: ./test-harness.sh down
cargo-test-e2e:
name: cargo-test-e2e
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: e2e
- name: Bring up a local Algorand sandbox
run: make sandbox || true
- name: Wait for algod + kmd to be ready
run: |
token=$(printf 'a%.0s' {1..64})
for i in $(seq 1 60); do
if curl -sf -o /dev/null http://localhost:4001/genesis \
&& curl -sf -o /dev/null -H "X-KMD-API-Token: $token" http://localhost:4002/v1/wallets; then
echo "algod + kmd ready"; exit 0
fi
sleep 2
done
echo "sandbox did not become ready"; docker ps -a
cat sandbox/sandbox.log 2>/dev/null || true
exit 1
- name: Run the ARC-56 end-to-end tests
run: make test-e2e
- name: Dump sandbox logs on failure
if: failure()
run: |
cat sandbox/sandbox.log 2>/dev/null || echo "No sandbox.log to dump."
docker logs algorand-sandbox-algod 2>&1 | tail -100 || true
- name: Tear down the sandbox
if: always()
run: make sandbox-down