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

Run some checks on windows #2730

Draft
wants to merge 44 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ea31dd2
Run some checks on windows
cptartur Nov 29, 2024
3fb3906
Remove linux specific expected message
cptartur Nov 29, 2024
5ebc63a
Run 2.8.3 only on ubuntu-latest
cptartur Nov 29, 2024
b738f12
Ignore fork related integration tests on windows
cptartur Nov 29, 2024
a7e4b4b
Ignore fork related integration tests on windows
cptartur Nov 29, 2024
864818a
Do not run coverage and profiler tests on windows
cptartur Nov 29, 2024
6c7cb45
Add install_devnet.ps1
cptartur Nov 29, 2024
72fd826
Run install_devnet.ps1 on windows
cptartur Nov 29, 2024
f4e15ea
Fix nextest platform specific uploads
cptartur Nov 29, 2024
527325b
Always run step in bash
cptartur Nov 29, 2024
cccb52b
Change path on windows
cptartur Nov 29, 2024
49b9ab4
Fix path to platform
cptartur Nov 29, 2024
75dfa7d
Fix tag name in install_devnet.ps1
cptartur Nov 29, 2024
3a849d8
Du not run forking e2e tests in windows
cptartur Nov 29, 2024
462d546
Add `--no-fail-fast` to forge e2e tests
cptartur Nov 29, 2024
31ec41f
Add different installation steps for windows and Linux/macOS
cptartur Nov 29, 2024
198ba82
Always run e2e prep steps using bash
cptartur Dec 2, 2024
0221ce3
Disable `setup_fork::incompatible_abi` on windows
cptartur Dec 2, 2024
a6a9b5e
Merge branch 'master' into 2716-run-tests-on-windows
cptartur Dec 2, 2024
97b7eb0
Disable `cheat_fork::store_load_cairo0_contract` on windows
cptartur Dec 2, 2024
1945681
System specific devnet path
cptartur Dec 2, 2024
45c531d
System specific devnet killing
cptartur Dec 2, 2024
5c9100c
Fix windows devnet path
cptartur Dec 2, 2024
e3f49d9
Remove os specific error from `test_invalid_private_key_file_path`
cptartur Dec 2, 2024
6c73d27
Remove os specific error from `test_directory_non_existent`
cptartur Dec 2, 2024
0a3384d
Handle `.exe` in sncast name in `test_no_output_path_specified`
cptartur Dec 2, 2024
ee04138
Remove os specific error from `test_invalid_path`
cptartur Dec 2, 2024
6707dc7
Remove os specific path from `test_initialized_script_compiles`
cptartur Dec 2, 2024
ea8c9af
Use different scripts depending on the os
cptartur Dec 2, 2024
988d6d7
Use powershell on windows
cptartur Dec 2, 2024
fad159a
Fix powershell syntax
cptartur Dec 2, 2024
0b7af36
Remove unused constant
cptartur Dec 2, 2024
a2c3d0a
Use strings in `format!` directly
cptartur Dec 2, 2024
9dbfada
Sanitise file name for traces
cptartur Dec 2, 2024
a9eeefe
Merge branch 'master' into 2716-run-tests-on-windows
cptartur Dec 2, 2024
85dbaae
Replace `::` in file names
cptartur Dec 2, 2024
c5c994c
Disable fail-fast for matrix tests
cptartur Dec 2, 2024
4b2302f
Change trace related paths
cptartur Dec 3, 2024
8138b99
Remove os specific errors
cptartur Dec 3, 2024
115b2a7
Replace `::`
cptartur Dec 3, 2024
3924657
Force `lf` line endings on windows
cptartur Dec 3, 2024
f3cde99
Bypass powershell execution policy
cptartur Dec 3, 2024
3000fff
Force `lf` line endings on windows
cptartur Dec 3, 2024
e416b0c
Remove OS specific error
cptartur Dec 3, 2024
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.* text eol=lf
64 changes: 44 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ 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
Expand All @@ -23,58 +26,62 @@ jobs:
- 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

- name: Install cairo-profiler
run: |
curl -L https://raw.githubusercontent.com/software-mansion/cairo-profiler/main/scripts/install.sh | sh

- name: Install cairo-coverage
run: |
curl -L https://raw.githubusercontent.com/software-mansion/cairo-coverage/main/scripts/install.sh | sh
shell: bash

- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -84,9 +91,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 All @@ -104,8 +111,13 @@ jobs:
run: |
curl -L https://raw.githubusercontent.com/software-mansion/cairo-coverage/main/scripts/install.sh | sh

- name: Install cairo-profiler
run: |
curl -L https://raw.githubusercontent.com/software-mansion/cairo-profiler/main/scripts/install.sh | sh

- run: cargo test --package forge --features scarb_2_8_3 --test main e2e::coverage
- run: cargo test --package forge --features scarb_2_8_3 --test main e2e::backtrace
- run: cargo test --package forge --features scarb_2_8_3 --test main e2e::build_profile

test-coverage-error:
name: Test coverage error
Expand Down Expand Up @@ -188,15 +200,24 @@ 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: Install starknet-devnet-rs on Windows
if: runner.os == 'Windows'
run: |
powershell .\scripts\install_devnet.ps1
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.7.0"
Expand Down Expand Up @@ -229,7 +250,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
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 @@ -124,3 +124,4 @@ serde_path_to_error = "0.1.16"
wiremock = "0.6.0"
const-hex = "1.14.0"
indicatif = "0.17.9"
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 @@ -55,3 +55,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 @@ -307,7 +307,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 @@ -68,9 +68,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
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_attr(not(feature = "scarb_2_8_3"), ignore)]
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_attr(not(feature = "scarb_2_8_3"), ignore)]
fn simple_package_build_profile_and_pass_args() {
let temp = setup_package("simple_package");

Expand Down
16 changes: 8 additions & 8 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
4 changes: 2 additions & 2 deletions crates/forge/tests/e2e/io_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn file_reading() {
[FAIL] file_reading_integrationtest::test::json_non_existent

Failure data:
"No such file or directory [..]"
[..]

[FAIL] file_reading_integrationtest::test::invalid_json

Expand All @@ -31,7 +31,7 @@ fn file_reading() {
[FAIL] file_reading_integrationtest::test::non_existent

Failure data:
"No such file or directory [..]"
"[..] file [..]"

[FAIL] file_reading_integrationtest::test::non_ascii

Expand Down
2 changes: 2 additions & 0 deletions crates/forge/tests/e2e/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ mod coverage;
mod docs_snippets_validation;
mod env;
mod features;
#[cfg(not(target_os = "windows"))]
mod fork_warning;
#[cfg(not(target_os = "windows"))]
mod forking;
mod fuzzing;
mod io_operations;
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/tests/e2e/running.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ fn catch_runtime_errors() {
use snforge_std::fs::{FileTrait, read_txt};

#[test]
#[should_panic(expected: "No such file or directory (os error 2)")]
#[should_panic(expected: "file")]
fn catch_no_such_file() {
let file = FileTrait::new("no_way_this_file_exists");
let content = read_txt(@file);
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/tests/e2e/trace_resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn assert_resources_for_test(

fn deserialize_call_trace(test_name: &str, temp_dir: &TempDir) -> VersionedProfilerCallTrace {
let trace_data = fs::read_to_string(temp_dir.join(TRACE_DIR).join(format!(
"trace_resources_tests::{test_name}::{test_name}.json"
"trace_resources_tests_{test_name}_{test_name}.json"
)))
.unwrap();
serde_json::from_str(&trace_data).expect("Failed to parse call trace")
Expand Down
Loading
Loading