Skip to content

Commit

Permalink
Misc chores (#61)
Browse files Browse the repository at this point in the history
- Remove separate CLI workspace and commit workspace lockfile
- Update Rust-related actions in CI config
- Check dependency graph with cargo-deny
- Fix new clippy lints and let-else formatting
- Replace `atty` crate (unmaintained) with `is-terminal`
  • Loading branch information
slowli authored Sep 17, 2023
2 parents c1bfba0 + d0b7dba commit 1f7e49c
Show file tree
Hide file tree
Showing 20 changed files with 666 additions and 421 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Do not send the `target` dirs to the Docker builder
target
cli/target
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ updates:
schedule:
interval: daily
time: "03:00"
groups:
dev-dependencies:
dependency-type: "development"
minor-changes:
update-types:
- "minor"
- "patch"
open-pull-requests-limit: 10
assignees:
- slowli
62 changes: 62 additions & 0 deletions .github/workflows/build-reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build

on:
workflow_call:
inputs:
rust_version:
type: string
description: Rust version to use in the build
required: false
default: stable

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ inputs.rust_version }}
components: rustfmt, clippy
- name: Install cargo-deny
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-deny
version: "^0.14"

- name: Cache cargo build
uses: actions/cache@v3
with:
path: target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo

- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --workspace --all-features --all-targets -- -D warnings
- name: Clippy (no features)
run: cargo clippy -p term-transcript --no-default-features --lib
- name: Clippy (features = svg)
run: cargo clippy -p term-transcript --no-default-features --features svg --lib -- -D warnings
- name: Clippy (features = test)
run: cargo clippy -p term-transcript --no-default-features --features test --lib -- -D warnings

- name: Check dependencies
run: cargo deny --workspace --all-features check

- name: Run tests
run: cargo test --workspace --all-features --all-targets
- name: Run doc tests
run: cargo test --workspace --all-features --doc

- name: Generate snapshots
run: ./examples/generate-snapshots.sh
- name: Test CLI tracing
run: |
RUST_LOG=term_transcript=debug \
cargo run -p term-transcript-cli --all-features -- \
exec 'echo Hello' |& grep INFO
122 changes: 8 additions & 114 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
# Minimum supported Rust version.
msrv: 1.66.0
# Nightly Rust necessary for building docs.
nightly: nightly-2022-11-24
nightly: nightly-2023-09-09

jobs:
build-msrv:
Expand All @@ -29,124 +29,24 @@ jobs:
- uses: actions/checkout@v3

- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.msrv }}
override: true
- name: Generate lockfile
uses: actions-rs/cargo@v1
with:
command: generate-lockfile

- name: Cache cargo build
uses: actions/cache@v3
with:
path: |
target
cli/target
path: target
key: ${{ runner.os }}${{ matrix.features }}-msrv-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}${{ matrix.features }}-msrv-cargo

- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace ${{ matrix.features }} --all-targets
- name: Run CLI tests
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=cli/Cargo.toml ${{ matrix.features }} --all-targets
run: cargo test -p term-transcript ${{ matrix.features }} --all-targets
- name: Run doc tests
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace ${{ matrix.features }} --doc
run: cargo test -p term-transcript ${{ matrix.features }} --doc

build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Generate lockfile
uses: actions-rs/cargo@v1
with:
command: generate-lockfile

- name: Cache cargo build
uses: actions/cache@v3
with:
path: |
target
cli/target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo

- name: Format
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace --all-features --all-targets -- -D warnings
- name: Clippy CLI
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --manifest-path=cli/Cargo.toml --all-features --all-targets -- -D warnings
name: clippy (CLI)
- name: Clippy (no features)
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: -p term-transcript --no-default-features --lib
name: clippy (no features)
- name: Clippy (features = svg)
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: -p term-transcript --no-default-features --features svg --lib -- -D warnings
name: clippy (features = svg)
- name: Clippy (features = test)
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: -p term-transcript --no-default-features --features test --lib -- -D warnings
name: clippy (features = test)

- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --all-features --all-targets
- name: Run CLI tests
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path=cli/Cargo.toml --all-features --all-targets
- name: Run doc tests
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --all-features --doc

- name: Generate snapshots
run: ./examples/generate-snapshots.sh
- name: Test CLI tracing
run: |
RUST_LOG=term_transcript=debug \
cargo run --manifest-path=cli/Cargo.toml --all-features -- \
exec 'echo Hello' |& grep INFO
uses: ./.github/workflows/build-reusable.yml

build-docker:
needs:
Expand All @@ -164,7 +64,7 @@ jobs:
uses: actions/cache@v3
with:
path: target/docker
key: ${{ runner.os }}-docker-buildkit-${{ hashFiles('cli/Cargo.lock') }}
key: ${{ runner.os }}-docker-buildkit-${{ hashFiles('Cargo.lock') }}
restore-keys: ${{ runner.os }}-docker-buildkit

- name: Install `socat`
Expand Down Expand Up @@ -268,15 +168,9 @@ jobs:
- uses: actions/checkout@v3

- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.nightly }}
profile: minimal
override: true
- name: Generate lockfile
uses: actions-rs/cargo@v1
with:
command: generate-lockfile

- name: Cache cargo build
uses: actions/cache@v3
Expand Down
28 changes: 18 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Release
on:
push:
tags: [ "v*" ]
workflow_dispatch: {}

defaults:
run:
Expand Down Expand Up @@ -40,25 +41,25 @@ jobs:
fi
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}
targets: ${{ matrix.target }}

- name: Cache cargo build
uses: actions/cache@v3
with:
path: cli/target
key: ${{ runner.os }}-release-cargo-${{ hashFiles('cli/Cargo.lock') }}
path: target
key: ${{ runner.os }}-release-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: ${{ runner.os }}-release-cargo

- name: Build CLI app
uses: actions-rs/cargo@v1
with:
command: build
args: --manifest-path=cli/Cargo.toml --release --target=${{ matrix.target }} --all-features --locked
run: |
cargo build -p term-transcript-cli \
--profile=executable \
--target=${{ matrix.target }} \
--all-features \
--locked
- name: Package archive
id: package
run: ./cli/package.sh ${REF#"refs/tags/"}
Expand All @@ -68,7 +69,14 @@ jobs:
REF: ${{ github.ref }}
- name: Publish archive
uses: softprops/action-gh-release@v1
if: github.event_name == "push"
with:
draft: false
files: ${{ steps.package.outputs.archive }}
prerelease: ${{ steps.release-type.outputs.type == 'prerelease' }}
- name: Attach archive to action
uses: actions/upload-artifact@v3
if: github.event_name == "workflow_dispatch"
with:
name: term-transcript-${{ matrix.target }}
path: ${{ steps.package.outputs.archive }}
9 changes: 9 additions & 0 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Scheduled checks

on:
schedule:
- cron: "0 2 * * MON"

jobs:
build:
uses: ./.github/workflows/build-reusable.yml
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Rust
target
/Cargo.lock

# IDE
.idea
Loading

0 comments on commit 1f7e49c

Please sign in to comment.