Skip to content

Commit

Permalink
Add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
pnehrer committed Dec 1, 2022
1 parent 8a45ada commit da5e6ec
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

99 changes: 99 additions & 0 deletions .github/workflows/rust-ci.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

0 comments on commit da5e6ec

Please sign in to comment.