Skip to content

ci: refactor and update GitHub Actions workflows #1651

ci: refactor and update GitHub Actions workflows

ci: refactor and update GitHub Actions workflows #1651

Workflow file for this run

name: CI
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Swift Lint
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Check swift codestyle
uses: docker://ghcr.io/realm/swiftlint:latest
with:
args: --config .swiftlint.yml --strict
cargo-format:
name: Cargo Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo +nightly fmt --all -- --check
test:
name: Build and Test (${{ matrix.config }})
runs-on: [self-hosted, linux]
timeout-minutes: ${{ matrix.config == 'debug' && 90 || 75 }}
strategy:
fail-fast: false
matrix:
config: [debug, release]
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
submodules: recursive
- run: sudo apt-get update
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: librocksdb-dev libzstd-dev libbz2-dev liblz4-dev libjemalloc-dev
- uses: aws-actions/configure-aws-credentials@v6
with:
aws-region: us-east-2
- name: Setup Swift
uses: SwiftyLab/setup-swift@latest
- name: Get Swift Version
id: swift-version
run: |
SWIFT_VERSION=$(swift --version 2>&1 | head -n1 | sed -E 's/.*Swift version ([0-9.]+).*/\1/')
echo "Detected Swift version: $SWIFT_VERSION"
echo "version=$SWIFT_VERSION" >> $GITHUB_OUTPUT
# SPM caching disabled due to 5.7 GB size causing 7+ minute upload delays
# The cache save/upload time exceeds the build time, making caching counterproductive
- name: Cache Cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Cache bandersnatch_vrfs static lib
uses: actions/cache@v5
with:
path: .lib/libbandersnatch_vrfs.a
key: ${{ runner.os }}-libs-libbandersnatch-${{ hashFiles('Utils/Sources/bandersnatch/**') }}
restore-keys: |
${{ runner.os }}-libs-libbandersnatch
- name: Cache bls static lib
uses: actions/cache@v5
with:
path: .lib/libbls.a
key: ${{ runner.os }}-libs-libbls-${{ hashFiles('Utils/Sources/bls/**') }}
restore-keys: |
${{ runner.os }}-libs-libbls
- name: Cache erasure-coding static lib
uses: actions/cache@v5
with:
path: .lib/libec.a
key: ${{ runner.os }}-libs-libec-${{ hashFiles('Utils/Sources/erasure-coding/**') }}
restore-keys: |
${{ runner.os }}-libs-libec
- name: Cache ed25519-zebra static lib
uses: actions/cache@v5
with:
path: .lib/libed25519_zebra_ffi.a
key: ${{ runner.os }}-libs-libed25519-${{ hashFiles('Utils/Sources/ed25519-zebra/**') }}
restore-keys: |
${{ runner.os }}-libs-libed25519
- name: Setup Rust
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Build native dependencies
run: make deps
- name: Build (Debug)
if: matrix.config == 'debug'
run: make build
- name: Test (Debug)
if: matrix.config == 'debug'
run: |
# Run all tests except FuzzTests (they run in a separate parallel job)
for pkg in Blockchain Codec Database JAMTests Networking Node PolkaVM RPC Utils; do
echo "Testing $pkg (debug)..."
if [ "$pkg" = "JAMTests" ]; then
# Skip FuzzTests for JAMTests as they run in a separate parallel job
swift test --package-path "$pkg" --skip "FuzzTests"
else
swift test --package-path "$pkg"
fi
done
cargo test --manifest-path Utils/Sources/bandersnatch/Cargo.toml
- name: Build and Test (Release)
if: matrix.config == 'release'
run: |
for pkg in Blockchain Codec Database JAMTests Networking Node PolkaVM RPC Utils; do
echo "Testing $pkg (release)..."
if [ "$pkg" = "JAMTests" ]; then
# Skip FuzzTests for JAMTests as they run in a separate parallel job
swift test -c release --package-path "$pkg" --skip "FuzzTests"
else
swift test -c release --package-path "$pkg"
fi
done
cargo test --manifest-path Utils/Sources/bandersnatch/Cargo.toml --release
fuzz-test:
name: Fuzz Test (${{ matrix.mode }})
runs-on: [self-hosted, linux]
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode:
- interpreter
- sandbox
- jit
- jit-sandbox
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
submodules: recursive
- run: sudo apt-get update
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: librocksdb-dev libzstd-dev libbz2-dev liblz4-dev libjemalloc-dev
- uses: aws-actions/configure-aws-credentials@v6
with:
aws-region: us-east-2
- name: Setup Swift
uses: SwiftyLab/setup-swift@latest
- name: Get Swift Version
id: swift-version
run: |
SWIFT_VERSION=$(swift --version 2>&1 | head -n1 | sed -E 's/.*Swift version ([0-9.]+).*/\1/')
echo "Detected Swift version: $SWIFT_VERSION"
echo "version=$SWIFT_VERSION" >> $GITHUB_OUTPUT
- name: Cache Cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Cache bandersnatch_vrfs static lib
uses: actions/cache@v5
with:
path: .lib/libbandersnatch_vrfs.a
key: ${{ runner.os }}-libs-libbandersnatch-${{ hashFiles('Utils/Sources/bandersnatch/**') }}
restore-keys: |
${{ runner.os }}-libs-libbandersnatch
- name: Cache bls static lib
uses: actions/cache@v5
with:
path: .lib/libbls.a
key: ${{ runner.os }}-libs-libbls-${{ hashFiles('Utils/Sources/bls/**') }}
restore-keys: |
${{ runner.os }}-libs-libbls
- name: Cache erasure-coding static lib
uses: actions/cache@v5
with:
path: .lib/libec.a
key: ${{ runner.os }}-libs-libec-${{ hashFiles('Utils/Sources/erasure-coding/**') }}
restore-keys: |
${{ runner.os }}-libs-libec
- name: Cache ed25519-zebra static lib
uses: actions/cache@v5
with:
path: .lib/libed25519_zebra_ffi.a
key: ${{ runner.os }}-libs-libed25519-${{ hashFiles('Utils/Sources/ed25519-zebra/**') }}
restore-keys: |
${{ runner.os }}-libs-libed25519
- name: Setup Rust
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- name: Build native dependencies
run: make deps
- name: Run Fuzz Tests (${{ matrix.mode }})
run: |
# Set test filter based on mode
case "${{ matrix.mode }}" in
interpreter)
TEST_FILTER="FuzzTests.v072_interpreter"
;;
sandbox)
TEST_FILTER="FuzzTests.v072_sandbox"
;;
jit)
TEST_FILTER="FuzzTests.v072_jit"
;;
jit-sandbox)
TEST_FILTER="FuzzTests.v072_jit_sandbox"
;;
esac
echo "Running fuzz tests for mode: ${{ matrix.mode }}"
echo "Test filter: $TEST_FILTER"
# Run only the fuzz tests for this specific mode
swift test -c release --package-path JAMTests --filter "$TEST_FILTER"