From 989334c406a4a99319c164d5e926e1d326daf3b6 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 29 Nov 2023 11:22:35 +0000 Subject: [PATCH 1/4] Add a workflow to try and automatically fixup a PR --- .github/workflows/fix_lint.yaml | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/fix_lint.yaml diff --git a/.github/workflows/fix_lint.yaml b/.github/workflows/fix_lint.yaml new file mode 100644 index 000000000000..ef471af3263a --- /dev/null +++ b/.github/workflows/fix_lint.yaml @@ -0,0 +1,50 @@ +# A helper workflow to automatically fixup any linting errors on a PR. Must be +# triggered manually. + +name: Attempt to automatically fix linting errors + +on: + workflow_dispatch: + +jobs: + fixup: + name: Fix up + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + # We use nightly so that `fmt` correctly groups together imports, and + # clippy correctly fixes up the benchmarks. + toolchain: nightly-2022-12-01 + components: rustfmt + - uses: Swatinem/rust-cache@v2 + + - name: Setup Poetry + uses: matrix-org/setup-python-poetry@v1 + with: + install-project: "false" + + - name: Import order (isort) + continue-on-error: true + run: poetry run isort . + + - name: Code style (black) + continue-on-error: true + run: poetry run black . + + - name: Semantic checks (ruff) + continue-on-error: true + run: poetry run ruff . + + - run: cargo clippy --all-features --fix -- -D warnings + continue-on-error: true + + - run: cargo fmt + continue-on-error: true + + - uses: stefanzweifel/git-auto-commit-action@v5 From 01fab6aaeae900937647b1a5578b780965280feb Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 29 Nov 2023 11:25:51 +0000 Subject: [PATCH 2/4] Add commit message --- .github/workflows/fix_lint.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/fix_lint.yaml b/.github/workflows/fix_lint.yaml index ef471af3263a..6b534acf6c19 100644 --- a/.github/workflows/fix_lint.yaml +++ b/.github/workflows/fix_lint.yaml @@ -48,3 +48,5 @@ jobs: continue-on-error: true - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Attempt to fix linting" From 72d96999156fda273dcee9ecfbc6872735a12820 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 29 Nov 2023 11:26:35 +0000 Subject: [PATCH 3/4] Newsfile --- changelog.d/16704.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/16704.misc diff --git a/changelog.d/16704.misc b/changelog.d/16704.misc new file mode 100644 index 000000000000..4dafb27fd8c1 --- /dev/null +++ b/changelog.d/16704.misc @@ -0,0 +1 @@ +Add a workflow to try and automatically fixup linting in a PR. From 8f04289d900f8e9ec3f80032277ff007aa203ca5 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 29 Nov 2023 13:09:26 +0000 Subject: [PATCH 4/4] Update .github/workflows/fix_lint.yaml Co-authored-by: Patrick Cloke --- .github/workflows/fix_lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fix_lint.yaml b/.github/workflows/fix_lint.yaml index 6b534acf6c19..f1e35fcd99d9 100644 --- a/.github/workflows/fix_lint.yaml +++ b/.github/workflows/fix_lint.yaml @@ -39,7 +39,7 @@ jobs: - name: Semantic checks (ruff) continue-on-error: true - run: poetry run ruff . + run: poetry run ruff --fix . - run: cargo clippy --all-features --fix -- -D warnings continue-on-error: true