From b692921160431472366ef047b771f5c067f2e354 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 27 Jan 2023 18:51:41 -0500 Subject: [PATCH] Use rustup show in lieu of actions-rs/toolchain (#2280) --- .github/workflows/ci.yaml | 78 +++++++-------------------- .github/workflows/flake8-to-ruff.yaml | 70 ++++++++++-------------- .github/workflows/playground.yaml | 6 +-- .github/workflows/ruff.yaml | 72 +++++++++++-------------- 4 files changed, 80 insertions(+), 146 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 780f152bc1..3d15869fca 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,9 +22,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal + - name: "Install Rust toolchain" + run: rustup show - uses: Swatinem/rust-cache@v1 - run: cargo build --all - run: ./target/debug/ruff_dev generate-all @@ -37,10 +36,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - components: rustfmt + - name: "Install Rust toolchain" + run: rustup component add rustfmt - run: cargo fmt --all --check cargo_clippy: @@ -48,11 +45,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - components: clippy - target: wasm32-unknown-unknown + - name: "Install Rust toolchain" + run: | + rustup component add clippy + rustup target add wasm32-unknown-unknown - uses: Swatinem/rust-cache@v1 - run: cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::pedantic - run: cargo clippy -p ruff --target wasm32-unknown-unknown --all-features -- -D warnings -W clippy::pedantic @@ -65,18 +61,17 @@ jobs: name: "cargo test | ${{ matrix.os }}" steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal + - name: "Install Rust toolchain" + run: rustup show - uses: Swatinem/rust-cache@v1 - run: cargo install cargo-insta - run: pip install black[d]==22.12.0 - - name: Run tests (Ubuntu) + - name: "Run tests (Ubuntu)" if: ${{ matrix.os == 'ubuntu-latest' }} run: | cargo insta test --all --delete-unreferenced-snapshots git diff --exit-code - - name: Run tests (Windows) + - name: "Run tests (Windows)" if: ${{ matrix.os == 'windows-latest' }} shell: bash run: | @@ -94,9 +89,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal + - name: "Install Rust toolchain" + run: rustup show - uses: Swatinem/rust-cache@v1 - run: ./scripts/add_rule.py --name DoTheThing --code PLC999 --linter pylint - run: cargo check @@ -105,44 +99,13 @@ jobs: ./scripts/add_rule.py --name FirstRule --code TST001 --linter test - run: cargo check -# TODO(charlie): Re-enable the `wasm-pack` tests. -# See: https://github.com/charliermarsh/ruff/issues/1425 -# wasm-pack-test: -# name: "wasm-pack test" -# runs-on: ubuntu-latest -# env: -# WASM_BINDGEN_TEST_TIMEOUT: 60 -# steps: -# - uses: actions/checkout@v3 -# - uses: actions-rs/toolchain@v1 -# with: -# profile: minimal - - -# - uses: actions/cache@v3 -# env: -# cache-name: cache-cargo -# with: -# path: | -# ~/.cargo/registry -# ~/.cargo/git -# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }} -# restore-keys: | -# ${{ runner.os }}-build-${{ env.cache-name }}- -# ${{ runner.os }}-build- -# ${{ runner.os }}- -# - uses: jetli/wasm-pack-action@v0.4.0 -# - uses: jetli/wasm-bindgen-action@v0.2.0 -# - run: wasm-pack test --node - maturin-build: name: "maturin build" runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal + - name: "Install Rust toolchain" + run: rustup show - uses: Swatinem/rust-cache@v1 - uses: actions/setup-python@v4 with: @@ -151,13 +114,10 @@ jobs: - run: maturin build -b bin typos: - name: Spell Check with Typos + name: "spell check" runs-on: ubuntu-latest steps: - - name: Checkout Actions Repository - uses: actions/checkout@v3 - - - name: Check spelling of file.txt - uses: crate-ci/typos@master + - uses: actions/checkout@v3 + - uses: crate-ci/typos@master with: files: . diff --git a/.github/workflows/flake8-to-ruff.yaml b/.github/workflows/flake8-to-ruff.yaml index 319dc2ae9b..3317b9d595 100644 --- a/.github/workflows/flake8-to-ruff.yaml +++ b/.github/workflows/flake8-to-ruff.yaml @@ -24,21 +24,17 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - default: true - - name: Build wheels - x86_64 + - name: "Install Rust toolchain" + run: rustup show + - name: "Build wheels - x86_64" uses: messense/maturin-action@v1 with: target: x86_64 args: --release --out dist --sdist -m ./${{ env.CRATE_NAME }}/Cargo.toml - - name: Install built wheel - x86_64 + - name: "Install built wheel - x86_64" run: | pip install dist/${{ env.CRATE_NAME }}-*.whl --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -51,20 +47,16 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - default: true - - name: Build wheels - universal2 + - name: "Install Rust toolchain" + run: rustup show + - name: "Build wheels - universal2" uses: messense/maturin-action@v1 with: args: --release --universal2 --out dist -m ./${{ env.CRATE_NAME }}/Cargo.toml - - name: Install built wheel - universal2 + - name: "Install built wheel - universal2" run: | pip install dist/${{ env.CRATE_NAME }}-*universal2.whl --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -81,22 +73,18 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: ${{ matrix.target }} - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - default: true - - name: Build wheels + - name: "Install Rust toolchain" + run: rustup show + - name: "Build wheels" uses: messense/maturin-action@v1 with: target: ${{ matrix.target }} args: --release --out dist -m ./${{ env.CRATE_NAME }}/Cargo.toml - - name: Install built wheel + - name: "Install built wheel" shell: bash run: | python -m pip install dist/${{ env.CRATE_NAME }}-*.whl --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -113,17 +101,17 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 - - name: Build wheels + - name: "Build wheels" uses: messense/maturin-action@v1 with: target: ${{ matrix.target }} manylinux: auto args: --release --out dist -m ./${{ env.CRATE_NAME }}/Cargo.toml - - name: Install built wheel + - name: "Install built wheel" if: matrix.target == 'x86_64' run: | pip install dist/${{ env.CRATE_NAME }}-*.whl --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -139,7 +127,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - - name: Build wheels + - name: "Build wheels" uses: messense/maturin-action@v1 with: target: ${{ matrix.target }} @@ -158,7 +146,7 @@ jobs: pip3 install -U pip run: | pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links dist/ --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -177,13 +165,13 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 - - name: Build wheels + - name: "Build wheels" uses: messense/maturin-action@v1 with: target: ${{ matrix.target }} manylinux: musllinux_1_2 args: --release --out dist -m ./${{ env.CRATE_NAME }}/Cargo.toml - - name: Install built wheel + - name: "Install built wheel" if: matrix.target == 'x86_64-unknown-linux-musl' uses: addnab/docker-run-action@v3 with: @@ -192,7 +180,7 @@ jobs: run: | apk add py3-pip pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links /io/dist/ --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -212,7 +200,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - - name: Build wheels + - name: "Build wheels" uses: messense/maturin-action@v1 with: target: ${{ matrix.platform.target }} @@ -228,7 +216,7 @@ jobs: apk add py3-pip run: | pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links dist/ --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -252,17 +240,17 @@ jobs: - uses: actions/setup-python@v4 with: python-version: pypy${{ matrix.python-version }} - - name: Build wheels + - name: "Build wheels" uses: messense/maturin-action@v1 with: target: ${{ matrix.target }} manylinux: auto args: --release --out dist -i pypy${{ matrix.python-version }} -m ./${{ env.CRATE_NAME }}/Cargo.toml - - name: Install built wheel + - name: "Install built wheel" if: matrix.target == 'x86_64' run: | pip install dist/${{ env.CRATE_NAME }}-*.whl --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -285,7 +273,7 @@ jobs: with: name: wheels - uses: actions/setup-python@v4 - - name: Publish to PyPi + - name: "Publish to PyPi" env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.FLAKE8_TO_RUFF_TOKEN }} diff --git a/.github/workflows/playground.yaml b/.github/workflows/playground.yaml index de7a8ba241..e4fc5efa3f 100644 --- a/.github/workflows/playground.yaml +++ b/.github/workflows/playground.yaml @@ -18,10 +18,8 @@ jobs: CF_API_TOKEN_EXISTS: ${{ secrets.CF_API_TOKEN != '' }} steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - target: wasm32-unknown-unknown + - name: "Install Rust toolchain" + run: rustup target add wasm32-unknown-unknown - uses: actions/setup-node@v3 with: node-version: 18 diff --git a/.github/workflows/ruff.yaml b/.github/workflows/ruff.yaml index 3a7deb20a2..b7ba7dba27 100644 --- a/.github/workflows/ruff.yaml +++ b/.github/workflows/ruff.yaml @@ -26,21 +26,17 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - default: true - - name: Build wheels - x86_64 + - name: "Install Rust toolchain" + run: rustup show + - name: "Build wheels - x86_64" uses: messense/maturin-action@v1 with: target: x86_64 args: --release --out dist --sdist - - name: Install built wheel - x86_64 + - name: "Install built wheel - x86_64" run: | pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -53,20 +49,16 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - default: true - - name: Build wheels - universal2 + - name: "Install Rust toolchain" + run: rustup show + - name: "Build wheels - universal2" uses: messense/maturin-action@v1 with: args: --release --universal2 --out dist - - name: Install built wheel - universal2 + - name: "Install built wheel - universal2" run: | pip install dist/${{ env.PACKAGE_NAME }}-*universal2.whl --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -83,22 +75,18 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: ${{ matrix.target }} - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - default: true - - name: Build wheels + - name: "Install Rust toolchain" + run: rustup show + - name: "Build wheels" uses: messense/maturin-action@v1 with: target: ${{ matrix.target }} args: --release --out dist - - name: Install built wheel + - name: "Install built wheel" shell: bash run: | python -m pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -115,17 +103,17 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 - - name: Build wheels + - name: "Build wheels" uses: messense/maturin-action@v1 with: target: ${{ matrix.target }} manylinux: auto args: --release --out dist - - name: Install built wheel + - name: "Install built wheel" if: matrix.target == 'x86_64' run: | pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -141,7 +129,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - - name: Build wheels + - name: "Build wheels" uses: messense/maturin-action@v1 with: target: ${{ matrix.target }} @@ -160,7 +148,7 @@ jobs: pip3 install -U pip run: | pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links dist/ --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -179,13 +167,13 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 - - name: Build wheels + - name: "Build wheels" uses: messense/maturin-action@v1 with: target: ${{ matrix.target }} manylinux: musllinux_1_2 args: --release --out dist - - name: Install built wheel + - name: "Install built wheel" if: matrix.target == 'x86_64-unknown-linux-musl' uses: addnab/docker-run-action@v3 with: @@ -194,7 +182,7 @@ jobs: run: | apk add py3-pip pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links /io/dist/ --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -214,7 +202,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: ${{ env.PYTHON_VERSION }} - - name: Build wheels + - name: "Build wheels" uses: messense/maturin-action@v1 with: target: ${{ matrix.platform.target }} @@ -230,7 +218,7 @@ jobs: apk add py3-pip run: | pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links dist/ --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -254,17 +242,17 @@ jobs: - uses: actions/setup-python@v4 with: python-version: pypy${{ matrix.python-version }} - - name: Build wheels + - name: "Build wheels" uses: messense/maturin-action@v1 with: target: ${{ matrix.target }} manylinux: auto args: --release --out dist -i pypy${{ matrix.python-version }} - - name: Install built wheel + - name: "Install built wheel" if: matrix.target == 'x86_64' run: | pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall - - name: Upload wheels + - name: "Upload wheels" uses: actions/upload-artifact@v3 with: name: wheels @@ -288,13 +276,13 @@ jobs: with: name: wheels - uses: actions/setup-python@v4 - - name: Publish to PyPi + - name: "Publish to PyPi" env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.RUFF_TOKEN }} run: | pip install --upgrade twine twine upload --skip-existing * - - name: Update pre-commit mirror + - name: "Update pre-commit mirror" run: | curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.RUFF_PRE_COMMIT_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/charliermarsh/ruff-pre-commit/dispatches --data '{"event_type": "pypi_release"}'