diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..476ae20 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: "cargo" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + diff --git a/.github/workflows/rust-ci.yaml b/.github/workflows/rust-ci.yaml new file mode 100644 index 0000000..eb56d5e --- /dev/null +++ b/.github/workflows/rust-ci.yaml @@ -0,0 +1,99 @@ +on: + pull_request: + push: + branches: + - main + +name: Rust CI + +jobs: + lint: + name: Check formatting and run clippy + runs-on: ubuntu-latest + steps: + - name: Check out the source code + uses: actions/checkout@v3 + - name: Cache tools + uses: actions/cache@v3 + with: + key: ${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.65.0 + components: rustfmt, clippy + default: true + - name: Check formatting + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + - name: Run clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --all -- -D warnings + + coverage: + name: Run tests with coverage + runs-on: ubuntu-latest + steps: + - name: Check out the source code + uses: actions/checkout@v3 + - name: Cache tools + uses: actions/cache@v3 + with: + key: ${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.65.0 + default: true + - name: Build the binary + uses: actions-rs/cargo@v1 + with: + command: build + env: + CARGO_INCREMENTAL: '0' + RUSTC_BOOTSTRAP: '1' + RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + - name: Run unit tests + uses: actions-rs/cargo@v1 + with: + command: test + env: + CARGO_INCREMENTAL: '0' + RUSTC_BOOTSTRAP: '1' + RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' + - name: Install grcov + uses: actions-rs/cargo@v1 + with: + command: install + args: grcov + - name: Run grcov + run: grcov . -s . --binary-path ./target/debug/ --excl-start '^mod\s+test(s)?\s*\{$' -t covdir --branch --ignore-not-existing --keep-only 'src/**' -o ./target/covdir.json + - name: Generate coverage report + uses: ecliptical/covdir-report-action@v0.1 + with: + file: ./target/covdir.json + summary: 'true' + out: ./target/coverage.md + - name: Add coverage comment to the pull request + uses: marocchino/sticky-pull-request-comment@v2 + if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' + with: + hide_and_recreate: true + hide_classify: "OUTDATED" + path: ./target/coverage.md diff --git a/README.md b/README.md index e3405f7..c7b09bd 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,8 @@ into the [`tracing`](https://github.com/tokio-rs/tracing) ecosystem. Use when a library uses `slog` but your application uses `tracing`. -Heavily inspired by [tracing-log](https://github.com/tokio-rs/tracing/tree/5fdbcbf61da27ec3e600678121d8c00d2b9b5cb1/tracing-log). +Heavily inspired by [tracing-log](https://github.com/tokio-rs/tracing/tree/60c60bef62972e447414a748a95b31ff9027165b/tracing-log). + +Specifically, the emitted log entries include the custom fields `slog.target`, `slog.module_path`, `slog.file`, `slog.line`, and `slog.column` with corresponding values from the slog call site. + +Note that the "native" `filename` and `line_number` metadata attributes will never be available (and `target` will always be `slog`). This is due to the fact that `tracing` requires static metadata constructed at the original call site. The `tracing-log` adapter does provide these due to explicit support in `tracing`.