Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #41 from epage/template
Browse files Browse the repository at this point in the history
chore: Update from '_rust/main' template
  • Loading branch information
epage committed Apr 4, 2023
2 parents 348df81 + 157ca9d commit 744c358
Show file tree
Hide file tree
Showing 14 changed files with 309 additions and 108 deletions.
11 changes: 11 additions & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
msrv = "1.60.0" # MSRV
warn-on-all-wildcard-imports = true
allow-expect-in-tests = true
allow-unwrap-in-tests = true
allow-dbg-in-tests = true
allow-print-in-tests = true
disallowed-methods = [
{ path = "std::option::Option::map_or", reason = "use `map(..).unwrap_or(..)`" },
{ path = "std::option::Option::map_or_else", reason = "use `map(..).unwrap_or_else(..)`" },
{ path = "std::result::Result::map_or", reason = "use `map(..).unwrap_or(..)`" },
{ path = "std::result::Result::map_or_else", reason = "use `map(..).unwrap_or_else(..)`" },
]
26 changes: 26 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,33 @@
],
"semanticCommits": "enabled",
"configMigration": true,
"dependencyDashboard": true,
"regexManagers": [
{
"fileMatch": [
"^rust-toolchain\\.toml$",
"Cargo.toml$",
"clippy.toml$",
"\.clippy.toml$",
"^\.github/workflows/ci.yml$",
"^\.github/workflows/rust-next.yml$",
],
"matchStrings": [
"MSRV.*?(?<currentValue>\\d+\\.\\d+(\\.\\d+)?)",
"(?<currentValue>\\d+\\.\\d+(\\.\\d+)?).*?MSRV",
],
"depNameTemplate": "rust",
"packageNameTemplate": "rust-lang/rust",
"datasourceTemplate": "github-releases",
}
],
"packageRules": [
{
"commitMessageTopic": "MSRV",
"matchManagers": ["regex"],
"matchPackageNames": ["rust"],
"stabilityDays": 126, // 3 releases * 6 weeks per release * 7 days per week
},
// Goals:
// - Keep version reqs low, ignoring compatible normal/build dependencies
// - Take advantage of latest dev-dependencies
Expand Down
12 changes: 6 additions & 6 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# These settings are synced to GitHub by https://probot.github.io/apps/settings/

repository:
description: Colored Console primitives for Rust CLIs
topics: rust cli ansi term console tty
description: "Colored Console primitives for Rust CLIs"
topics: "rust cli ansi term console tty"
has_issues: true
has_projects: false
has_wiki: false
Expand All @@ -20,19 +20,19 @@ labels:
# Type
- name: bug
color: '#b60205'
description: Not as expected
description: "Not as expected"
- name: enhancement
color: '#1d76db'
description: Improve the expected
description: "Improve the expected"
# Flavor
- name: question
color: "#cc317c"
description: Uncertainty is involved
description: "Uncertainty is involved"
- name: breaking-change
color: "#e99695"
- name: good first issue
color: '#c2e0c6'
description: Help wanted!
description: "Help wanted!"

branches:
- name: main
Expand Down
38 changes: 33 additions & 5 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,49 @@
name: Security audit

permissions:
contents: read

on:
pull_request:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
schedule:
- cron: '3 3 3 * *'
branches:
- main

env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
CLICOLOR: 1

jobs:
security_audit:
permissions:
issues: write # to create issues (actions-rs/audit-check)
checks: write # to create check (actions-rs/audit-check)
runs-on: ubuntu-latest
# Prevent sudden announcement of a new advisory from failing ci:
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

cargo_deny:
permissions:
issues: write # to create issues (actions-rs/audit-check)
checks: write # to create check (actions-rs/audit-check)
runs-on: ubuntu-latest
strategy:
matrix:
checks:
- bans licenses sources
steps:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check ${{ matrix.checks }}
rust-version: stable
68 changes: 34 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: CI

permissions:
contents: read

on:
pull_request:
paths:
- '**'
- '!/*.md'
- '!/docs/**'
- "!/LICENSE-*"
push:
branches:
- main
paths:
- '**'
- '!/*.md'
- '!/docs/**'
- "!/LICENSE-*"
schedule:
- cron: '3 3 3 * *'

env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
CLICOLOR: 1

jobs:
ci:
permissions:
contents: none
name: CI
needs: [test, msrv, docs, rustfmt, clippy]
runs-on: ubuntu-latest
Expand All @@ -36,16 +36,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
- name: Configure git
run: |
git config --global user.name "Test User"
git config --global user.email "test_user@example.com"
- name: Build
run: cargo test --no-run --workspace --all-features
- name: Default features
Expand All @@ -61,11 +55,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.60.0 # MSRV
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
- name: Default features
run: cargo check --workspace --all-targets
Expand All @@ -80,11 +72,9 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
- name: Check documentation
env:
Expand All @@ -97,32 +87,42 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
# Not MSRV because its harder to jump between versions and people are
# more likely to have stable
toolchain: stable
profile: minimal
override: true
components: rustfmt
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
clippy:
name: clippy
runs-on: ubuntu-latest
permissions:
security-events: write # to upload sarif results
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.60.0 # MSRV
profile: minimal
override: true
components: clippy
- uses: Swatinem/rust-cache@v2
- uses: actions-rs/clippy-check@v1
- name: Install SARIF tools
run: cargo install clippy-sarif --version 0.3.4 --locked # Held back due to msrv
- name: Install SARIF tools
run: cargo install sarif-fmt --version 0.3.4 --locked # Held back due to msrv
- name: Check
run: >
cargo clippy --workspace --all-features --all-targets --message-format=json -- -D warnings --allow deprecated
| clippy-sarif
| tee clippy-results.sarif
| sarif-fmt
continue-on-error: true
- name: Upload
uses: github/codeql-action/upload-sarif@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace --all-features --all-targets -- -D warnings --allow deprecated
sarif_file: clippy-results.sarif
wait-for-processing: true
8 changes: 8 additions & 0 deletions .github/workflows/committed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
name: Lint Commits
on: [pull_request]

permissions:
contents: read

env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
CLICOLOR: 1

jobs:
committed:
name: Lint Commits
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
name: pre-commit

permissions: {} # none

on:
pull_request:
push:
branches: [main]

env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
CLICOLOR: 1

jobs:
pre-commit:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
60 changes: 11 additions & 49 deletions .github/workflows/rust-next.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
name: rust-next

permissions:
contents: read

on:
schedule:
- cron: '3 3 3 * *'

env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
CLICOLOR: 1

jobs:
test:
name: Test
Expand All @@ -18,61 +28,13 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
- name: Default features
run: cargo test --workspace
- name: All features
run: cargo test --workspace --all-features
- name: No-default features
run: cargo test --workspace --no-default-features
rustfmt:
name: rustfmt
strategy:
matrix:
rust:
- stable
- beta
continue-on-error: ${{ matrix.rust != 'stable' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
components: rustfmt
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
clippy:
name: clippy
strategy:
matrix:
rust:
- 1.60.0 # MSRV
- stable
continue-on-error: ${{ matrix.rust != '1.60.0' }} # MSRV
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
components: clippy
- uses: Swatinem/rust-cache@v2
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace --all-features --all-targets -- -D warnings

0 comments on commit 744c358

Please sign in to comment.