1# Generated from xtask::workflows::autofix_pr
2# Rebuild with `cargo xtask workflows`.
3name: autofix_pr
4run-name: 'autofix PR #${{ inputs.pr_number }}'
5on:
6 workflow_dispatch:
7 inputs:
8 pr_number:
9 description: pr_number
10 required: true
11 type: string
12 run_clippy:
13 description: run_clippy
14 type: boolean
15 default: 'true'
16jobs:
17 run_autofix:
18 runs-on: namespace-profile-16x32-ubuntu-2204
19 steps:
20 - name: steps::checkout_repo
21 uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
22 with:
23 clean: false
24 - name: autofix_pr::run_autofix::checkout_pr
25 run: gh pr checkout "$PR_NUMBER"
26 env:
27 PR_NUMBER: ${{ inputs.pr_number }}
28 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 - name: steps::setup_cargo_config
30 run: |
31 mkdir -p ./../.cargo
32 cp ./.cargo/ci-config.toml ./../.cargo/config.toml
33 - name: steps::cache_rust_dependencies_namespace
34 uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
35 with:
36 cache: rust
37 path: ~/.rustup
38 - name: steps::setup_linux
39 run: ./script/linux
40 - name: steps::download_wasi_sdk
41 run: ./script/download-wasi-sdk
42 - name: steps::setup_pnpm
43 uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2
44 with:
45 version: '9'
46 - name: autofix_pr::run_autofix::install_cargo_machete
47 if: ${{ inputs.run_clippy }}
48 uses: taiki-e/install-action@02cc5f8ca9f2301050c0c099055816a41ee05507
49 with:
50 tool: cargo-machete@0.7.0
51 - name: autofix_pr::run_autofix::run_cargo_fix
52 if: ${{ inputs.run_clippy }}
53 run: cargo fix --workspace --release --all-targets --all-features --allow-dirty --allow-staged
54 - name: autofix_pr::run_autofix::run_cargo_machete_fix
55 if: ${{ inputs.run_clippy }}
56 run: cargo machete --fix
57 - name: autofix_pr::run_autofix::run_clippy_fix
58 if: ${{ inputs.run_clippy }}
59 run: cargo clippy --workspace --release --all-targets --all-features --fix --allow-dirty --allow-staged
60 - name: autofix_pr::run_autofix::run_prettier_fix
61 run: ./script/prettier --write
62 - name: autofix_pr::run_autofix::run_cargo_fmt
63 run: cargo fmt --all
64 - id: create-patch
65 name: autofix_pr::run_autofix::create_patch
66 run: |
67 if git diff --quiet; then
68 echo "No changes to commit"
69 echo "has_changes=false" >> "$GITHUB_OUTPUT"
70 else
71 git diff > autofix.patch
72 echo "has_changes=true" >> "$GITHUB_OUTPUT"
73 fi
74 - name: upload artifact autofix-patch
75 uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
76 with:
77 name: autofix-patch
78 path: autofix.patch
79 if-no-files-found: ignore
80 retention-days: '1'
81 - name: steps::cleanup_cargo_config
82 if: always()
83 run: |
84 rm -rf ./../.cargo
85 outputs:
86 has_changes: ${{ steps.create-patch.outputs.has_changes }}
87 commit_changes:
88 needs:
89 - run_autofix
90 if: needs.run_autofix.outputs.has_changes == 'true'
91 runs-on: namespace-profile-2x4-ubuntu-2404
92 steps:
93 - id: generate-token
94 name: steps::authenticate_as_zippy
95 uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859
96 with:
97 app-id: ${{ secrets.ZED_ZIPPY_APP_ID }}
98 private-key: ${{ secrets.ZED_ZIPPY_APP_PRIVATE_KEY }}
99 permission-contents: write
100 permission-workflows: write
101 - name: steps::checkout_repo
102 uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
103 with:
104 clean: false
105 token: ${{ steps.generate-token.outputs.token }}
106 - name: autofix_pr::commit_changes::checkout_pr
107 run: gh pr checkout "$PR_NUMBER"
108 env:
109 PR_NUMBER: ${{ inputs.pr_number }}
110 GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
111 - name: autofix_pr::download_patch_artifact
112 uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53
113 with:
114 name: autofix-patch
115 - name: autofix_pr::commit_changes::apply_patch
116 run: git apply autofix.patch
117 - name: autofix_pr::commit_changes::commit_and_push
118 run: |
119 git commit -am "Autofix"
120 git push
121 env:
122 GIT_COMMITTER_NAME: Zed Zippy
123 GIT_COMMITTER_EMAIL: 234243425+zed-zippy[bot]@users.noreply.github.com
124 GIT_AUTHOR_NAME: Zed Zippy
125 GIT_AUTHOR_EMAIL: 234243425+zed-zippy[bot]@users.noreply.github.com
126 GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
127concurrency:
128 group: ${{ github.workflow }}-${{ inputs.pr_number }}
129 cancel-in-progress: true
130defaults:
131 run:
132 shell: bash -euxo pipefail {0}