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

Fix macos-latest builds #282

Merged
merged 5 commits into from
Nov 19, 2022
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
70 changes: 70 additions & 0 deletions .github/workflows/ci-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
on:
workflow_call:
inputs:
os:
required: true
type: string
toolchain:
required: true
type: string
profile:
required: true
type: string
features:
required: true
type: string
secrets:
NPCAP_OEM_PASSWORD:
required: true
NPCAP_OEM_USERNAME:
required: true

jobs:
cargo-test-steps:
runs-on: ${{ inputs.os }}
steps:
- name: Check out repo
uses: actions/checkout@v2
- name: Install libpcap (ubuntu)
if: inputs.os == 'ubuntu-latest'
run: sudo apt-get install libpcap-dev
- name: Install libpcap (macos)
if: inputs.os == 'macos-latest'
run: brew install libpcap
- name: Install npcap sdk (windows)
if: inputs.os == 'windows-latest'
run: |
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
- name: Install npcap dll (windows)
# Secrets are not passed to workflows that are triggered by a pull request from a fork.
# https://docs.github.com/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets
if: (inputs.os == 'windows-latest') && (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
- name: Select rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ inputs.toolchain }}
components: clippy, rustfmt
override: true
- name: cargo build
run: cargo build ${{ inputs.profile }} ${{ inputs.features }}
- name: cargo test
# Since secrets are not passed to workflows that are triggered by a pull request from a fork
# the npcap dll won't be installed so we skip this step on pull requests. It will
# nevertheless be run once merged and the pull request will still verify the build steps.
if: (inputs.os != 'windows-latest') || (github.event_name != 'pull_request')
run: cargo test ${{ inputs.profile }} ${{ inputs.features }}
- name: cargo clippy
if: inputs.toolchain == 'stable'
run: cargo clippy ${{ inputs.profile }} ${{ inputs.features }} -- -D warnings
- name: cargo doc
run: env DOCS_RS=true cargo doc ${{ inputs.profile }} ${{ inputs.features }} --no-deps
- name: cargo fmt
if: inputs.toolchain == 'stable'
run: cargo fmt -- --check
110 changes: 52 additions & 58 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,70 +14,64 @@ env:
CARGO_TERM_COLOR: always

jobs:
cargo-test:
cargo-test-stable-beta:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
toolchain: ["1.46.0", stable, beta]
toolchain: [stable, beta]
profile: ['', --release]
features: ['', '--all-features']
exclude:
# capture-stream is not supported on Windows or compiler versions too old for Tokio.
# capture-stream is not supported on Windows.
- os: windows-latest
features: '--all-features'
- toolchain: "1.46.0"
features: '--all-features'
include:
# nightly check is performed on ubuntu only.
- os: ubuntu-latest
toolchain: nightly
profile: ''
features: --all-features
runs-on: ${{ matrix.os }}

steps:
- name: Check out repo
uses: actions/checkout@v2
- name: Install libpcap (ubuntu)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install libpcap-dev
- name: Install libpcap (macos)
if: matrix.os == 'macos-latest'
run: brew install libpcap
- name: Install npcap sdk (windows)
if: matrix.os == 'windows-latest'
run: |
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
- name: Install npcap dll (windows)
# Secrets are not passed to workflows that are triggered by a pull request from a fork.
# https://docs.github.com/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets
if: (matrix.os == 'windows-latest') && (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
- name: Select rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
components: clippy, rustfmt
override: true
- name: cargo build
run: cargo build ${{ matrix.profile }} ${{ matrix.features }}
- name: cargo test
# Since secrets are not passed to workflows that are triggered by a pull request from a fork
# the npcap dll won't be installed so we skip this step on pull requests. It will
# nevertheless be run once merged and the pull request will still verify the build steps.
if: (matrix.os != 'windows-latest') || (github.event_name != 'pull_request')
run: cargo test ${{ matrix.profile }} ${{ matrix.features }}
- name: cargo clippy
if: matrix.toolchain == 'stable'
run: cargo clippy ${{ matrix.profile }} ${{ matrix.features }} -- -D warnings
- name: cargo doc
run: env DOCS_RS=true cargo doc ${{ matrix.profile }} ${{ matrix.features }} --no-deps
- name: cargo fmt
if: matrix.toolchain == 'stable'
run: cargo fmt -- --check
uses: ./.github/workflows/ci-steps.yml
with:
os: ${{ matrix.os }}
toolchain: ${{ matrix.toolchain }}
profile: ${{ matrix.profile }}
features: ${{ matrix.features }}
secrets:
NPCAP_OEM_PASSWORD: ${{ secrets.NPCAP_OEM_PASSWORD }}
NPCAP_OEM_USERNAME: ${{ secrets.NPCAP_OEM_USERNAME }}

cargo-test-msrv:
strategy:
matrix:
# rust < 1.54 does not work on macos >= 12:
# https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20How.20can.20I.20fix.20Rust.201.2E53.2E0.20or.20earlier.20to.20run.20on.20macOS.2012.2E6.3F/near/299263887
os: [windows-latest, ubuntu-latest, macos-11]
toolchain: ["1.46.0"]
profile: ['', --release]
# capture-stream is not supported on compiler versions too old for Tokio.
features: ['']

uses: ./.github/workflows/ci-steps.yml
with:
os: ${{ matrix.os }}
toolchain: ${{ matrix.toolchain }}
profile: ${{ matrix.profile }}
features: ${{ matrix.features }}
secrets:
NPCAP_OEM_PASSWORD: ${{ secrets.NPCAP_OEM_PASSWORD }}
NPCAP_OEM_USERNAME: ${{ secrets.NPCAP_OEM_USERNAME }}

# nightly check is performed on ubuntu only.
cargo-test-nightly:
strategy:
matrix:
os: [ubuntu-latest]
toolchain: [nightly]
profile: ['', --release]
features: ['', '--all-features']

uses: ./.github/workflows/ci-steps.yml
with:
os: ${{ matrix.os }}
toolchain: ${{ matrix.toolchain }}
profile: ${{ matrix.profile }}
features: ${{ matrix.features }}
secrets:
NPCAP_OEM_PASSWORD: ${{ secrets.NPCAP_OEM_PASSWORD }}
NPCAP_OEM_USERNAME: ${{ secrets.NPCAP_OEM_USERNAME }}