-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add tests, linting and msrv workflows - Update authors in markdown and Cargo.toml files
- Loading branch information
1 parent
a86309d
commit 6765ec7
Showing
9 changed files
with
406 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,43 @@ | ||
name: CI | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
name: Tests | ||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
build-and-test: | ||
setup-environment: | ||
name: Set env vars | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
cargo_cache_key: ${{ steps.cargo_cache_key.outputs.value }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: cargo build --workspace --verbose | ||
- run: cargo test --workspace --verbose --color=always -- --color=always | ||
- run: cargo fmt --all --check | ||
- uses: actions/checkout@v4 | ||
- name: Set cargo cache key | ||
id: cargo_cache_key | ||
run: | | ||
CARGO_CACHE_KEY="${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}" | ||
echo "value=$CARGO_CACHE_KEY" >> $GITHUB_ENV | ||
echo "::set-output name=value::$CARGO_CACHE_KEY" | ||
msrv-check: | ||
runs-on: ubuntu-latest | ||
lint: | ||
needs: setup-environment | ||
uses: ./.github/workflows/lint.yml | ||
with: | ||
cache-key: ${{ needs.setup-environment.outputs.cargo_cache_key }} | ||
|
||
test: | ||
name: Test | ||
needs: setup-environment | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: rustup toolchain install 1.64 | ||
- run: cargo +1.64 build -p ribboncurls --verbose | ||
- run: cargo +1.64 test -p ribboncurls --verbose --color=always -- --color=always | ||
- uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
|
||
- name: Cargo test | ||
run: cargo test --release --workspace --all-targets --all-features | ||
|
||
check-msrv: | ||
uses: ./.github/workflows/msrv.yml |
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,176 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- "cli-v*.*.*" | ||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
publish_dryrun: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
cargo_version: ${{ steps.cargo_version.outputs.value }} | ||
steps: | ||
- uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
with: | ||
components: rustfmt | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
ref: ${{ github.ref }} | ||
|
||
- name: Setup Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
|
||
- name: Cache Cargo registry and binaries | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
~/.cargo/bin | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/rust-toolchain') }} | ||
id: cache-cargo-release | ||
|
||
- name: Install deps | ||
run: | | ||
if ! command -v jq &> /dev/null; then | ||
if [[ "$RUNNER_OS" == "Linux" ]]; then | ||
sudo apt-get update | ||
sudo apt-get install -y jq | ||
elif [[ "$RUNNER_OS" == "macOS" ]]; then | ||
brew install jq | ||
fi | ||
fi | ||
if ! command -v cargo-deny &> /dev/null; then | ||
cargo install --locked cargo-deny | ||
fi | ||
env: | ||
RUNNER_OS: ${{ runner.os }} | ||
|
||
- name: Get Cargo version | ||
id: cargo_version | ||
run: | | ||
VERSION=$(cargo read-manifest | jq -r ".version") | ||
echo "value=$VERSION" >> $GITHUB_ENV | ||
echo "::set-output name=value::$VERSION" | ||
- name: Abort if there is a Cargo.toml and git tag mismatch | ||
run: | | ||
if [[ "v${{ steps.cargo_version.outputs.value }}" != "${{ github.ref_name }}" ]]; then | ||
echo "There is a Cargo.toml version and git tag mismatch." && exit 1; | ||
fi | ||
- name: Attempt a publish dryrun | ||
run: | | ||
make publish_dry | ||
release: | ||
needs: publish_dryrun | ||
name: ${{ matrix.target }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- prefix: x86_64-linux | ||
target: x86_64-unknown-linux-gnu | ||
os: ubuntu-latest | ||
cross: false | ||
deb: false | ||
- prefix: i686-linux | ||
target: i686-unknown-linux-gnu | ||
os: ubuntu-latest | ||
cross: true | ||
deb: true | ||
- prefix: aarch64-linux | ||
target: aarch64-unknown-linux-gnu | ||
os: ubuntu-latest | ||
cross: true | ||
deb: true | ||
- os: macos-11 | ||
target: x86_64-apple-darwin | ||
cross: true | ||
deb: false | ||
- os: macos-11 | ||
target: aarch64-apple-darwin | ||
cross: true | ||
deb: false | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
ref: ${{ github.ref }} | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
override: true | ||
target: ${{ matrix.target }} | ||
|
||
- name: Setup cache | ||
uses: Swatinem/[email protected] | ||
with: | ||
key: ${{ matrix.target }} | ||
|
||
- name: Build binary | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
use-cross: ${{ matrix.cross }} | ||
command: build | ||
args: --release --locked --target=${{ matrix.target }} --color=always --verbose | ||
|
||
- name: Install cargo-deb | ||
if: ${{ matrix.deb == true }} | ||
uses: actions-rs/[email protected] | ||
with: | ||
crate: cargo-deb | ||
|
||
- name: Build deb | ||
if: ${{ matrix.deb == true }} | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: deb | ||
args: --no-build --no-strip --output=. --target=${{ matrix.target }} | ||
|
||
- name: Package | ||
shell: bash | ||
run: | | ||
files="example.toml license.html LICENSE README.md" | ||
$GITHUB_WORKSPACE/scripts/package_build \ | ||
"LICENSE-APACHE LICENSE-MIT README.md license.html" \ | ||
"${{ matrix.target }}" \ | ||
"$GITHUB_WORKSPACE" \ | ||
"${{ steps.cargo_version.outputs.value }}" | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.target }} | ||
path: | | ||
*.deb | ||
*.tar.gz | ||
*.sha256 | ||
- name: Create release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
build/*.deb | ||
build/*.tar.gz | ||
build/*.sha256 | ||
tag_name: ${{ github.ref_name }} | ||
name: Release ${{ steps.cargo_version.outputs.value }} | ||
draft: true |
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,70 @@ | ||
name: Lint | ||
on: | ||
workflow_call: | ||
inputs: | ||
cache-key: | ||
required: true | ||
type: string | ||
workflow_dispatch: | ||
|
||
env: | ||
CARGO_CACHE_KEY: ${{ inputs.cache-key || 'default-cache-key-if-none-provided' }} | ||
|
||
jobs: | ||
fmt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
~/.cargo/bin | ||
key: ${{ env.CARGO_CACHE_KEY }} | ||
id: cache-cargo-fmt | ||
- uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
with: | ||
components: rustfmt | ||
|
||
- name: Rustfmt Check | ||
uses: actions-rust-lang/rustfmt@v1 | ||
|
||
deny: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
~/.cargo/bin | ||
key: ${{ env.CARGO_CACHE_KEY }} | ||
id: cache-cargo-deny | ||
- uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
|
||
- uses: EmbarkStudios/cargo-deny-action@v1 | ||
|
||
audit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
~/.cargo/bin | ||
key: ${{ env.CARGO_CACHE_KEY }} | ||
id: cache-cargo-fmt | ||
- uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
|
||
- uses: taiki-e/install-action@v2 | ||
with: | ||
tool: cargo-audit | ||
- name: Cargo audit | ||
run: cargo audit |
Oops, something went wrong.