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 all tests on Windows #356

Merged
merged 6 commits into from
May 3, 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
3 changes: 3 additions & 0 deletions .github/workflows/00-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
uses: './.github/workflows/02-coverage.yml'
with:
os: 'windows-latest'
secrets:
NPCAP_OEM_PASSWORD: ${{ secrets.NPCAP_OEM_PASSWORD }}
NPCAP_OEM_USERNAME: ${{ secrets.NPCAP_OEM_USERNAME }}

windows-lint-stable:
uses: './.github/workflows/03-lint.yml'
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/01-build-and-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ env:
RUST_BACKTRACE: 1
CARGO_TERM_VERBOSE: true
CARGO_TERM_COLOR: always
PCAP_CI_TEST_TARGETS: ${{ (github.event_name == 'pull_request') && '--lib' || '--all-targets' }}

jobs:
build-and-test:
Expand All @@ -44,18 +45,17 @@ jobs:
rustup override set ${{ inputs.toolchain }}
- if: inputs.msrv
run: cp msrv.lock Cargo.lock
# Until #275 is resolved, we will not run integration tests on Windows. Note that since
# secrets are not passed to workflows triggered by a pull request from a fork, it will still
# not be possible to run integration tests on pull requests.
# Note that since secrets are not passed to workflows triggered by a pull request from a fork,
# it is not possible to run integration tests on pull requests.
- run: cargo build --all-targets
- run: cargo test --lib
- run: cargo build --all-targets --release
- run: cargo test --lib --release
- run: cargo test ${{ env.PCAP_CI_TEST_TARGETS }}
- run: cargo build --all-targets --release
- run: cargo test ${{ env.PCAP_CI_TEST_TARGETS }} --release
- if: ${{ ! inputs.msrv }}
run: cargo build --all-targets --all-features
run: cargo build --all-targets --all-features
- if: ${{ ! inputs.msrv}}
run: cargo test --lib --all-features
run: cargo test ${{ env.PCAP_CI_TEST_TARGETS }} --all-features
- if: ${{ ! inputs.msrv }}
run: cargo build --all-targets --release --all-features
run: cargo build --all-targets --release --all-features
- if: ${{ ! inputs.msrv}}
run: cargo test --lib --release --all-features
run: cargo test ${{ env.PCAP_CI_TEST_TARGETS }} --release --all-features
22 changes: 14 additions & 8 deletions .github/workflows/02-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ on:
os:
required: true
type: string
secrets:
NPCAP_OEM_PASSWORD:
required: false
NPCAP_OEM_USERNAME:
required: false

env:
RUST_BACKTRACE: 1
CARGO_TERM_VERBOSE: true
CARGO_TERM_COLOR: always
PCAP_CI_TEST_TARGETS: ${{ contains(inputs.os, 'windows') && (github.event_name == 'pull_request') && '--lib' || '--all-targets' }}
PCAP_CI_GRCOV_CMD: >-
${{ contains(inputs.os, 'windows') && 'C:/grcov' || './grcov' }}
target/debug/profraw
Expand Down Expand Up @@ -45,6 +51,12 @@ jobs:
Invoke-WebRequest -Uri "https://npcap.com/dist/npcap-sdk-1.13.zip" -OutFile "C:/npcap-sdk.zip"
Expand-Archive -LiteralPath C:/npcap-sdk.zip -DestinationPath C:/npcap-sdk
echo "LIB=C:/npcap-sdk/Lib/x64" >> $env:GITHUB_ENV
- if: ${{ contains(inputs.os, 'windows') && (github.event_name != 'pull_request') }}
run: |
$SecPassword = ConvertTo-SecureString "${{ secrets.NPCAP_OEM_PASSWORD }}" -AsPlainText -Force
$CredObject = New-Object System.Management.Automation.PSCredential ("${{ secrets.NPCAP_OEM_USERNAME }}", $SecPassword)
Invoke-WebRequest -Uri "https://npcap.com/oem/dist/npcap-1.71-oem.exe" -OutFile C:/npcap-oem.exe -Credential $CredObject
C:/npcap-oem.exe /S
# No installation of actuall library since we cannot install OEM pcap on pull request branches
# anyway. We'll just be running unit tests on Windows. No integration tests.
- run: |
Expand All @@ -64,10 +76,7 @@ jobs:
Invoke-WebRequest -Uri "https://github.com/mozilla/grcov/releases/latest/download/grcov-x86_64-pc-windows-msvc.zip" -OutFile C:/grcov.zip
Expand-Archive -LiteralPath C:/grcov.zip -DestinationPath C:/
# Coverage without features.
- if: ${{ contains(inputs.os, 'windows') }}
run: cargo test --lib --no-fail-fast
- if: ${{ ! contains(inputs.os, 'windows') }}
run: cargo test --all-targets --no-fail-fast
- run: cargo test ${{ env.PCAP_CI_TEST_TARGETS }} --no-fail-fast
- run: ${{ env.PCAP_CI_GRCOV_CMD }}
- run: ${{ env.PCAP_CI_COV_CMD }} --fail-under ${{ env.PCAP_CI_COV_FAIL_UNDER_NO_FEATURES }}
# Clean up coverage artifacts.
Expand All @@ -79,10 +88,7 @@ jobs:
run: rm -rf ./target/debug/{coverage,profraw}
- run: cargo clean -p pcap
# Coverage with features.
- if: ${{ contains(inputs.os, 'windows') }}
run: cargo test --lib --all-features --no-fail-fast
- if: ${{ ! contains(inputs.os, 'windows') }}
run: cargo test --all-targets --all-features --no-fail-fast
- run: cargo test ${{ env.PCAP_CI_TEST_TARGETS }} --all-features --no-fail-fast
- run: ${{ env.PCAP_CI_GRCOV_CMD }}
- run: ${{ env.PCAP_CI_COV_CMD }} --fail-under ${{ env.PCAP_CI_COV_FAIL_UNDER_ALL_FEATURES }}
# On push to main push results to coverage branch.
Expand Down