Skip to content

Commit

Permalink
Run some checks on windows (#2730)
Browse files Browse the repository at this point in the history
<!-- Reference any GitHub issues resolved by this PR -->

Closes #2716 

## Introduced changes

<!-- A brief description of the changes -->

-

## Checklist

<!-- Make sure all of these are complete -->

- [ ] Linked relevant issue
- [ ] Updated relevant documentation
- [ ] Added relevant tests
- [ ] Performed self-review of the code
- [ ] Added changes to `CHANGELOG.md`

---------

Co-authored-by: Franciszek Job <[email protected]>
  • Loading branch information
cptartur and franciszekjob authored Jan 10, 2025
1 parent 2d9b28f commit 7ebb054
Show file tree
Hide file tree
Showing 31 changed files with 296 additions and 80 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.* text eol=lf
68 changes: 52 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: CI

env:
DEVNET_REV: ef789b700770fa27a2fc057b3d1c610771be27d9

on:
pull_request:
merge_group:
Expand All @@ -11,68 +14,83 @@ on:
jobs:
test-forge-unit-and-integration:
name: Test Forge / Unit and Integration Tests
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab
- uses: software-mansion/setup-scarb@v1
- uses: software-mansion/setup-universal-sierra-compiler@v1
- run: cargo test --release --lib -p forge
- run: cargo test --release --bin snforge
- run: cargo test --release integration -p forge

build-test-forge-e2e-nextest-archive:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest ]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Build and archive tests
run: cargo nextest archive --release -p forge --archive-file nextest-archive.tar.zst
run: cargo nextest archive --release -p forge --archive-file 'nextest-archive-${{ matrix.os }}.tar.zst'
- name: Upload archive to workflow
uses: actions/upload-artifact@v4
with:
name: nextest-archive
path: nextest-archive.tar.zst
name: nextest-archive-${{ matrix.os }}
path: nextest-archive-${{ matrix.os }}.tar.zst

test-forge-e2e:
name: Test Forge / E2E Tests
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
needs: build-test-forge-e2e-nextest-archive
strategy:
fail-fast: false
matrix:
partition: [ 1, 2, 3, 4, 5, 6, 7, 8 ]
os: [ ubuntu-latest, windows-latest ]
steps:
- name: Extract branch name
if: github.event_name != 'pull_request'
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
shell: bash

- name: Extract branch name on pull request
if: github.event_name == 'pull_request'
run: echo "BRANCH_NAME=$(echo $GITHUB_HEAD_REF)" >> $GITHUB_ENV
shell: bash

- name: Extract repo name and owner
if: github.event_name != 'pull_request'
run: echo "REPO_NAME=$(echo ${{ github.repository }}.git)" >> $GITHUB_ENV
shell: bash

- name: Extract repo name and owner on pull request
if: github.event_name == 'pull_request'
run: echo "REPO_NAME=$(echo ${{ github.event.pull_request.head.repo.full_name }}.git)" >> $GITHUB_ENV
shell: bash

- name: Print repo name
run: echo 'The repo name is' $REPO_NAME
shell: bash

- name: Get branch name
run: echo 'The branch name is' $BRANCH_NAME
shell: bash

- name: Install cairo-profiler
if: runner.os != 'Windows'
run: |
curl -L https://raw.githubusercontent.com/software-mansion/cairo-profiler/main/scripts/install.sh | sh
- name: Install cairo-coverage
if: runner.os != 'Windows'
run: |
curl -L https://raw.githubusercontent.com/software-mansion/cairo-coverage/main/scripts/install.sh | sh
Expand All @@ -84,9 +102,9 @@ jobs:
- uses: taiki-e/install-action@nextest
- uses: actions/download-artifact@v4
with:
name: nextest-archive
name: nextest-archive-${{ matrix.os }}
- name: nextest partition ${{ matrix.partition }}/8
run: cargo nextest run --partition 'count:${{ matrix.partition }}/8' --archive-file 'nextest-archive.tar.zst' e2e
run: cargo nextest run --no-fail-fast --partition 'count:${{ matrix.partition }}/8' --archive-file 'nextest-archive-${{ matrix.os }}.tar.zst' e2e

