Skip to content

Commit

Permalink
Add docs for configuring github actions to format
Browse files Browse the repository at this point in the history
  • Loading branch information
drdavella committed Mar 14, 2024
1 parent ecf9525 commit 327bc71
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
83 changes: 83 additions & 0 deletions docs/configuring.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```
4 changes: 4 additions & 0 deletions docs/faqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 327bc71

Please sign in to comment.