-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docs for configuring github actions to format
- Loading branch information
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,3 +66,86 @@ jobs: | |
``` | ||
|
||
Please contact us at [email protected] with any questions, or if you would like more options for automatic assignment. | ||
|
||
## Configuring Automatic Formatting | ||
|
||
Many projects enforce a consistent code style by using automatic code formatters. This section contains instructions for configuring GitHub Actions to automatically format PRs that are created by Pixeebot. | ||
|
||
### Python | ||
|
||
The most popular Python code formatter is [Black](https://black.readthedocs.io/en/stable/). To automatically format PRs created by Pixeebot using Black, add the following GitHub action workflow to your repository: | ||
|
||
```yaml | ||
name: Format Pixeebot PRs | ||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
jobs: | ||
apply-black: | ||
if: github.event.pull_request.user.login == 'pixeebot[bot]' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
- name: Install black | ||
run: pip install black | ||
- name: Apply black formatting | ||
run: black . | ||
- name: Commit and push changes | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: ":art: Apply formatting" | ||
``` | ||
|
||
This action can be added to your repository by creating a `.github/workflows/pixeebot-autoformat-black.yml` file with the above content. | ||
|
||
Note that it may be necessary to pin the version of Black to ensure that the formatting is consistent with your project's style. Depending on your project's configuration it may also be necessary to pass additional arguments to the `black` command to ensure that the correct settings are used. | ||
|
||
### Java | ||
|
||
For Java projects it is common to use a tool such as [Spotless](https://github.com/diffplug/spotless) to enforce code formatting. To automatically format PRs created by Pixeebot using Gradle to apply Spotless, add the following GitHub action workflow to your repository: | ||
|
||
```yaml | ||
name: Format Pixeebot PRs | ||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
jobs: | ||
spotless-apply: | ||
if: github.event.pull_request.user.login == 'pixeebot[bot]' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: "Setup JDK" | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
- name: 🐘Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
- name: 🎨 Run spotless via Gradle | ||
run: ./gradlew spotlessApply | ||
- name: Commit and push changes | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: ":art: Apply formatting" | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,7 @@ Each party agrees to hold data and confidential information of the other party i | |
### Where can I learn more and discuss Pixeebot? | ||
|
||
Users can join the Pixee community [on Slack](https://join.slack.com/t/openpixee/shared_invite/zt-1pnk7jqdd-kfwilrfG7Ov4M8rorfOnUA). This channel can be used to engage with peers who are also interested in Pixee. Feel free to email us at [email protected] with any questions or comments. | ||
|
||
### How can I Automatic Formatting to Pixeebot PRs? | ||
|
||
See our [Configuration](configuring.md#configuring-automatic-formatting) page for more information on how to enable automatic formatting of PRs generated by Pixeebot. |