Skip to content

Add exit code check to workflow that tests with soroban-examples diff step #5379

Add exit code check to workflow that tests with soroban-examples diff step

Add exit code check to workflow that tests with soroban-examples diff step #5379

Workflow file for this run

name: Rust
on:
push:
branches: [main, release/**]
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref_protected == 'true' && github.sha || github.ref }}-{{ github.event_name }}
cancel-in-progress: true
env:
ARTIFACT_RETENTION_DAYS_FOR_TEST_WASMS: 7
defaults:
run:
shell: bash
jobs:
complete:
if: always()
needs: [fmt, check-git-rev-deps, semver-checks, build, test, build-fuzz, docs, readme, migration-docs]
runs-on: ubuntu-latest
steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update
- run: cargo fmt --all --check
cargo-deny:
runs-on: ubuntu-latest
strategy:
matrix:
checks:
- advisories
- bans licenses sources
# Prevent sudden announcement of a new advisory from failing ci:
continue-on-error: ${{ matrix.checks == 'advisories' }}
steps:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@b01e7a8cfb1f496c52d77361e84c1840d8246393
with:
command: check ${{ matrix.checks }}
check-git-rev-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-check-git-rev-deps@main
semver-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update
- uses: stellar/binaries@v45
with:
name: cargo-semver-checks
version: 0.44.0
- run: >
cargo semver-checks
--exclude soroban-meta
--exclude soroban-token-spec
--exclude stellar-asset-spec
build:
strategy:
fail-fast: false
matrix:
rust: [msrv, latest]
sys:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- os: macos-15-intel
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.sys.os }}
steps:
- uses: actions/checkout@v3
- name: Install minimum supported rust version
if: matrix.rust == 'msrv'
run: |
msrv="$(make msrv)"
rustup install $msrv
rustup component add --toolchain $msrv clippy rustfmt
rustup target add --toolchain $msrv ${{ matrix.sys.target }}
rustup target add --toolchain $msrv wasm32v1-none
- name: Install latest rust version
if: matrix.rust == 'latest'
run: |
rustup update
rustup target add ${{ matrix.sys.target }}
rustup target add wasm32v1-none
- name: Use the minimum supported rust version
if: matrix.rust == 'msrv'
run: echo RUSTUP_TOOLCHAIN="$(make msrv)" >> $GITHUB_ENV
- name: Set latest toolchain
if: matrix.rust == 'latest'
run: echo RUSTUP_TOOLCHAIN="$(rustup show active-toolchain | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: stellar/actions/rust-cache@main
- name: Error on warnings only for msrv
if: matrix.rust == 'msrv'
run: echo RUSTFLAGS='-Dwarnings' >> $GITHUB_ENV
- run: echo CARGO_BUILD_TARGET='${{ matrix.sys.target }}' >> $GITHUB_ENV
- uses: stellar/binaries@v45
with:
name: cargo-hack
version: 0.5.28
- run: cargo version
- run: make build-libs
- run: make build-test-wasms TEST_CRATES_RUSTUP_TOOLCHAIN=$RUSTUP_TOOLCHAIN
- name: Upload test wasms
uses: actions/upload-artifact@v4
with:
name: test-wasms-${{ matrix.rust }}-${{ matrix.sys.target }}
path: target/wasm32v1-none/release/test_*.wasm
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS_FOR_TEST_WASMS }}
test:
needs: build
strategy:
fail-fast: false
matrix:
rust: [msrv, latest]
sys:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- os: macos-15-intel
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.sys.os }}
steps:
- uses: actions/checkout@v3
- name: Install minimum supported rust version
if: matrix.rust == 'msrv'
run: |
msrv="$(make msrv)"
rustup install $msrv
rustup component add --toolchain $msrv clippy rustfmt
rustup target add --toolchain $msrv ${{ matrix.sys.target }}
rustup target add --toolchain $msrv wasm32v1-none
- name: Install latest rust version
if: matrix.rust == 'latest'
run: |
rustup update
rustup target add ${{ matrix.sys.target }}
rustup target add wasm32v1-none
- name: Use the minimum supported rust version
if: matrix.rust == 'msrv'
run: echo RUSTUP_TOOLCHAIN="$(make msrv)" >> $GITHUB_ENV
- name: Set latest toolchain
if: matrix.rust == 'latest'
run: echo RUSTUP_TOOLCHAIN="$(rustup show active-toolchain | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: stellar/actions/rust-cache@main
- name: Error on warnings only for msrv
if: matrix.rust == 'msrv'
run: echo RUSTFLAGS='-Dwarnings' >> $GITHUB_ENV
- run: echo CARGO_BUILD_TARGET='${{ matrix.sys.target }}' >> $GITHUB_ENV
- uses: stellar/binaries@v45
with:
name: cargo-hack
version: 0.5.28
- name: Restore test wasms for tests from one of the msrv builds
uses: actions/download-artifact@v5
with:
name: test-wasms-msrv-x86_64-unknown-linux-gnu
path: target/wasm32v1-none/release/
- name: Clear test snapshots for checking no diffs exists after test run
run: rm -fr **/test_snapshots
- run: cargo version
- run: make test-only
- name: Check no diffs exist
run: git add -N . && git diff HEAD --exit-code
build-fuzz:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup install nightly
- uses: stellar/binaries@v45
with:
name: cargo-fuzz
version: 0.13.1
- run: make build-fuzz
- name: Check no diffs exist
run: git add -N . && git diff HEAD --exit-code
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup install nightly
- run: make doc
- name: Check no diffs exist
run: git add -N . && git diff HEAD --exit-code
readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup install nightly
- run: make readme
- run: git add -N . && git diff HEAD --exit-code
migration-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup update
- run: |
version="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "soroban-sdk") | .version | split("\\.";"")[0] | "v"+.')"
git grep "${version}" -- soroban-sdk/src/_migrating.rs \
|| (echo "The _migrating ${version} section is missing." && exit 1)
expand-test-wasms:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: stellar/actions/rust-cache@main
- name: Install minimum supported rust version
run: |
msrv="$(make msrv)"
rustup install $msrv
rustup target add --toolchain $msrv wasm32v1-none
- uses: stellar/binaries@v45
with:
name: cargo-hack
version: 0.5.28
- uses: stellar/binaries@v45
with:
name: cargo-expand
version: 1.0.116
- run: make expand-tests
- name: Check no diffs exist
run: git add -N . && git diff HEAD --exit-code
publish-dry-run:
if: github.event_name == 'push' || startsWith(github.head_ref, 'release/')
strategy:
matrix:
sys:
- os: ubuntu-latest
target: wasm32v1-none
cargo-hack-feature-options: --manifest-path Cargo.toml --exclude soroban-meta --exclude soroban-spec --exclude soroban-spec-rust --exclude soroban-ledger-snapshot --exclude-features testutils,docs,default,std --feature-powerset
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
cargo-hack-feature-options: '--feature-powerset --exclude-features docs'
uses: stellar/actions/.github/workflows/rust-publish-dry-run.yml@main
with:
runs-on: ${{ matrix.sys.os }}
target: ${{ matrix.sys.target }}
cargo-hack-feature-options: ${{ matrix.sys.cargo-hack-feature-options }}