]> git.madduck.net Git - etc/vim.git/blob - docs/integrations/github_actions.md

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

d77b969367897f155671bd38941e6f2db117b493
[etc/vim.git] / docs / integrations / github_actions.md
1 # GitHub Actions integration
2
3 You can use _Black_ within a GitHub Actions workflow without setting your own Python
4 environment. Great for enforcing that your code matches the _Black_ code style.
5
6 ## Compatibility
7
8 This action is known to support all GitHub-hosted runner OSes. In addition, only
9 published versions of _Black_ are supported (i.e. whatever is available on PyPI).
10
11 Finally, this action installs _Black_ with the `colorama` extra so the `--color` flag
12 should work fine.
13
14 ## Usage
15
16 Create a file named `.github/workflows/black.yml` inside your repository with:
17
18 ```yaml
19 name: Lint
20
21 on: [push, pull_request]
22
23 jobs:
24   lint:
25     runs-on: ubuntu-latest
26     steps:
27       - uses: actions/checkout@v2
28       - uses: psf/black@stable
29 ```
30
31 We recommend the use of the `@stable` tag, but per version tags also exist if you prefer
32 that. Note that the action's version you select is independent of the version of _Black_
33 the action will use.
34
35 The version of _Black_ the action will use can be configured via `version`. This can be
36 any
37 [valid version specifier](https://packaging.python.org/en/latest/glossary/#term-Version-Specifier)
38 or just the version number if you want an exact version. The action defaults to the
39 latest release available on PyPI. Only versions available from PyPI are supported, so no
40 commit SHAs or branch names.
41
42 You can also configure the arguments passed to _Black_ via `options` (defaults to
43 `'--check --diff'`) and `src` (default is `'.'`)
44
45 Here's an example configuration:
46
47 ```yaml
48 - uses: psf/black@stable
49   with:
50     options: "--check --verbose"
51     src: "./src"
52     version: "21.5b1"
53 ```
54
55 If you want to match versions covered by Black's
56 [stability policy](labels/stability-policy), you can use the compatible release operator
57 (`~=`):
58
59 ```yaml
60 - uses: psf/black@stable
61   with:
62     options: "--check --verbose"
63     src: "./src"
64     version: "~= 22.0"
65 ```