feat: remove features when removing dependencies #188
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
name: Rust | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "*" | ||
pull_request: | ||
branches: [main] | ||
jobs: | ||
ci: | ||
env: | ||
RUST_BACKTRACE: 1 | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
rust: | ||
- stable | ||
#- nightly # re-enable once #104 has been fixed | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
components: clippy, rustfmt | ||
- uses: Swatinem/rust-cache@v2 | ||
- run: cargo fmt --all --check | ||
- run: cargo clippy --all --all-features -- -D warnings | ||
- run: cargo test --workspace --verbose | ||
autofix: | ||
name: Autofix Tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: stable | ||
components: clippy, rustfmt | ||
- run: cargo build --release | ||
- run: cargo install --path . | ||
- run: ls | ||
# The below works, but we need it to instead run with a different structure | ||
# There is now a cli-tests directory, with actual and expected subdirectories | ||
# In each of those is a number of tests we dont know hte names of in advance | ||
# We want to dynamically run the below for each of those, and well as any added in actual | ||
# And then diff the whole directory | ||
# - run: cd integration-tests/autofix-with-feature/actual && cargo machete --fix || true | ||
# - run: cd integration-tests/autofix-with-feature && diff -r expected actual | ||
# Get all directoriies in cli-tests/actual, and for each run cargo-machete --fix, | ||
- run: | | ||
for dir in cli-tests/actual/*; do | ||
if [ -d "$dir" ]; then | ||
cd "$dir" && cargo machete --fix || true | ||
fi | ||
done | ||
- run: cd cli-tests && diff -r expected actual | ||
# Code mutably borrowed from https://github.com/EmbarkStudios/cargo-deny/, thanks Embark! | ||
release: | ||
name: Release | ||
if: startsWith(github.ref, 'refs/tags/') | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-20.04 | ||
rust: stable | ||
target: x86_64-unknown-linux-musl | ||
bin: cargo-machete | ||
- os: windows-2022 | ||
rust: stable | ||
target: x86_64-pc-windows-msvc | ||
bin: cargo-machete.exe | ||
- os: macos-11 | ||
rust: stable | ||
target: x86_64-apple-darwin | ||
bin: cargo-machete | ||
- os: macos-11 | ||
rust: stable | ||
target: aarch64-apple-darwin | ||
bin: cargo-machete | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Install stable toolchain | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
target: ${{ matrix.target }} | ||
- name: Install musl tools | ||
if: matrix.os == 'ubuntu-20.04' | ||
run: | | ||
sudo apt-get install -y musl-tools | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: cargo fetch | ||
run: cargo fetch --target ${{ matrix.target }} | ||
- name: Release build | ||
run: cargo build --release --target ${{ matrix.target }} | ||
- name: Package | ||
shell: bash | ||
run: | | ||
name=cargo-machete | ||
tag=$(git describe --tags --abbrev=0) | ||
release_name="$name-$tag-${{ matrix.target }}" | ||
release_tar="${release_name}.tar.gz" | ||
mkdir "$release_name" | ||
if [ "${{ matrix.target }}" != "x86_64-pc-windows-msvc" ]; then | ||
strip "target/${{ matrix.target }}/release/${{ matrix.bin }}" | ||
fi | ||
cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "$release_name/" | ||
cp README.md LICENSE.md "$release_name/" | ||
tar czvf "$release_tar" "$release_name" | ||
rm -r "$release_name" | ||
# Windows environments in github actions don't have the gnu coreutils installed, | ||
# which includes the shasum exe, so we just use powershell instead | ||
if [ "${{ matrix.target }}" == "x86_64-pc-windows-msvc" ]; then | ||
echo "(Get-FileHash \"${release_tar}\" -Algorithm SHA256).Hash | Out-File -Encoding ASCII -NoNewline \"${release_tar}.sha256\"" | pwsh -c - | ||
else | ||
echo -n "$(shasum -ba 256 "${release_tar}" | cut -d " " -f 1)" > "${release_tar}.sha256" | ||
fi | ||
- name: Publish | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
draft: true | ||
files: "cargo-machete*" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} |