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

Add lots of Github Actions CI jobs to check sanity #57

Merged
merged 7 commits into from
Jun 11, 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
77 changes: 77 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
name: Build and test
on:
pull_request:
paths:
- .github/workflows/build-and-test.yml
- '**/*.rs'
- Cargo.toml
- Cargo.lock
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: --deny warnings

jobs:
build-and-test:
strategy:
matrix:
# Keep MSRV in sync with rust-version in Cargo.toml
rust: [stable, beta, nightly, 1.56.0]
runs-on: ubuntu-latest
steps:
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y libnftnl-dev libmnl-dev

- uses: actions/checkout@v4

- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #v1.0.7
with:
toolchain: ${{ matrix.rust }}
profile: minimal
default: true

- name: Build
run: cargo build --all-targets --locked

- name: Test
run: cargo test --locked

# Make sure documentation builds without warnings (broken links etc)
- name: Generate documentation
if: matrix.rust == 'stable'
run: RUSTDOCFLAGS="--deny warnings" cargo doc

# Make sure the library builds with all dependencies downgraded to their
# oldest versions allowed by the semver spec. This ensures we have not
# under-specified any dependency
minimal-versions:
runs-on: ubuntu-latest
steps:
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y libnftnl-dev libmnl-dev

- uses: actions/checkout@v4

- name: Install stable Rust
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #v1.0.7
with:
toolchain: stable
profile: minimal

- name: Install nightly Rust
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #v1.0.7
with:
toolchain: nightly
profile: minimal

- name: Downgrade dependencies to minimal versions
run: cargo +nightly update -Z minimal-versions

- name: Compile with minimal versions
run: cargo +stable build --all-targets --locked
25 changes: 25 additions & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Rust formatting
on:
pull_request:
paths:
- .github/workflows/formatting.yml
- '**/*.rs'
workflow_dispatch:
jobs:
check-formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #v1.0.7
with:
toolchain: stable
profile: minimal
components: rustfmt
default: true

- name: Check formatting
run: |
rustfmt --version
cargo fmt -- --check
32 changes: 32 additions & 0 deletions .github/workflows/git-commit-message-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Git - Check commit message style
on:
push:
workflow_dispatch:

jobs:
check-commit-message-style:
name: Check commit message style
runs-on: ubuntu-latest
steps:
# Make sure there are no whitespaces other than space, tab and newline in a commit message.
- name: Check for unicode whitespaces
uses: gsactions/commit-message-checker@16fa2d5de096ae0d35626443bcd24f1e756cafee #v2.0.0
with:
# Pattern matches strings not containing weird unicode whitespace/separator characters
# \P{Z} = All non-whitespace characters (the u-flag is needed to enable \P{Z})
# [ \t\n] = Allowed whitespace characters
pattern: '^(\P{Z}|[ \t\n])+$'
flags: 'u'
error: 'Detected unicode whitespace character in commit message.'
checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request
accessToken: ${{ secrets.GITHUB_TOKEN }} # only required if checkAllCommitMessages is true

# Git commit messages should follow these guidelines: https://cbea.ms/git-commit/
- name: Check against guidelines
uses: mristin/opinionated-commit-message@f3b9cec249cabffbae7cd564542fd302cc576827 #v3.1.1
with:
# Commit messages are allowed to be subject only, no body
allow-one-liners: 'true'
# This action defaults to 50 char subjects, but 72 is fine.
max-subject-line-length: '72'
32 changes: 32 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Rust linting
on:
pull_request:
paths:
- .github/workflows/linting.yml
- '**/*.rs'
- Cargo.toml
- Cargo.lock
workflow_dispatch:
jobs:
clippy-linting:
runs-on: ubuntu-latest
steps:
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y libnftnl-dev libmnl-dev

- uses: actions/checkout@v4

- uses: actions-rs/[email protected]
with:
toolchain: stable
profile: minimal
components: clippy
default: true

- name: Clippy check
env:
RUSTFLAGS: --deny warnings
run: cargo clippy --locked --all-targets
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@

/target/
**/*.rs.bk
Cargo.lock
89 changes: 89 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions nftnl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ log = "0.4"
nftnl-sys = { path = "../nftnl-sys", version = "0.6.1" }

[dev-dependencies]
ipnetwork = "0.16"
mnl = "0.2"
ipnetwork = "0.20.0"
mnl = "0.2.2"
Loading