Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Use Cargo.lock for all crates #1891

Merged
merged 20 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/bin/bash

# This hook ensures that code formatting is good before allowing you to commit.
# Install me by running: `cp .githooks/pre-commit .git/hooks`
# Remove me by running: `rm .git/hooks/pre-commit`
set -e

cd "$(dirname "$0")"

echo "Running code format check...If it stops you from committing, try running script './format.sh' first"
echo "[PRE-COMMIT] Formatting assertion"

../check.sh
../../check.sh --quiet || { echo "[PRE-COMMIT] Formatting check FAIL: Committing aborted"; exit 1; }

echo "[PRE-COMMIT] Formatting check PASS"
6 changes: 6 additions & 0 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ runs:
- name: Install Rust toolchain
uses: RDXWorks-actions/toolchain@master
with:
# IMPORTANT: If you update this Rust version:
# * Ensure you also update it in the README in two places:
# - "Install Rust - we recommend to use Rust XXXX"
# - "rustup default XXXX"
# * Ensure you update the version in the "radix-clis-scrypto-coverage" step,
# or update the comment explaining why a different version is used.
toolchain: 1.80.1
default: true
target: wasm32-unknown-unknown
Expand Down
84 changes: 53 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ on:
- main
- develop
- docs
- alphanet
- betanet
- develop\/*
- release\/*
pull_request:

env:
CARGO_TERM_COLOR: always
SCRYPTO_CARGO_LOCKED: 1

concurrency:
group: ci-${{ github.ref }}
Expand Down Expand Up @@ -55,11 +55,11 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run tests
run: cargo nextest run -p sbor --no-fail-fast
run: cargo nextest run -p sbor --no-fail-fast --locked
- name: Run tests (no_std)
run: cargo nextest run -p sbor --no-default-features --features alloc --no-fail-fast
run: cargo nextest run -p sbor --no-default-features --features alloc --no-fail-fast --locked
- name: Run derive tests
run: cargo nextest run -p sbor-derive-common --no-fail-fast
run: cargo nextest run -p sbor-derive-common --no-fail-fast --locked

sbor-integration-tests:
name: Run SBOR integration tests
Expand All @@ -69,11 +69,11 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run tests
run: cargo nextest run -p sbor-tests --no-fail-fast
run: cargo nextest run -p sbor-tests --no-fail-fast --locked
- name: Run tests (no_std)
run: cargo nextest run -p sbor-tests --no-default-features --features alloc --no-fail-fast
run: cargo nextest run -p sbor-tests --no-default-features --features alloc --no-fail-fast --locked
- name: Run bench
run: cargo bench -p sbor-tests
run: cargo bench -p sbor-tests --locked

scrypto-tests:
name: Run Scrypto tests
Expand All @@ -83,13 +83,13 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run tests
run: cargo nextest run -p scrypto --no-fail-fast
run: cargo nextest run -p scrypto --no-fail-fast --locked
- name: Run tests (no_std)
run: cargo nextest run -p scrypto --no-default-features --features alloc --no-fail-fast
run: cargo nextest run -p scrypto --no-default-features --features alloc --no-fail-fast --locked
- name: Run abi tests
run: cargo nextest run -p radix-blueprint-schema-init --no-fail-fast
run: cargo nextest run -p radix-blueprint-schema-init --no-fail-fast --locked
- name: Run derive tests
run: cargo nextest run -p scrypto-derive --no-fail-fast
run: cargo nextest run -p scrypto-derive --no-fail-fast --locked

scrypto-derive-tests:
name: Run Scrypto derive tests
Expand All @@ -99,9 +99,29 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run tests
run: cargo nextest run -p scrypto-derive-tests --no-fail-fast
run: cargo nextest run -p scrypto-derive-tests --no-fail-fast --locked
- name: Run tests with no_std
run: cargo nextest run -p scrypto-derive-tests --no-default-features --features alloc --no-fail-fast
run: cargo nextest run -p scrypto-derive-tests --no-default-features --features alloc --no-fail-fast --locked

scrypto-compiler-tests:
name: Run Scrypto compiler tests
runs-on: ubuntu-latest
steps:
- uses: RDXWorks-actions/checkout@main
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run tests
run: cargo nextest run -p scrypto-compiler --no-fail-fast --locked

radix-engine-toolkit-tests:
name: Run Radix Engine Toolkit tests
runs-on: ubuntu-latest
steps:
- uses: RDXWorks-actions/checkout@main
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run tests
run: cargo nextest run -p radix-engine-toolkit --no-fail-fast --locked

scrypto-examples:
name: Run Scrypto examples
Expand All @@ -112,16 +132,16 @@ jobs:
uses: ./.github/actions/setup-env
- name: Build and test hello-world
run: |
cargo build --target wasm32-unknown-unknown --release
cargo nextest run --release --no-fail-fast
cargo build --target wasm32-unknown-unknown --release --locked
cargo nextest run --release --no-fail-fast --locked
working-directory: examples/hello-world
- name: Build and test everything
run: |
cargo build --target wasm32-unknown-unknown --release
cargo nextest run --release --no-fail-fast
cargo build --target wasm32-unknown-unknown --release --locked
cargo nextest run --release --no-fail-fast --locked
working-directory: examples/everything
- name: Build no-std
run: cargo build --target wasm32-unknown-unknown --release
run: cargo build --target wasm32-unknown-unknown --release --locked
working-directory: examples/no-std

scrypto-stubs:
Expand All @@ -147,7 +167,7 @@ jobs:
- name: Install dependency
run: sudo apt-get -y update && sudo apt-get -y install pkg-config libfreetype6-dev libfontconfig1-dev
- name: Build with additional features
run: cargo build -p radix-engine -p radix-substate-store-impls --features radix-engine/resource_tracker,radix-engine/cpu_ram_metrics,radix-substate-store-impls/rocksdb
run: cargo build -p radix-engine -p radix-substate-store-impls --features radix-engine/resource_tracker,radix-engine/cpu_ram_metrics,radix-substate-store-impls/rocksdb --locked

radix-engine-test:
name: Run Radix Engine tests
Expand All @@ -164,7 +184,7 @@ jobs:
-p radix-engine-interface \
-p radix-engine \
-p radix-engine-tests \
--no-fail-fast
--no-fail-fast --locked
./check_stack_usage.sh

radix-engine-release:
Expand All @@ -188,7 +208,7 @@ jobs:
-p radix-engine-interface \
-p radix-engine \
-p radix-engine-tests \
--no-fail-fast
--no-fail-fast --locked

radix-engine-no-std:
name: Run Radix Engine tests (no_std)
Expand All @@ -207,7 +227,7 @@ jobs:
-p radix-engine-interface \
-p radix-engine \
-p radix-engine-tests \
--no-fail-fast
--no-fail-fast --locked

radix-engine-bench:
name: Run Radix Engine benchmarks
Expand All @@ -217,7 +237,7 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run bench
run: cargo bench
run: cargo bench --locked
working-directory: radix-engine-tests

radix-common-bench:
Expand All @@ -228,7 +248,7 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run bench
run: cargo bench
run: cargo bench --locked
working-directory: radix-common

radix-transactions:
Expand All @@ -239,7 +259,7 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run tests
run: cargo nextest run -p radix-transactions --no-fail-fast
run: cargo nextest run -p radix-transactions --no-fail-fast --locked

radix-transaction-scenarios:
name: Run transaction scenarios
Expand All @@ -249,7 +269,7 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Run tests
run: cargo nextest run -p radix-transaction-scenarios --no-fail-fast
run: cargo nextest run -p radix-transaction-scenarios --no-fail-fast --locked

radix-clis:
name: Run CLI tests
Expand All @@ -271,7 +291,7 @@ jobs:
cache-directories: ~/.cargo/registry/src/**/librocksdb-sys-*
workspaces: radix-clis
- name: Run Unit tests
run: cargo nextest run --no-fail-fast
run: cargo nextest run --no-fail-fast --locked
working-directory: radix-clis
- name: Run resim shell tests
run: bash ./tests/resim.sh
Expand Down Expand Up @@ -316,6 +336,8 @@ jobs:
shared-key: radix-clis-debug-${{ runner.os }}
cache-directories: ~/.cargo/registry/src/**/librocksdb-sys-*
workspaces: radix-clis
# Coverage needs a nightly compiler.
# This should be at or in front of the default toolchain defined in action.yml
- name: Install rustc 1.81.0-nightly
run: |
rustup toolchain install nightly-2024-07-18
Expand Down Expand Up @@ -350,7 +372,7 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Cargo Check
run: cargo check --all
run: cargo check --all --locked

