forked from JelteF/derive_more
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework CI and improve project toolchain (JelteF#212)
- add Contribution Guide - add template for GitHub PRs - runs CI only once for PRs - auto-cancel previous CI pipelines for the same PR/branch - switch to `dtolnay/rust-toolchain` GitHub action - remove redundant CI jobs - check documentation integrity with `rustdoc` lints on CI - create GitHub releases on CI - remove `Cargo.lock` and enable @dependabot - turn on `#![forbid(non_ascii_idents, unsafe_code)]` to simplify life of hypothetical auditors - replace `#[cfg(feature = "nightly")]` with `#[cfg(nightly)]` - tune up `.editorconfig` rules Co-authored-by: Jelte Fennema <[email protected]>
- Loading branch information
Showing
15 changed files
with
315 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Resolves <!-- paste issue reference --> | ||
<!-- and/or --> | ||
Part of <!-- paste issue/PR reference --> | ||
<!-- and/or --> | ||
Required for <!-- paste issues/PRs references --> | ||
<!-- and/or --> | ||
Requires <!-- paste issues/PRs references --> | ||
<!-- and/or --> | ||
Related to <!-- paste issues/PRs references --> | ||
|
||
<!-- Remove the lines above if there are no related issues/PRs --> | ||
|
||
|
||
|
||
|
||
## Synopsis | ||
|
||
<!-- Give a brief overview of the problem --> | ||
|
||
|
||
|
||
|
||
## Solution | ||
|
||
<!-- Describe how exactly the problem is (or will be) resolved --> | ||
|
||
|
||
|
||
|
||
## Checklist | ||
|
||
- [ ] Documentation is updated (if required) | ||
- [ ] Tests are added/updated (if required) | ||
- [ ] [CHANGELOG entry][l:1] is added (if required) | ||
|
||
|
||
|
||
|
||
[l:1]: /CHANGELOG.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: cargo | ||
directory: / | ||
schedule: | ||
interval: daily | ||
|
||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: daily |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,134 +1,177 @@ | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
on: | ||
push: | ||
branches: ["master"] | ||
tags: ["v*"] | ||
pull_request: | ||
branches: ["master"] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
RUST_BACKTRACE: 1 | ||
|
||
jobs: | ||
test: | ||
name: Test Rust ${{ matrix.toolchain }} on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }}-latest | ||
strategy: | ||
matrix: | ||
toolchain: [stable, nightly, 1.56.0] | ||
os: [ubuntu, macOS, windows] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.toolchain }} | ||
override: true | ||
|
||
- name: Remove .lock file | ||
run: rm Cargo.lock | ||
########################## | ||
# Linting and formatting # | ||
########################## | ||
|
||
- name: Test | ||
uses: actions-rs/cargo@v1 | ||
clippy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@v1 | ||
with: | ||
command: test | ||
args: --features testing-helpers | ||
toolchain: stable | ||
components: clippy | ||
|
||
- run: cargo clippy --all-features -- -D warnings | ||
|
||
test_features_separate: | ||
name: Test features | ||
rustfmt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
override: true | ||
components: rustfmt | ||
|
||
- name: Install tomljson | ||
run: go get github.com/pelletier/go-toml/cmd/tomljson | ||
- run: cargo +nightly fmt --all -- --check | ||
|
||
- name: Test | ||
run: | | ||
export GOBIN=$HOME/go/bin | ||
export PATH=$PATH:$GOBIN | ||
ci/test_all_features.sh | ||
|
||
|
||
doc_test: | ||
name: Doc tests | ||
runs-on: ubuntu-latest | ||
|
||
########### | ||
# Testing # | ||
########### | ||
|
||
msrv: | ||
name: MSRV | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
msrv: ["1.56.0"] | ||
os: | ||
- ubuntu | ||
- macOS | ||
- windows | ||
runs-on: ${{ matrix.os }}-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.msrv }} | ||
- run: rustup default ${{ matrix.msrv }} | ||
- uses: dtolnay/rust-toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
override: true | ||
|
||
- name: Run cargo-external-doc | ||
uses: actions-rs/cargo@v1 | ||
- name: Install minimal dependencies versions | ||
run: cargo +nightly update -Z minimal-versions | ||
|
||
- run: cargo test --features testing-helpers | ||
|
||
test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu | ||
- macOS | ||
- windows | ||
toolchain: | ||
- stable | ||
- nightly | ||
runs-on: ${{ matrix.os }}-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@v1 | ||
with: | ||
command: test | ||
args: --doc --features testing-helpers | ||
toolchain: ${{ matrix.toolchain }} | ||
- run: rustup default ${{ matrix.toolchain }} | ||
|
||
- run: cargo test --features testing-helpers | ||
|
||
clippy: | ||
name: Clippy | ||
test-features: | ||
name: test features | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: nightly | ||
components: clippy | ||
override: true | ||
- run: rustup default nightly | ||
|
||
- name: Clippy | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: clippy | ||
args: --all-features -- -D warnings | ||
- name: Install tomljson | ||
run: go get github.com/pelletier/go-toml/cmd/tomljson | ||
|
||
- run: ci/test_all_features.sh | ||
env: | ||
GOBIN: "$HOME/go/bin" | ||
PATH: "$PATH:$GOBIN" | ||
|
||
rustfmt: | ||
|
||
|
||
|
||
################# | ||
# Documentation # | ||
################# | ||
|
||
rustdoc: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: nightly | ||
components: rustfmt | ||
override: true | ||
|
||
- name: rustfmt | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: --all -- --check | ||
- run: cargo +nightly doc | ||
env: | ||
RUSTDOCFLAGS: --cfg docsrs | ||
|
||
|
||
msrv: | ||
# TODO: Use MSRV once it understands new `Cargo.lock` format. | ||
# name: MSRV | ||
name: Minimal crates versions | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# msrv: ["1.36.0"] | ||
msrv: [stable] | ||
os: [ubuntu, macOS, windows] | ||
runs-on: ${{ matrix.os }}-latest | ||
|
||
|
||
############# | ||
# Releasing # | ||
############# | ||
|
||
release-github: | ||
name: release on GitHub | ||
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | ||
needs: | ||
- clippy | ||
- msrv | ||
- rustdoc | ||
- rustfmt | ||
- test | ||
- test-features | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: nightly | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: ${{ matrix.msrv }} | ||
override: true | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install minimal dependecies versions | ||
run: cargo +nightly update -Z minimal-versions | ||
- name: Parse release version | ||
id: release | ||
run: echo ::set-output | ||
name=version::${GITHUB_REF#refs/tags/v} | ||
- name: Verify release version matches `derive_more` Cargo manifest | ||
run: | | ||
test "${{ steps.release.outputs.version }}" \ | ||
== "$(grep -m1 'version = "' Cargo.toml | cut -d '"' -f2)" | ||
- name: Parse CHANGELOG link | ||
id: changelog | ||
run: echo ::set-output | ||
name=link::${{ github.server_url }}/${{ github.repository }}/blob/v${{ steps.release.outputs.version }}/CHANGELOG.md#$(sed -n '/^## ${{ steps.release.outputs.version }}/{s/^## \([^ ]*\) - \([0-9].*\)/\1---\2/;s/[^0-9a-z-]*//g;p;}' CHANGELOG.md) | ||
|
||
- name: Test | ||
uses: actions-rs/cargo@v1 | ||
- uses: softprops/action-gh-release@v1 | ||
with: | ||
command: test | ||
args: --features testing-helpers | ||
name: ${{ steps.release.outputs.version }} | ||
body: | | ||
[API docs](https://docs.rs/derive_more/${{ steps.release.outputs.version }}) | ||
[Changelog](${{ steps.changelog.outputs.link }}) | ||
prerelease: ${{ contains(steps.release.outputs.version, '-') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.