Skip to content

Commit

Permalink
redact_sensitive feature flag (#176)
Browse files Browse the repository at this point in the history
demo for @ZanCorDX 

Idea is to redact the error `Display` and `Debug` implementation where
the error is defined, rather than creating new layers of wrapper we need
to maintain and remember to use

---------

Co-authored-by: Daniel Xifra <[email protected]>
  • Loading branch information
2 people authored and astarinmymind committed Oct 3, 2024
1 parent 4144286 commit 9b67084
Show file tree
Hide file tree
Showing 12 changed files with 386 additions and 140 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ jobs:
lint_and_test:
name: Lint and test
runs-on: warp-ubuntu-latest-x64-16x
env:
# Set features for the Makefile
FEATURES: ${{ matrix.features }}
strategy:
matrix:
toolchain:
- stable
#- beta
#- nightly
features:
- ""
- "redact_sensitive"
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down Expand Up @@ -53,9 +57,11 @@ jobs:
- name: Install native dependencies
run: sudo apt-get install -y libsqlite3-dev

# lint and test
- run: make lint
- run: make test
- name: Lint
run: make lint

- name: Test
run: make test

integration:
name: Integration tests
Expand All @@ -65,8 +71,9 @@ jobs:
matrix:
toolchain:
- stable
#- beta
#- nightly
features:
- ""
- "redact_sensitive"
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand All @@ -92,13 +99,13 @@ jobs:
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- name: Build the rbuilder
run: cargo build
run: cargo build --features="${{ matrix.features }}"

- name: Run the playground
run: builder-playground &

- name: Run integration tests
run: cargo test --package rbuilder --lib -- integration
- name: Run integration tests with flags
run: cargo test --features="${{ matrix.features }}" --package rbuilder --lib -- integration
env:
PLAYGROUND: TRUE

Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ name: Release
on:
push:
tags:
- 'v*'
- "v*"
workflow_dispatch:
inputs:
build-docker:
description: 'Build Docker'
description: "Build Docker"
required: false
type: boolean
default: false
build-binary:
description: 'Build Binary'
description: "Build Binary"
required: false
type: boolean
default: true
draft-release:
description: 'Draft Release'
description: "Draft Release"
required: false
type: boolean
default: false
Expand Down Expand Up @@ -77,6 +77,9 @@ jobs:
runner: warp-ubuntu-latest-arm64-16x
- target: aarch64-apple-darwin
runner: warp-macos-14-arm64-6x
features:
- ""
- "redact_sensitive"

steps:
- name: Checkout sources
Expand Down Expand Up @@ -107,12 +110,16 @@ jobs:
- name: Prepare output filename
run: |
OUTPUT_FILENAME="rbuilder-${VERSION}-${{ matrix.configs.target }}.tar.gz"
if [ -z "${{ matrix.features }}" ]; then
OUTPUT_FILENAME="rbuilder-${VERSION}-${{ matrix.configs.target }}.tar.gz"
else
OUTPUT_FILENAME="rbuilder-${VERSION}-${{ matrix.configs.target }}-${{ matrix.features }}.tar.gz"
fi
echo "OUTPUT_FILENAME=$OUTPUT_FILENAME" >> $GITHUB_ENV
echo "Filename: ${OUTPUT_FILENAME}"
- name: Build rbuilder binary
run: cargo build --release
run: cargo build --release --features=${{ matrix.features }}

- name: Prepare artifacts
run: |
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#
FROM rust:1.79 as base

ARG FEATURES

RUN cargo install sccache --version ^0.8
RUN cargo install cargo-chef --version ^0.1

Expand Down Expand Up @@ -53,7 +55,7 @@ COPY ./crates/ ./crates/
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
cargo build --release
cargo build --release --features="$FEATURES"

#
# Runtime container
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
GIT_VER ?= $(shell git describe --tags --always --dirty="-dev")
GIT_TAG ?= $(shell git describe --tags --abbrev=0)

FEATURES ?=

##@ Help

.PHONY: help
Expand All @@ -23,22 +25,22 @@ clean: ## Clean up

.PHONY: build
build: ## Build (debug version)
cargo build
cargo build --features "$(FEATURES)"

.PHONY: docker-image
docker-image: ## Build a rbuilder Docker image
docker build --platform linux/amd64 . -t rbuilder
docker build --platform linux/amd64 --build-arg FEATURES="$(FEATURES)" . -t rbuilder

##@ Dev

.PHONY: lint
lint: ## Run the linters
cargo fmt -- --check
cargo clippy -- -D warnings
cargo clippy --features "$(FEATURES)" -- -D warnings

.PHONY: test
test: ## Run the tests
cargo test --verbose
cargo test --verbose --features "$(FEATURES)"

.PHONY: lt
lt: lint test ## Run "lint" and "test"
Expand All @@ -47,11 +49,11 @@ lt: lint test ## Run "lint" and "test"
fmt: ## Format the code
cargo fmt
cargo fix --allow-staged
cargo clippy --fix --allow-staged
cargo clippy --features "$(FEATURES)" --fix --allow-staged

.PHONY: bench
bench: ## Run benchmarks
cargo bench --bench bench_main
cargo bench --features "$(FEATURES)" --bench bench_main
# cargo bench --bench bench_main -- --verbose

.PHONY: bench-report-open
Expand Down
3 changes: 3 additions & 0 deletions crates/rbuilder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,6 @@ criterion = { version = "0.5.1", features = ["html_reports", "async_tokio"] }
[[bench]]
name = "bench_main"
harness = false

[features]
redact_sensitive = []
Loading

0 comments on commit 9b67084

Please sign in to comment.