|
1 | 1 | name: Rust
|
2 |
| - |
3 |
| -on: |
4 |
| - push: |
5 |
| - branches: [ "master", "dev" ] |
6 |
| - pull_request: |
7 |
| - branches: [ "master", "dev" ] |
8 |
| - |
| 2 | +on: [push, pull_request] |
9 | 3 | env:
|
10 | 4 | CARGO_TERM_COLOR: always
|
11 | 5 |
|
12 | 6 | jobs:
|
13 | 7 | build:
|
14 |
| - |
15 |
| - runs-on: ubuntu-latest |
| 8 | + env: |
| 9 | + NPCAP_SDK_URL: "https://npcap.com/dist/npcap-sdk-1.15.zip" |
16 | 10 | strategy:
|
17 | 11 | matrix:
|
18 |
| - toolchain: |
19 |
| - - nightly |
| 12 | + os: [ubuntu-latest, windows-latest] |
| 13 | + runs-on: ${{ matrix.os }} |
20 | 14 | steps:
|
21 |
| - - uses: actions/checkout@v4 |
22 |
| - - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} |
23 |
| - - name: Build |
24 |
| - run: cargo build --verbose |
25 |
| - - name: Build for release |
26 |
| - run: cargo build --release --verbose |
27 |
| - - name: Run tests |
28 |
| - run: cargo test --verbose |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + - name: Set up Rust |
| 17 | + uses: dtolnay/rust-toolchain@nightly |
| 18 | + - name: Cache Windows dependencies |
| 19 | + if: matrix.os == 'windows-latest' |
| 20 | + id: cache-windows |
| 21 | + uses: actions/cache@v4 |
| 22 | + with: |
| 23 | + key: ${{ env.NPCAP_SDK_URL }} |
| 24 | + path: .\Packet.lib |
| 25 | + - name: Install Windows dependencies |
| 26 | + if: matrix.os == 'windows-latest' && steps.cache-windows.outputs.cache-hit != 'true' |
| 27 | + shell: pwsh |
| 28 | + run: | |
| 29 | + $sdkPath = ".\tmp" |
| 30 | + mkdir $sdkPath |
| 31 | + Invoke-WebRequest -Uri $env:NPCAP_SDK_URL -OutFile "$sdkPath\npcap-sdk.zip" |
| 32 | + Expand-Archive -Path "$sdkPath\npcap-sdk.zip" -DestinationPath $sdkPath |
| 33 | + Copy-Item -Path "$sdkPath\Lib\x64\Packet.lib" -Destination . |
| 34 | + - name: Build |
| 35 | + run: cargo build --verbose |
| 36 | + - name: Build for release |
| 37 | + run: cargo build --release --verbose |
| 38 | + # - name: Run tests |
| 39 | + # run: cargo test --verbose |
0 commit comments