test-scarb-2-8-3:
name: Test scarb 2.8.3
Expand Down Expand Up @@ -188,23 +206,38 @@ jobs:

test-cast:
name: Test Cast
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a
with:
toolchain: stable
- uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab
- name: Install starknet-devnet-rs
run: ./scripts/install_devnet.sh
- name: Install starknet-devnet-rs on Linux/Macos
if: runner.os != 'Windows'
run: |
./scripts/install_devnet.sh
- name: Cache devnet build
if: runner.os == 'Windows'
id: windows-devnet-cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}\crates\sncast\tests\utils\devnet
key: ${{ runner.os }}-devnet-${{ env.DEVNET_REV }}
- name: Install devnet
if: runner.os == 'Windows' && steps.windows-devnet-cache.outputs.cache-hit != 'true'
run: |
$DEVNET_INSTALL_DIR = "${{ github.workspace }}\crates\sncast\tests\utils\devnet"
cargo install --git https://github.com/0xSpaceShard/starknet-devnet-rs.git --locked --rev ${{ env.DEVNET_REV }} --root $DEVNET_INSTALL_DIR
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.7.0"
- uses: software-mansion/setup-universal-sierra-compiler@v1
- name: Run tests
run: cargo test --release -p sncast
- name: Run test in debug profile
run: cargo test -p sncast test_happy_case_common_arguments_after_subcommand

test-conversions:
name: Test Conversions
Expand All @@ -229,7 +262,10 @@ jobs:

test-scarb-api:
name: Test Scarb Api
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Forge

#### Changed

- Trace files saved in `snfoundry_trace` directory will now use `_` as separators instead of `::`

### Cast

#### Added

- interactive interface that allows setting created or imported account as the default


## [0.35.1] - 2024-12-16

### Forge
Expand Down
12 changes: 11 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,4 @@ wiremock = "0.6.0"
const-hex = "1.14.0"
indicatif = "0.17.9"
shell-words = "1.1.0"
sanitize-filename = "0.6.0"
1 change: 1 addition & 0 deletions crates/forge-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ shared = { path = "../shared" }
universal-sierra-compiler-api = { path = "../universal-sierra-compiler-api" }
fs4.workspace = true
which.workspace = true
sanitize-filename.workspace = true
2 changes: 1 addition & 1 deletion crates/forge-runner/src/build_trace_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ fn build_profiler_trace_entry(value: &RelocatedTraceEntry) -> ProfilerTraceEntry
}