cargo-check-post-run-db-check:
name: Run cargo check with post run db check
Expand All @@ -363,7 +385,7 @@ jobs:
- name: Setup environment
uses: ./.github/actions/setup-env
- name: Cargo Check
run: cargo check --all --features post_run_db_check
run: cargo check --all --features post_run_db_check --locked

determinism-test:
name: Run determinism test
Expand All @@ -381,7 +403,7 @@ jobs:
run: git lfs pull
- name: Replay transactions
run: |
cargo run --release --bin replay -- \
cargo run --release --locked --bin replay -- \
execute-in-memory ../assets-lfs/babylon-mainnet-transactions-2023-10-11.tar.gz \
--max-version 50000 \
--breakpoints 10:91850a10dad5ec6d9a974663e87243b3f3ff8f8b1c0dd74135e8ddd097aa6276,100:8ac9b0caf4daad6f821038f325b215932e90fbabce089ca42bc0330c867aa8f8,1000:6b621e9c7f9674c3d71832aec822b695b0e90010dc6158a18e43fbacf296ef69,500000:7dd4403a757f43f4a885e914b8dc38086fdbaf96082fa90067acf1500075e85d
Expand Down
37 changes: 21 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,40 @@ target/

# CARGO.LOCK - Source controlling strategy
#
# We have multiple workspaces/crates in this repository:
# We have multiple workspaces/crates in this repository, with different Cargo.lock strategies.
#
# TYPE 1:
# - The root workspace of libraries. As per docs in below link, libraries shouldn't have Cargo.lock source controlled.
# The Cargo.lock of packages is ignored anyway by crates pulling them in.
# https://doc.rust-lang.org/cargo/faq.html#why-do-binaries-have-cargolock-in-version-control-but-not-libraries
Cargo.lock
# First off - let's blanket ignore all Cargo.lock files, so any old/historic ones stay ignored,
# to try to limit the amount of git breakage which will occur when we start to source control
# these
!Cargo.lock

