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

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
72 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
7fde1e7
Cache devnet on Windows
cptartur Dec 3, 2024
e3164ab
Fix path to devnet
cptartur Dec 3, 2024
3bb66d7
Make hard_test harder
cptartur Dec 3, 2024
4135145
Add missing ```
cptartur Dec 3, 2024
f95d30f
Build devnet cache
cptartur Dec 4, 2024
5085d32
Uncomment tests
cptartur Dec 4, 2024
023f4fa
Remove steps running non-existent test
cptartur Dec 4, 2024
000aa1d
Add newline to .gitattributes
cptartur Dec 5, 2024
10faf23
Use proper cfg for windows
cptartur Dec 5, 2024
10dde82
Restore tests order
cptartur Dec 5, 2024
b9527aa
Disable whole modules on windows
cptartur Dec 5, 2024
d9cefbc
Update asserts
cptartur Dec 5, 2024
c5f45ec
Add missing newline to install_devnet.ps1
cptartur Dec 5, 2024
84f40bf
Run profiler only on not windows
cptartur Dec 5, 2024
409eeab
Remove os specific asserts
cptartur Dec 5, 2024
34178da
Remove unnecessary profiler installation
cptartur Dec 9, 2024
92c025b
Mention trace file changes in CHANGELOG.md
cptartur Dec 9, 2024
833320c
Remove unnecessary todo
cptartur Dec 9, 2024
1a51b13
Use revision instead of tag
cptartur Dec 9, 2024
e9e18ed
Restore OS specific errors for files
cptartur Dec 10, 2024
04637a9
Lint, use reference
cptartur Dec 10, 2024
cbefce3
Fix windows error
cptartur Dec 10, 2024
e351f64
Fix windows error
cptartur Dec 10, 2024
0112d70
Use devnet revision on ci
cptartur Dec 10, 2024
aa534d1
Remove comments
cptartur Dec 10, 2024
91d8ec5
Update .github/workflows/ci.yml
cptartur Dec 10, 2024
8c209cc
Remove unnecessary test step
cptartur Dec 13, 2024
f641187
Merge branch 'master' into 2716-run-tests-on-windows
cptartur Dec 13, 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
67 changes: 52 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: CI

env:
DEVNET_TAG: "v0.2.2"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use commit hash because it is immutable, unlike a tag which is mutable therefore could theoretically pose some risk.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to be changed 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated here as well

on:
pull_request:
merge_group:
Expand All @@ -11,7 +14,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,56 +29,69 @@ jobs:
- run: cargo test --release integration -p forge

cptartur marked this conversation as resolved.
Show resolved Hide resolved
build-test-forge-e2e-nextest-archive:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
ddoktorski marked this conversation as resolved.
Show resolved Hide resolved
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 +103,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 +207,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
franciszekjob marked this conversation as resolved.
Show resolved Hide resolved
- 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_TAG }}
- 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 --tag ${{ env.DEVNET_TAG }} --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 +263,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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ 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 `::`

### `snforge_scarb_plugin`

#### Changed
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("::", "_"));
ddoktorski marked this conversation as resolved.
Show resolved Hide resolved
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
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
Loading
Loading