Skip to content

Commit

Permalink
Improve CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aon committed Aug 16, 2023
1 parent f538390 commit 972931b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 36 deletions.
73 changes: 37 additions & 36 deletions .github/workflows/general-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,48 +21,49 @@ env:
CARGO_TERM_COLOR: always

jobs:
# test:
# name: Test
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3

# - name: Cache cargo-scout dependencies
# id: cache-cargo-scout-dependencies
# uses: actions/cache@v3
# with:
# path: ./apps/cargo-scout-audit/target
# key: ${{ runner.os }}-cargo-${{ hashFiles('apps/cargo-scout-audit/Cargo.lock') }}

# - name: Cache other dependencies
# id: cache-other-dependencies
# uses: actions/cache@v3
# with:
# path: |
# ~/.cargo/registry
# ~/.cargo/git
# ./detectors/**/target
# ./test-cases/**/target
# key: ${{ runner.os }}-other-dependencies
scout-audit-test:
name: Test Scout Audit
runs-on: ubuntu-latest
strategy:
matrix:
test: ["panic-error"]
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Cache cargo-scout dependencies
id: cache-cargo-scout-dependencies
uses: actions/cache@v3
with:
path: ./apps/cargo-scout-audit/target
key: ${{ runner.os }}-cargo-${{ hashFiles('apps/cargo-scout-audit/Cargo.lock') }}

- name: Cache other dependencies
id: cache-other-dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-other-dependencies

# - name: Update Rust
# run: rustup update
- name: Update Rust
run: rustup update

# - name: Install Rust nightly-2023-01-27
# run: rustup install nightly-2023-01-27 --profile minimal
- name: Install Rust nightly-2023-01-27
run: rustup install nightly-2023-01-27 --profile minimal

# - name: Install Rust nightly-2023-04-23
# run: rustup install nightly-2023-04-23 --profile minimal
- name: Install Rust nightly-2023-04-23
run: rustup install nightly-2023-04-23 --profile minimal

# - name: Install dylint-link
# run: cargo install dylint-link
- name: Install dylint-link
run: cargo install dylint-link

# - name: Install cargo-scout
# run: cargo install --path apps/cargo-scout-audit
- name: Install cargo-scout
run: cargo install --path apps/cargo-scout-audit

# - name: Run cargo test
# run: make test
- name: Run tests
run: INTEGRATION_TESTS_TO_RUN=${{ matrix.test }} cargo test -- --nocapture

fmt:
name: Rustfmt
Expand Down
11 changes: 11 additions & 0 deletions apps/cargo-scout-audit/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,22 @@ fn test() {
print_cargo_scout_not_found()
);

// Get environment variable to determine integration tests to run
let integration_tests_to_run = std::env::var("INTEGRATION_TESTS_TO_RUN")
.ok()
.map(|e| e.split(',').map(|s| s.to_string()).collect::<Vec<String>>());

// Get the configuration
let configuration = get_configuration()
.unwrap_or_else(|_| panic!("{}", "Failed to get the configuration".red().to_string()));

for (detector_name, detector_config) in configuration.detectors.iter() {
if let Some(integration_tests_to_run) = &integration_tests_to_run {
if !integration_tests_to_run.contains(&detector_name) {
continue;
}
}

println!("\n{} {}", "Running detector:".bright_cyan(), detector_name);
for example in detector_config.examples.iter() {
execute_and_validate_example(
Expand Down

0 comments on commit 972931b

Please sign in to comment.