Skip to content

Fix clippy issues

Fix clippy issues #467

Workflow file for this run

name: Build and Test
on:
pull_request:
push:
branches:
- "master"
tags-ignore:
- "*"
env:
CARGO_TERM_COLOR: always
jobs:
cancel_previous:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ github.token }}
lint:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust_toolchain: [stable]
features: [default, all]
experimental: [false]
include:
- os: ubuntu-latest
rust_toolchain: nightly
features: all
experimental: true
- os: macos-latest
rust_toolchain: nightly
features: all
experimental: true
- os: windows-latest
rust_toolchain: nightly
features: all
experimental: true
steps:
- uses: actions/checkout@v4
- name: Install Rust Toolchain
id: rust_toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_toolchain }}
components: rustfmt, clippy
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: lint-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-lock-${{ hashFiles('Cargo.lock') }}-features-${{ matrix.features }}-git-${{ github.sha }}
restore-keys: |
lint-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-lock-${{ hashFiles('Cargo.lock') }}-features-${{ matrix.features }}-
lint-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-lock-${{ hashFiles('Cargo.lock') }}-
lint-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-
lint-${{ runner.os }}-
- name: rustfmt
shell: bash
run: |
cargo fmt -- --check
- name: Clippy
shell: bash
run: |
cargo clippy --features=${{ matrix.features }} --locked --tests -- -D warnings
test:
runs-on: ${{ matrix.os }}
continue-on-error: false
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust_toolchain: [stable]
features:
- [default]
- [all]
- [notification, encryption, yubikey]
steps:
- uses: actions/checkout@v4
- name: Install Rust Toolchain
id: rust_toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_toolchain }}
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: test-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-lock-${{ hashFiles('Cargo.lock') }}-features-${{ join(matrix.features, '+') }}-git-${{ github.sha }}
restore-keys: |
test-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-lock-${{ hashFiles('Cargo.lock') }}-features-${{ join(matrix.features, '+') }}-
test-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-lock-${{ hashFiles('Cargo.lock') }}-
test-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-
test-${{ runner.os }}-
- name: Test
shell: bash
run: |
cargo test --release --features=${{ join(matrix.features) }}
build:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust_toolchain: [stable]
features: [default, notification, yubikey, all]
experimental: [false]
include:
- os: ubuntu-latest
rust_toolchain: nightly
features: all
experimental: true
- os: macos-latest
rust_toolchain: nightly
features: all
experimental: true
- os: windows-latest
rust_toolchain: nightly
features: all
experimental: true
steps:
- uses: actions/checkout@v4
- name: Install macOS Dependencies
if: contains(matrix.os, 'macos')
run: |
brew install coreutils gnu-tar
echo PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH" >> $GITHUB_ENV
- name: Install Rust Toolchain
id: rust_toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_toolchain }}
- name: Add macOS Targets
if: contains(matrix.os, 'macos')
run: |
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: build-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-lock-${{ hashFiles('Cargo.lock') }}-features-${{ matrix.features }}-git-${{ github.sha }}
restore-keys: |
build-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-lock-${{ hashFiles('Cargo.lock') }}-features-${{ matrix.features }}-
build-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-lock-${{ hashFiles('Cargo.lock') }}-
build-${{ runner.os }}-rustc-${{ steps.rust_toolchain.outputs.cachekey }}-
build-${{ runner.os }}-
- name: "Build (Linux/Windows)"
if: "!contains(matrix.os, 'macos')"
shell: bash
run: |
cargo build --release --features=${{ matrix.features }}
- name: "Build (macOS x86_64)"
if: contains(matrix.os, 'macos')
shell: bash
run: |
cargo build --release --features=${{ matrix.features }} --target=x86_64-apple-darwin
- name: "Build (macOS aarch64)"
if: contains(matrix.os, 'macos')
shell: bash
run: |
cargo build --release --features=${{ matrix.features }} --target=aarch64-apple-darwin
- name: macOS Universal Binary
if: contains(matrix.os, 'macos')
run: |
mkdir -p target/release/
lipo -create -output target/release/git-credential-keepassxc target/x86_64-apple-darwin/release/git-credential-keepassxc target/aarch64-apple-darwin/release/git-credential-keepassxc
file target/release/git-credential-keepassxc
- name: Determine artifact name suffix
id: artifact_suffix
if: "matrix.features == 'default' || matrix.features == 'all'"
shell: bash
run: |
case "${{ matrix.features }}" in
default)
printf 'suffix=%s\n' 'minimal' >> $GITHUB_OUTPUT
;;
all)
printf 'suffix=%s\n' 'full' >> $GITHUB_OUTPUT
;;
*)
exit 1
;;
esac
- name: Artifacts
if: "matrix.features == 'default' || matrix.features == 'all'"
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.rust_toolchain }}-${{ steps.artifact_suffix.outputs.suffix }}
retention-days: 60
path: |
target/release/git-credential-keepassxc
target/release/git-credential-keepassxc.exe