Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to properly use Blue in GitHub Actions? #85

Open
eddyyxxyy opened this issue Oct 5, 2022 · 1 comment
Open

How to properly use Blue in GitHub Actions? #85

eddyyxxyy opened this issue Oct 5, 2022 · 1 comment

Comments

@eddyyxxyy
Copy link

No description provided.

@tpwo
Copy link

tpwo commented Oct 5, 2022

I just migrated from black, and I'm using the same way as before -- pre-commit. It's a great solution to run multiple tools in one process, and it provides a ready-to-use plugin for GitHub Actions.

To enable it, you have to create a config file .pre-commit-config.yaml in your repo root; the simplest with just blue looks like that:

repos:
-   repo: https://github.com/grantjenks/blue
    rev: v0.9.1
    hooks:
    -   id: blue

My .github/workflows/pre-commit.yaml looks like this. pre-commit/[email protected] does the magic here:

name: pre-commit

on:
  pull_request:
  push:
    branches:
      - main
      - test-me-*
    tags:
      - '*'

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-python@v2
    - uses: pre-commit/[email protected]

And remember that you can very easily run pre-commit locally, hence the name -- it can run all checks AKA hooks before each commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants