Skip to content

chore(clippy): fix clippy warnings #18

chore(clippy): fix clippy warnings

chore(clippy): fix clippy warnings #18

Workflow file for this run

name: CI/CD
on:
push:
branches:
- main
- '**'
pull_request:
branches:
- main
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
test_and_lint:
name: Test & Lint (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
rust: [ stable ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy Lints
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run tests
run: cargo test --all-targets --all-features --verbose
- name: Build documentation (as a check)
run: cargo doc --no-deps --all-features
check_version_for_release:
name: Check Version for Release
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.check_logic.outputs.should_release }}
current_version: ${{ steps.get_version.outputs.current_version }}
is_prerelease: ${{ steps.check_logic.outputs.is_prerelease }}
tag_name: ${{ steps.check_logic.outputs.tag_name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get current version from Cargo.toml
id: get_version
run: |
VERSION=$(grep '^version = ' Cargo.toml | sed -E 's/^version = "(.*)"/\1/')
echo "current_version=$VERSION" >> $GITHUB_OUTPUT
echo "Current Cargo.toml version: $VERSION"
- name: Determine if release is needed and if it's a prerelease
id: check_logic
run: |
CURRENT_VERSION="${{ steps.get_version.outputs.current_version }}"
TAG_NAME="v${CURRENT_VERSION}"
SHOULD_RELEASE="false"
IS_PRERELEASE="false"
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "Tag $TAG_NAME already exists. No release needed for version $CURRENT_VERSION."
else
echo "Tag $TAG_NAME does not exist for version $CURRENT_VERSION. A release should be created."
SHOULD_RELEASE="true"
fi
if echo "$CURRENT_VERSION" | grep -q '-'; then
IS_PRERELEASE="true"
echo "Version $CURRENT_VERSION is a pre-release."
else
echo "Version $CURRENT_VERSION is a full release."
fi
echo "should_release=$SHOULD_RELEASE" >> $GITHUB_OUTPUT
echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
publish_crate_release:
name: Create Tag and Publish GitHub Release
if: github.ref == 'refs/heads/main' && needs.check_version_for_release.outputs.should_release == 'true'
needs: [ test_and_lint, check_version_for_release ]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Create and Push Git Tag
env:
TAG_NAME: ${{ needs.check_version_for_release.outputs.tag_name }}
run: |
echo "Creating and pushing tag $TAG_NAME"
git tag "$TAG_NAME" -m "Release $TAG_NAME"
git push origin "$TAG_NAME"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ needs.check_version_for_release.outputs.tag_name }}
IS_PRERELEASE: ${{ needs.check_version_for_release.outputs.is_prerelease }}
run: |
PRERELEASE_OPTION=""
if [[ "$IS_PRERELEASE" == "true" ]]; then
PRERELEASE_OPTION="--prerelease"
fi
echo "Creating GitHub release for tag $TAG_NAME"
gh release create "$TAG_NAME" \
--title "Release $TAG_NAME" \
--generate-notes \
$PRERELEASE_OPTION