Skip to content

Commit

Permalink
chore: First step
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Mar 29, 2023
0 parents commit e7b7555
Show file tree
Hide file tree
Showing 23 changed files with 1,019 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.x86_64-pc-windows-msvc]
rustflags = ["-Ctarget-feature=+crt-static"]

[target.i686-pc-windows-msvc]
rustflags = ["-Ctarget-feature=+crt-static"]
12 changes: 12 additions & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
msrv = "1.64.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(..)`" },
]
71 changes: 71 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"schedule": [
"before 3am on the first day of the month"
],
"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
// - Rollup safe upgrades to reduce CI runner load
// - Help keep number of versions down by always using latest breaking change
// - Have lockfile and manifest in-sync
{
"matchManagers": ["cargo"],
"matchDepTypes": ["build-dependencies", "dependencies"],
"matchCurrentVersion": ">=0.1.0",
"matchUpdateTypes": ["patch"],
"enabled": false,
},
{
"matchManagers": ["cargo"],
"matchDepTypes": ["build-dependencies", "dependencies"],
"matchCurrentVersion": ">=1.0.0",
"matchUpdateTypes": ["minor"],
"enabled": false,
},
{
"matchManagers": ["cargo"],
"matchDepTypes": ["dev-dependencies"],
"matchCurrentVersion": ">=0.1.0",
"matchUpdateTypes": ["patch"],
"automerge": true,
"groupName": "compatible (dev)",
},
{
"matchManagers": ["cargo"],
"matchDepTypes": ["dev-dependencies"],
"matchCurrentVersion": ">=1.0.0",
"matchUpdateTypes": ["minor"],
"automerge": true,
"groupName": "compatible (dev)",
},
],
}
52 changes: 52 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# These settings are synced to GitHub by https://probot.github.io/apps/settings/

repository:
description: "DESCRIPTION"
homepage: "https://docs.rs/PROJECT"
topics: ""
has_issues: true
has_projects: false
has_wiki: false
has_downloads: true
default_branch: main

allow_squash_merge: true
allow_merge_commit: true
allow_rebase_merge: true

allow_auto_merge: true
delete_branch_on_merge: true

squash_merge_commit_title: "PR_TITLE"
squash_merge_commit_message: "PR_BODY"
merge_commit_message: "PR_BODY"

labels:
# Type
- name: bug
color: '#b60205'
description: Not as expected
- name: enhancement
color: '#1d76db'
description: Improve the expected
# Flavor
- name: question
color: "#cc317c"
description: Uncertainty is involved
- name: breaking-change
color: "#e99695"
- name: good first issue
color: '#c2e0c6'
description: Help wanted!

branches:
- name: main
protection:
required_pull_request_reviews: null
required_conversation_resolution: true
required_status_checks:
# Required. Require branches to be up to date before merging.
strict: false
contexts: ["CI", "Lint Commits", "Spell Check with Typos"]
enforce_admins: false
restrictions: null
49 changes: 49 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Security audit

permissions:
contents: read

on:
pull_request:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
push:
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
128 changes: 128 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: CI

permissions:
contents: read

on:
pull_request:
push:
branches:
- main

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
steps:
- name: Done
run: exit 0
test:
name: Test
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
rust: ["stable"]
continue-on-error: ${{ matrix.rust != 'stable' }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo test --no-run --workspace --all-features
- 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
msrv:
name: "Check MSRV: 1.64.0"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.64.0 # MSRV
- uses: Swatinem/rust-cache@v2
- name: Default features
run: cargo check --workspace --all-targets
- name: All features
run: cargo check --workspace --all-targets --all-features
- name: No-default features
run: cargo check --workspace --all-targets --no-default-features
docs:
name: Docs
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Check documentation
env:
RUSTDOCFLAGS: -D warnings
run: cargo doc --workspace --all-features --no-deps --document-private-items
rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
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
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: dtolnay/rust-toolchain@stable
with:
toolchain: 1.64.0 # MSRV
components: clippy
- uses: Swatinem/rust-cache@v2
- 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:
sarif_file: clippy-results.sarif
wait-for-processing: true
24 changes: 24 additions & 0 deletions .github/workflows/committed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Not run as part of pre-commit checks because they don't handle sending the correct commit
# range to `committed`
name: Lint Commits
on: [pull_request]

permissions:
contents: read

env:
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
CLICOLOR: 1

jobs:
committed:
name: Lint Commits
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Lint Commits
uses: crate-ci/committed@master
23 changes: 23 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
Loading

0 comments on commit e7b7555

Please sign in to comment.