22 |
23 |
24 | Thank you for installing the autofix.ci app!
25 |
26 |
27 | To finish your setup, follow the steps below.
28 |
29 |
30 |
31 |
Getting Started
32 |
33 |
To setup autofix.ci, do the following:
34 |
35 |
36 | -
37 |
40 |
41 | This provides autofix.ci with the necessary permissions to update pull requests.
42 |
43 |
44 | -
45 |
46 | Create .github/workflows/autofix.yml with the following content:
47 |
48 |
49 | {{ examplebox("stub.yml") }}
50 |
51 | Limiting the runner's permissions and pinning the autofix action to a specific
52 | release is not required, but makes our workflow more resilient against supply chain
53 | attacks.[1]
54 |
55 |
56 |
57 | -
58 |
Add a job that auto-fixes your codebase.
59 |
60 | Replace the comment in the file above with the code-fixing tools of your choice.
61 | Take a look at the examples below!
62 |
63 |
64 |
65 |
66 |
Examples
67 |
68 |
69 | You can combine all the example steps below, but keep them in a single job with only
70 | one call to the autofix action! :)
71 |
72 |
73 |
Python
74 |
75 | These two examples demonstrate the use of some of the most popular Python code fixing tools.
76 | We use the @install-pinned actions to
77 | install deterministic versions of all tools, but you can also pip install
78 | or use an existing requirements.txt file.
79 |
80 |
81 |
pyupgrade, reorder_python_imports autoflake, and black
82 | {{ examplebox("python.yml") }}
83 |
84 |
ruff and black
85 | {{ examplebox("python-ruff.yml") }}
86 |
87 |
88 | Of course, there's way more in the Python ecosystem! You may also want to check out
89 | yesqa,
90 | isort,
91 | blacken-docs,
92 | yapf,
93 | autopep8,
94 | docformatter, or
95 | μsort.
96 |
97 |
98 |
TypeScript / JavaScript / HTML / CSS
99 |
100 | Here's a simple workflow that formats your TypeScript or JavaScript code using
101 | Prettier:
102 |
103 | {{ examplebox("typescript.yml") }}
104 |
105 | Alternatively, you may want to check out
106 | standardjs!
107 |
108 |
109 |
Rust
110 |
111 | Here's a simple workflow that rustfmts your repo and applies clippy's suggestions:
112 |
113 | {{ examplebox("rust.yml") }}
114 |
115 | You can of course switch to a different Rust toolchain first,
116 | for example if you are using nightly rustfmt.
117 |
118 |
119 | Crab fact: autocix.ci's backend is written in Rust. 🦀
120 |
121 |
122 |
Go
123 |
124 | Here's a simple workflow that gofmts your repo:
125 |
126 | {{ examplebox("go.yml") }}
127 |
128 |
Images
129 |
130 | With a bit of creativity, autofix.ci is not limited to code formatting.
131 | For example, the following workflow shrinks all PNG files:
132 |
133 | {{ examplebox("web.yml") }}
134 |
135 |
pre-commit hooks
136 |
137 | If your existing workflow is based on pre-commit.com hooks, you should use
138 | pre-commit.ci instead of autofix.ci.
139 | Of course, you can also integrate pre-commit hooks in your
140 | autofix.ci workflow:
141 |
142 | {{ examplebox("pre-commit.yml") }}
143 |
144 |
152 |