feat(linter): Add unused_trait lint (#2121)
#5570
This file contains hidden or 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
| name: CI | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - "**/CHANGELOG.md" | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - "**/CHANGELOG.md" | |
| workflow_dispatch: | |
| # Cancel previous runs for the same workflow | |
| concurrency: | |
| group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" | |
| cancel-in-progress: true | |
| jobs: | |
| get_release_info: | |
| name: Get Release Info | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.new_release_tag.outputs.TAG }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Get latest release | |
| if: startsWith(github.ref, 'refs/heads/main') | |
| id: release | |
| uses: pozetroninc/github-action-get-latest-release@master | |
| with: | |
| repository: ${{ github.repository }} | |
| excludes: prerelease, draft | |
| - name: Determine if release build | |
| if: startsWith(github.ref, 'refs/heads/main') | |
| id: new_release_tag | |
| env: | |
| LATEST_RELEASE: ${{ steps.release.outputs.release }} | |
| run: | | |
| CARGO_VERSION=v$(grep "version" Cargo.toml | head -n 1 | cut -d\" -f2) | |
| if [[ "${CARGO_VERSION}" != "${LATEST_RELEASE}" ]]; then | |
| echo "TAG=${CARGO_VERSION}" >> $GITHUB_OUTPUT | |
| echo "::warning::Will create release for version: ${CARGO_VERSION}" | |
| else | |
| echo "::warning::Will not create a release" | |
| fi | |
| sanity_check: | |
| name: Sanity checks | |
| runs-on: ubuntu-latest | |
| env: | |
| RUSTFLAGS: "-Dwarnings" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| run: rustup toolchain install stable --profile minimal --component rustfmt,clippy | |
| - name: Install cargo binstall | |
| uses: cargo-bins/cargo-binstall@ae04fb5e853ae6cd3ad7de4a1d554a8b646d12aa # v1.15.11 | |
| - name: Install cargo audit | |
| run: cargo binstall [email protected] --no-confirm --locked | |
| - name: Setup Rust cache | |
| id: setup-rust-cache | |
| uses: ./.github/actions/setup-rust-cache | |
| with: | |
| target-cache-key: ${{ runner.os }}-${{ github.job }} | |
| - name: Run audit | |
| run: cargo audit --ignore RUSTSEC-2022-0028 | |
| - name: Run rustfmt | |
| run: cargo fmt-stacks --check | |
| - name: Run clippy | |
| run: cargo clippy --workspace --exclude clarinet-sdk-wasm | |
| cargo_test: | |
| name: Run cargo tests | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| platform: linux | |
| target: x86_64-unknown-linux-gnu | |
| architecture: x64 | |
| libc: glibc | |
| - os: windows-latest | |
| platform: windows | |
| target: x86_64-pc-windows-msvc | |
| architecture: x64 | |
| - os: macos-latest | |
| platform: darwin | |
| target: aarch64-apple-darwin | |
| architecture: arm64 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| run: rustup toolchain install stable --profile minimal --target ${{ matrix.target }} | |
| - name: Setup Rust cache | |
| id: setup-rust-cache | |
| uses: ./.github/actions/setup-rust-cache | |
| with: | |
| target-cache-key: ${{ matrix.os }}-${{ matrix.target }}-${{ github.job }} | |
| target-path: | | |
| target/debug/.fingerprint/ | |
| target/debug/build/ | |
| target/debug/deps/ | |
| - name: Install dependencies | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-llvm-cov,nextest | |
| - name: Run unit test | |
| if: matrix.target != 'x86_64-unknown-linux-gnu' | |
| env: | |
| HIRO_API_KEY: ${{ secrets.HIRO_API_KEY }} | |
| CARGO_INCREMENTAL: 0 | |
| RUSTFLAGS: "-C debuginfo=0" | |
| run: cargo tst | |
| - name: Install llvm-cov | |
| if: matrix.target == 'x86_64-unknown-linux-gnu' | |
| run: rustup component add llvm-tools-preview --toolchain stable-x86_64-unknown-linux-gnu | |
| - name: Run unit test with coverage | |
| if: matrix.target == 'x86_64-unknown-linux-gnu' | |
| env: | |
| HIRO_API_KEY: ${{ secrets.HIRO_API_KEY }} | |
| CARGO_INCREMENTAL: 0 | |
| # prevents linux from recompiling dependencies when cache is hit | |
| CARGO_BUILD_DEP_INFO_BASEDIR: "." | |
| RUSTFLAGS: "-C debuginfo=0" | |
| run: cargo cov | |
| - name: Upload coverage data to codecov | |
| if: matrix.target == 'x86_64-unknown-linux-gnu' | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: lcov.info | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| dist_clarinet: | |
| name: Build Clarinet Distributions | |
| needs: | |
| - get_release_info | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| id-token: write | |
| contents: read | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| platform: linux | |
| target: x86_64-unknown-linux-gnu | |
| architecture: x64 | |
| libc: glibc | |
| - os: windows-latest | |
| platform: windows | |
| target: x86_64-pc-windows-msvc | |
| architecture: x64 | |
| - os: macos-latest | |
| platform: darwin | |
| target: x86_64-apple-darwin | |
| architecture: x64 | |
| - os: macos-latest | |
| platform: darwin | |
| target: aarch64-apple-darwin | |
| architecture: arm64 | |
| - os: ubuntu-latest | |
| platform: linux | |
| target: x86_64-unknown-linux-musl | |
| architecture: x64 | |
| libc: musl | |
| steps: | |
| - name: Configure git to use LF (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| git config --global core.autocrlf false | |
| git config --global core.eol lf | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| run: rustup toolchain install stable --profile minimal --target ${{ matrix.target }} | |
| - name: Setup Rust cache | |
| id: setup-rust-cache | |
| uses: ./.github/actions/setup-rust-cache | |
| with: | |
| target-cache-key: ${{ matrix.os }}-${{ matrix.target }}-${{ github.job }} | |
| # Set environment variables required from cross compiling from macos-x86_64 to macos-arm64 | |
| - name: Configure macos-arm64 cross compile config | |
| if: matrix.target == 'aarch64-apple-darwin' | |
| run: | | |
| echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV | |
| echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV | |
| - name: Configure artifact names (libc) | |
| if: ${{ matrix.libc }} | |
| shell: bash | |
| run: | | |
| echo "SHORT_TARGET_NAME=${{ matrix.platform }}-${{ matrix.architecture }}-${{ matrix.libc }}" >> $GITHUB_ENV | |
| echo "PRE_GYP_TARGET_NAME=${{ matrix.platform }}-${{ matrix.architecture }}-${{ matrix.libc }}" >> $GITHUB_ENV | |
| - name: Configure artifact names (not libc) | |
| if: ${{ ! matrix.libc }} | |
| shell: bash | |
| run: | | |
| echo "SHORT_TARGET_NAME=${{ matrix.platform }}-${{ matrix.architecture }}" >> $GITHUB_ENV | |
| echo "PRE_GYP_TARGET_NAME=${{ matrix.platform }}-${{ matrix.architecture }}-unknown" >> $GITHUB_ENV | |
| - name: Install musl-gcc | |
| if: matrix.target == 'x86_64-unknown-linux-musl' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y musl-tools | |
| - name: Build - Cargo | |
| run: cargo build --release --features=telemetry --locked --target ${{ matrix.target }} | |
| - name: Upload unsigned Windows binary for SignPath | |
| id: upload-unsigned-windows | |
| if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != '' && matrix.os == 'windows-latest' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: unsigned-clarinet-${{ env.SHORT_TARGET_NAME }} | |
| path: target/${{ matrix.target }}/release/clarinet.exe | |
| - name: Code sign Windows binary with SignPath | |
| if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != '' && matrix.os == 'windows-latest' | |
| uses: signpath/github-action-submit-signing-request@v2 | |
| with: | |
| api-token: ${{ secrets.SIGNPATH_API_TOKEN }} | |
| organization-id: ${{ secrets.SIGNPATH_ORGANIZATION_ID }} | |
| project-slug: "clarinet" | |
| signing-policy-slug: "release-signing" | |
| github-artifact-id: ${{ steps.upload-unsigned-windows.outputs.artifact-id }} | |
| wait-for-completion: true | |
| output-artifact-directory: ./signed | |
| - name: Compress cargo artifact (Linux and macOS) | |
| if: matrix.os != 'windows-latest' | |
| run: tar -C target/${{ matrix.target }}/release -zcvf clarinet-${{ env.SHORT_TARGET_NAME }}.tar.gz clarinet | |
| - name: Compress signed cargo artifact (Windows - main branch) | |
| if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != '' && matrix.os == 'windows-latest' | |
| shell: pwsh | |
| run: | | |
| Compress-Archive -Path "./signed/clarinet.exe" -DestinationPath "clarinet-${{ env.SHORT_TARGET_NAME }}.zip" | |
| - name: Upload cargo artifacts (Linux and macOS) | |
| if: matrix.os != 'windows-latest' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: clarinet-${{ env.SHORT_TARGET_NAME }} | |
| path: clarinet-${{ env.SHORT_TARGET_NAME }}.tar.gz | |
| - name: Upload cargo artifact (Windows) | |
| if: matrix.os == 'windows-latest' && needs.get_release_info.outputs.tag != '' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: clarinet-${{ env.SHORT_TARGET_NAME }} | |
| path: clarinet-${{ env.SHORT_TARGET_NAME }}.zip | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != '' | |
| needs: | |
| - get_release_info | |
| - sanity_check | |
| - cargo_test | |
| - dist_clarinet | |
| permissions: | |
| actions: write | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download pre-built dists | |
| uses: actions/download-artifact@v4 | |
| - name: Tag and Release | |
| uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1 | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| with: | |
| name: "${{ needs.get_release_info.outputs.tag }}" | |
| tag_name: ${{ needs.get_release_info.outputs.tag }} | |
| draft: true | |
| fail_on_unmatched_files: true | |
| target_commitish: ${{ env.GITHUB_SHA }} | |
| generate_release_notes: false | |
| files: | | |
| **/*.tar.gz | |
| **/*.zip | |
| - name: Trigger pkg-version-bump workflow | |
| uses: peter-evans/repository-dispatch@v1 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| event-type: released | |
| client-payload: '{"tag": "${{ needs.get_release_info.outputs.tag }}"}' |