2026-08-06 19:30:21 +08:00

99 lines
4.1 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "0 0 * * *" # Every night at midnight UTC
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup update stable && rustup default stable
# hashgraph-like-consensus's build.rs shells out to protoc via prost-build.
- run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
# chat-cli, embedded-logos-delivery and logos-delivery-bindings all reach
# waku-bindings, whose build script compiles the Nim library and rln from
# source. The smoketest job pays that cost; this one stays fast by
# skipping them. Note the exclusions only hold while nothing else
# selected here depends on that chain.
- run: cargo build --verbose --workspace --exclude chat-cli --exclude embedded-logos-delivery --exclude logos-delivery-bindings
- run: cargo test --verbose --workspace --exclude chat-cli --exclude embedded-logos-delivery --exclude logos-delivery-bindings
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup update stable && rustup default stable
- run: rustup component add clippy
# hashgraph-like-consensus's build.rs shells out to protoc via prost-build.
- run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
# logos-delivery-bindings excluded: clippy compiles build scripts, so it
# would drive the from-source Nim build described in the test job.
- run: cargo clippy --all-targets --all-features --workspace --exclude chat-cli --exclude logos-delivery-bindings -- -D warnings
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: rustup update stable && rustup default stable
- run: rustup component add rustfmt
- run: cargo fmt --all -- --check
smoketest:
name: Smoketest
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
# waku-bindings' build script builds the Nim library and rln from source on
# a cold cache, which dominates this job.
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- run: rustup update stable && rustup default stable
# hashgraph-like-consensus's build.rs shells out to protoc via prost-build.
- name: Install protoc
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
sudo apt-get update && sudo apt-get install -y protobuf-compiler
else
brew install protobuf
fi
# waku-bindings' build script bootstraps its own Nim toolchain, and
# install_nim.sh / install_nimble.sh symlink the binaries into
# ~/.nimble/bin without putting it on PATH. The same make run then calls
# `nimble` and fails with "No such file or directory", so add it here.
# The directory does not exist yet at this point; that is fine.
- name: Put the bootstrapped Nim toolchain on PATH
run: echo "$HOME/.nimble/bin" >> "$GITHUB_PATH"
# No Nix here: waku-bindings compiles and statically links its own
# liblogosdelivery, so there is no prebuilt Nix .so to match glibc
# against — which is what the dev shell used to be for. Building outside
# Nix also keeps the system OpenSSL visible, which the Nim toolchain
# bootstrap dlopens while installing nimble/nph.
- name: Build chat-cli
run: cargo build --release -p chat-cli
- name: Run chat-cli smoketest
# The client registers against the keypackage/account registry on
# startup, so stand up a mock that accepts those calls.
run: |
python3 .github/scripts/mock-registry.py &
mock_pid=$!
trap 'kill "$mock_pid" 2>/dev/null || true' EXIT
for _ in $(seq 1 50); do
curl -s -o /dev/null http://127.0.0.1:18080/ && break
sleep 0.2
done
./target/release/chat-cli --name ci-test --smoketest --registry-url http://127.0.0.1:18080