Repoint soroban-spec-tools to the moved one in stellar/soroban-rpc #4538
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust | |
on: | |
push: | |
branches: [main, release/**] | |
pull_request: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
complete: | |
if: always() | |
needs: [fmt, rust-analyzer-compat, build-and-test, publish-dry-run] | |
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 | |
rust-analyzer-compat: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- run: rustup update | |
- run: rustup +nightly component add rust-analyzer | |
- name: Check if rust-analyzer encounters any errors parsing project | |
run: rustup run nightly rust-analyzer analysis-stats . 2>&1 | (! grep '^\[ERROR') | |
build-and-test: | |
strategy: | |
fail-fast: false | |
matrix: | |
rust: [msrv, latest] | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
- os: windows-latest-8-cores | |
target: x86_64-pc-windows-msvc | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: stellar/actions/rust-cache@main | |
- name: Use the minimum supported Rust version | |
if: matrix.rust == 'msrv' | |
run: | | |
msrv="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages | map(.rust_version) | map(values) | min')" | |
rustup override set $msrv | |
rustup component add clippy --toolchain $msrv | |
- name: Error on warnings and clippy checks | |
# Only error on warnings and checks for the msrv, because new versions of | |
# Rust will frequently add new warnings and checks. | |
if: matrix.rust == 'msrv' | |
run: echo RUSTFLAGS='-Dwarnings -Dclippy::all -Dclippy::pedantic' >> $GITHUB_ENV | |
- run: rustup update | |
- run: cargo version | |
- run: rustup target add ${{ matrix.target }} | |
- run: rustup target add wasm32-unknown-unknown | |
- if: matrix.target == 'aarch64-unknown-linux-gnu' | |
run: sudo apt-get update && sudo apt-get -y install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu | |
- run: cargo clippy --all-targets --target ${{ matrix.target }} | |
- run: make build-test | |
- if: startsWith(matrix.target, 'x86_64') | |
# specify directories explicitly (otherwise it will fail with missing symbols) | |
run: | | |
for I in cmd/soroban-cli cmd/crates/* cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world ; do | |
cargo test --target ${{ matrix.target }} --manifest-path $I/Cargo.toml | |
done | |
publish-dry-run: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
defaults: | |
run: | |
shell: bash | |
env: | |
CARGO_BUILD_TARGET: x86_64-unknown-linux-gnu | |
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: stellar/actions/rust-cache@main | |
- run: rustup update | |
- run: rustup target add x86_64-unknown-linux-gnu | |
- uses: stellar/binaries@v18 | |
with: | |
name: cargo-hack | |
version: 0.5.28 | |
# Vendor all the dependencies into the vendor/ folder. Temporarily remove | |
# [patch.crates-io] entries in the workspace Cargo.toml that reference git | |
# repos. These will be removed when published. | |
- name: Vendor Dependencies | |
run: | | |
cp Cargo.toml Cargo.toml.bak | |
sed -r '/(git|rev) ?=/d' Cargo.toml.bak > Cargo.toml | |
cargo vendor --versioned-dirs | |
rm Cargo.toml | |
mv Cargo.toml.bak Cargo.toml | |
# Package the crates that will be published. Verification is disabled | |
# because we aren't ready to verify yet. Add each crate that was packaged to | |
# the vendor/ directory. | |
- name: Package Crates | |
run: | | |
for name in soroban-spec-json soroban-spec-typescript soroban-test soroban-cli | |
do | |
version=$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="'$name'") | .version') | |
cargo package \ | |
--no-verify \ | |
--package $name \ | |
--config "source.crates-io.replace-with = 'vendored-sources'" \ | |
--config "source.vendored-sources.directory = 'vendor'" | |
path="target/package/${name}-${version}.crate" | |
tar xvfz "$path" -C vendor/ | |
# Crates in the vendor directory require a checksum file, but it doesn't | |
# matter if it is empty. | |
echo '{"files":{}}' > vendor/$name-$version/.cargo-checksum.json | |
done | |
# Rerun the package command but with verification enabled this time. Tell | |
# cargo to use the local vendor/ directory as the source for all packages. Run | |
# the package command on the full feature powerset so that all features of | |
# each crate are verified to compile. | |
- name: Verify Crates | |
run: > | |
cargo-hack hack | |
--feature-powerset | |
--ignore-private | |
--config "source.crates-io.replace-with = 'vendored-sources'" | |
--config "source.vendored-sources.directory = 'vendor'" | |
package | |
--target x86_64-unknown-linux-gnu |