# TYPE 2:
# - The radix-clis workspace/package. This is an application, and so has its Cargo.lock source controlled
!radix-clis/Cargo.lock
# TYPE 1:
# - The root workspace of libraries.
# As of August 2024, and a change in the Rust guidance around lock files for libraries
# (see https://blog.rust-lang.org/2023/08/29/committing-lockfiles.html), we now source control our
# Cargo.lock file.
# This allows our builds to be more reducible, and is a partial mitigation against supply chain attacks.
# However, this is possibly at the expense of Scrypto users who will have their own Cargo.locks.
# So we may wish to add a CI job to build against the latest versions, as per:
# https://doc.rust-lang.org/cargo/guide/continuous-integration.html#verifying-latest-dependencies
!/Cargo.lock

# TYPE 3:
# - Examples should have their own Cargo.lock files to show good practice
!examples/**/Cargo.lock


# TYPE 4:
# - The asset scrypto packages. These need to be built deterministically, so include a Cargo.lock (at a shared workspace layer)
# But also keep blanket ignoring all the old Cargo.locks before they moved to blueprints, to avoid developer git issues
!radix-engine/assets/**/Cargo.lock
!radix-transaction-scenarios/assets/**/Cargo.lock
!scrypto-test/assets/**/Cargo.lock
!radix-engine/assets/blueprints/Cargo.lock
!radix-transaction-scenarios/assets/blueprints/Cargo.lock

# TYPE 5:
# - Various test scrypto packages. We don't care too much about either way - but we do want CI to run without a lock, so let's git ignore these.
# Also make sure to blanket ignore all the old Cargo.locks before they moved to blueprints, to avoid developer git issues
radix-engine-tests/**/Cargo.lock
radix-clis/tests/**/Cargo.lock
!scrypto-test/assets/blueprints/Cargo.lock
!scrypto-test/tests/blueprints/Cargo.lock
!radix-engine-tests/assets/blueprints/Cargo.lock
!radix-clis/tests/blueprints/Cargo.lock

# FURTHER DETAILS:
# Our CI tests ensure that libraries can build and have their tests run with an empty lock file (ie, with the latest semver
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"rust-analyzer.linkedProjects": [
"Cargo.toml",
"radix-clis/Cargo.toml",
],
"cSpell.words": [
"accesscontroller",
Expand Down
Loading
Loading