pub fn save_trace_data(
test_name: &String,
test_name: &str,
trace_data: &VersionedProfilerCallTrace,
) -> Result<PathBuf> {
let serialized_trace =
Expand Down
5 changes: 3 additions & 2 deletions crates/forge-runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ pub fn maybe_save_trace_and_profile(
}) = result
{
if execution_data_to_save.is_vm_trace_needed() {
let trace_path = save_trace_data(name, trace_data)?;
let name = sanitize_filename::sanitize(name.replace("::", "_"));
let trace_path = save_trace_data(&name, trace_data)?;
if execution_data_to_save.profile {
run_profiler(name, &trace_path, &execution_data_to_save.additional_args)?;
run_profiler(&name, &trace_path, &execution_data_to_save.additional_args)?;
}
return Ok(Some(trace_path));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use exit_first::fib;

#[test]
fn hard_test() {
fib(0, 1, 30344);
fib(0, 1, 99999999999999999999999);
assert(2 == 2, 'simple check');
}

Expand Down
10 changes: 6 additions & 4 deletions crates/forge/tests/e2e/build_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,35 @@ use super::common::runner::{setup_package, test_runner};
use forge_runner::profiler_api::PROFILE_DIR;

#[test]
#[cfg(not(target_os = "windows"))]
fn simple_package_build_profile() {
let temp = setup_package("simple_package");

test_runner(&temp).arg("--build-profile").assert().code(1);

assert!(temp
.join(PROFILE_DIR)
.join("simple_package::tests::test_fib.pb.gz")
.join("simple_package_tests_test_fib.pb.gz")
.is_file());
assert!(!temp
.join(PROFILE_DIR)
.join("simple_package_integrationtest::test_simple::test_failing.pb.gz")
.join("simple_package_integrationtest_test_simple_test_failing.pb.gz")
.is_file());
assert!(!temp
.join(PROFILE_DIR)
.join("simple_package::tests::ignored_test.pb.gz")
.join("simple_package_tests_ignored_test.pb.gz")
.is_file());
assert!(temp
.join(PROFILE_DIR)
.join("simple_package_integrationtest::ext_function_test::test_simple.pb.gz")
.join("simple_package_integrationtest_ext_function_test_test_simple.pb.gz")
.is_file());

// Check if it doesn't crash in case some data already exists
test_runner(&temp).arg("--build-profile").assert().code(1);
}

#[test]
#[cfg(not(target_os = "windows"))]
fn simple_package_build_profile_and_pass_args() {
let temp = setup_package("simple_package");

Expand Down
18 changes: 9 additions & 9 deletions crates/forge/tests/e2e/build_trace_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ fn simple_package_save_trace() {

assert!(temp
.join(TRACE_DIR)
.join("simple_package::tests::test_fib.json")
.join("simple_package_tests_test_fib.json")
.exists());
assert!(!temp
.join(TRACE_DIR)
.join("simple_package_integrationtest::test_simple::test_failing.json")
.join("simple_package_integrationtest_test_simple_test_failing.json")
.exists());
assert!(!temp
.join(TRACE_DIR)
.join("simple_package::tests::ignored_test.json")
.join("simple_package_tests_ignored_test.json")
.exists());
assert!(temp
.join(TRACE_DIR)
.join("simple_package_integrationtest::ext_function_test::test_simple.json")
.join("simple_package_integrationtest_ext_function_test_test_simple.json")
.exists());

let trace_data = fs::read_to_string(
temp.join(TRACE_DIR)
.join("simple_package_integrationtest::ext_function_test::test_simple.json"),
.join("simple_package_integrationtest_ext_function_test_test_simple.json"),
)
.unwrap();

Expand All @@ -56,7 +56,7 @@ fn trace_has_contract_and_function_names() {

let trace_data = fs::read_to_string(
temp.join(TRACE_DIR)
.join("trace_info_integrationtest::test_trace::test_trace.json"),
.join("trace_info_integrationtest_test_trace_test_trace.json"),
)
.unwrap();

Expand Down Expand Up @@ -103,7 +103,7 @@ fn trace_has_cairo_execution_info() {

let trace_data = fs::read_to_string(
temp.join(TRACE_DIR)
.join("trace_info_integrationtest::test_trace::test_trace.json"),
.join("trace_info_integrationtest_test_trace_test_trace.json"),
)
.unwrap();

Expand Down Expand Up @@ -145,7 +145,7 @@ fn trace_has_deploy_with_no_constructor_phantom_nodes() {

let trace_data = fs::read_to_string(
temp.join(TRACE_DIR)
.join("trace_info_integrationtest::test_trace::test_trace.json"),
.join("trace_info_integrationtest_test_trace_test_trace.json"),
)
.unwrap();

Expand Down Expand Up @@ -177,7 +177,7 @@ fn trace_is_produced_even_if_contract_panics() {

let trace_data = fs::read_to_string(
temp.join(TRACE_DIR)
.join("backtrace_panic::Test::test_contract_panics.json"),
.join("backtrace_panic_Test_test_contract_panics.json"),
)
.unwrap();

Expand Down
Loading

0 comments on commit 7ebb054

Please sign in to comment.