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 PROFILE_FLAGS to profileable targets #891

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
45 changes: 45 additions & 0 deletions .github/workflows/weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ name: devicemapper weekly

# yamllint disable-line rule:truthy
on:
push:
branches:
- master
paths-ignore:
- 'CHANGES.txt'
- '**/README.md'
pull_request:
branches:
- master
paths-ignore:
- 'CHANGES.txt'
- '**/README.md'

schedule:
- cron: 20 3 * * 2
workflow_dispatch:
Expand All @@ -27,3 +40,35 @@ jobs:
${{ matrix.dependencies }}
- name: ${{ matrix.task }}
run: ${{ matrix.task }}

coverage:
strategy:
matrix:
include:
- toolchain: 1.73.0 # CURRENT DEVELOPMENT RUST TOOLCHAIN
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
components: cargo
toolchain: ${{ matrix.toolchain }}
- name: Install dependencies
run: |
sudo apt-get -q update
sudo apt-get -y install libdevmapper-dev
- name: Set toolchain override with sudo
# yamllint disable rule:line-length
run: sudo /home/runner/.cargo/bin/rustup override set ${{ matrix.toolchain }}
- name: Install cargo-binutils
run: sudo PATH=$GITHUB_WORKSPACE/.cargo/bin:$PATH CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' /home/runner/.cargo/bin/cargo install cargo-binutils
- name: Add component llvm-tools-preview
run: sudo /home/runner/.cargo/bin/rustup component add llvm-tools-preview
- name: Run all tests on ${{ matrix.toolchain }} toolchain with profiling
run: sudo PATH=$GITHUB_WORKSPACE/.cargo/bin:$PATH PROFILE=1 make -f Makefile sudo_test
- name: Merge raw coverage files
run: |
sudo PATH=$GITHUB_WORKSPACE/.cargo/bin:$PATH CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' /root/.cargo/bin/rust-profdata merge --sparse *.profraw -o result.profdata
sudo rm *.profraw
- name: Generate coverage report
run: sudo PATH=$GITHUB_WORKSPACE/.cargo/bin:$PATH CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' /root/.cargo/bin/rust-cov report -object $(find target/debug/deps/ -regex ".*devicemapper-[0-9a-f]*") -instr-profile=result.profdata --summary-only
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ Cargo.lock
*.bk
*.swo
*.swp

*.profraw
*.profdata
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
ifeq ($(origin PROFILE), undefined)
else
PROFILE_FLAGS = -C instrument-coverage
endif

ifeq ($(origin FEDORA_RELEASE), undefined)
else
FEDORA_RELEASE_ARGS = --release=${FEDORA_RELEASE}
Expand Down Expand Up @@ -46,16 +51,16 @@ fmt-ci:
cd devicemapper-rs-sys && cargo fmt -- --check

build:
RUSTFLAGS="${DENY}" cargo build
RUSTFLAGS="${DENY} ${PROFILE_FLAGS}" cargo build

build-tests:
RUSTFLAGS="${DENY}" cargo test --no-run
RUSTFLAGS="${DENY} ${PROFILE_FLAGS}" cargo test --no-run

test:
RUSTFLAGS="${DENY}" RUST_BACKTRACE=1 cargo test -- --skip sudo_ --skip loop_
RUSTFLAGS="${DENY} ${PROFILE_FLAGS}" RUST_BACKTRACE=1 cargo test -- --skip sudo_ --skip loop_

sudo_test:
RUSTFLAGS="${DENY}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test
RUSTFLAGS="${DENY} ${PROFILE_FLAGS}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER='sudo -E' cargo test

clippy:
RUSTFLAGS="${DENY}" \
Expand Down