Skip to content

feat: conditional compilation support #191

feat: conditional compilation support

feat: conditional compilation support #191

Workflow file for this run

name: Rust
on: [ push, pull_request ]
env:
CARGO_TERM_COLOR: 'always'
CARGO_TERM_VERBOSE: 'true'
RUSTDOCFLAGS: '-Dwarnings'
jobs:
rust-version:
name: Minimal supported Rust version
outputs:
version: ${{ steps.read_version.outputs.msrv }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: read_version
run: |
awk -F '=' \
'/^rust-version =/ { gsub(/([" ]|#.*)/,"",$2); print "msrv=" $2 }' \
Cargo.toml \
| tee -a "$GITHUB_OUTPUT"
test-linux:
name: Test (Linux)
needs: rust-version
runs-on: ubuntu-latest
strategy:
matrix:
rust-version:
- ${{ needs.rust-version.outputs.version }}
- stable
steps:
- name: checkout source
uses: actions/checkout@v4
- name: set up cargo cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ matrix.rust-version}}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-${{ matrix.rust-version }}
- name: set up nginx deps cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
.cache/.gnupg
.cache/nginx
.cache/*.tar.gz
.cache/*.tar.asc
.cache/*.tar.sig
key: ${{ runner.os }}-deps-${{ hashFiles('**/nginx-sys/build.rs') }}
restore-keys: ${{ runner.os }}-deps-
- uses: dtolnay/rust-toolchain@master
with:
components: rustfmt, clippy
toolchain: ${{ matrix.rust-version }}
- name: build
id: build
run: cargo build --workspace --all-targets --all-features
- name: run clippy
# always run if build succeeds
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
run: cargo clippy --workspace --all-targets --all-features -- -Dwarnings
- name: run tests
# always run if build succeeds
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
run: cargo test --workspace --all-features
- name: rustdoc
# always run if build succeeds
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
run: cargo doc --no-deps
examples-linux:
name: Examples (Linux)
runs-on: ubuntu-latest
steps:
- name: checkout source
uses: actions/checkout@v4
- name: set up cargo cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: set up nginx deps cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
.cache/.gnupg
.cache/nginx
.cache/*.tar.gz
.cache/*.tar.asc
.cache/*.tar.sig
key: ${{ runner.os }}-deps-${{ hashFiles('**/nginx-sys/build.rs') }}
restore-keys: ${{ runner.os }}-deps-
- name: compile examples
run: cargo build --release --package examples --examples --all-features
test-macos:
name: Test (MacOS)
runs-on: macos-latest
steps:
- name: install command line dependencies
run: brew install make gnupg
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: set up cargo cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: set up nginx deps cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
.cache/*.tar.gz
.cache/*.tar.asc
.cache/*.tar.sig
key: ${{ runner.os }}-deps-${{ hashFiles('**/nginx-sys/build.rs') }}
restore-keys: ${{ runner.os }}-deps-
- name: current directory
run: pwd
- name: make cache directory
run: mkdir -p .cache/.gnupg
- name: disable ipv6 for gpg
run: echo "disable-ipv6" > .cache/.gnupg/dirmngr.conf
- name: build
run: cargo build
- name: run tests
run: cargo test --workspace
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: rustfmt version
run: rustfmt --version
- name: cargo fmt
run: cargo fmt --all --check