Skip to content

Commit

Permalink
Merge pull request #268 from blink1073/fix-pre-commit-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Apr 11, 2022
2 parents 2ecef7b + 2700732 commit 640a0c6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,27 @@ jobs:
- name: Coverage
run: codecov

# Run "pre-commit run --all-files --hook-stage=manual"
pre-commit:
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- uses: pre-commit/action@v2.0.0
with:
extra_args: --all-files --hook-stage=manual
- name: Help message if pre-commit fail
if: ${{ failure() }}
run: |
echo "You can install pre-commit hooks to automatically run formatting"
echo "on each commit with:"
echo " pre-commit install"
echo "or you can run by hand on staged files with"
echo " pre-commit run"
echo "or after-the-fact on already committed files with"
echo " pre-commit run --all-files --hook-stage=manual"
docs:
runs-on: ubuntu-latest
steps:
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
ci:
skip: [check-jsonschema]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
Expand Down Expand Up @@ -47,6 +44,7 @@ repos:
hooks:
- id: doc8
args: [--max-line-length=200]
stages: [manual]

- repo: https://github.com/pycqa/flake8
rev: 4.0.1
Expand All @@ -58,6 +56,7 @@ repos:
"flake8-logging-format==0.6.0",
"flake8-implicit-str-concat==0.2.0",
]
stages: [manual]

- repo: https://github.com/sirosen/check-jsonschema
rev: 0.14.2
Expand All @@ -67,3 +66,4 @@ repos:
files: ^\.github/workflows/
types: [yaml]
args: ["--schemafile", "https://json.schemastore.org/github-workflow"]
stages: [manual]
25 changes: 25 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

We follow the [IPython Contributing Guide](https://github.com/ipython/ipython/blob/master/CONTRIBUTING.md).

## Code Styling

`nbformat` has adopted automatic code formatting so you shouldn't
need to worry too much about your code style.
As long as your code is valid,
the pre-commit hook should take care of how it should look.
You can invoke the pre-commit hook by hand at any time with:

```bash
pre-commit run
```

which should run any autoformatting on your code
and tell you about any errors it couldn't fix automatically.
You may also install [black integration](https://black.readthedocs.io/en/stable/integrations/editors.html)
into your text editor to format code automatically.

If you have already committed files before setting up the pre-commit
hook with `pre-commit install`, you can fix everything up using
`pre-commit run --all-files`. You need to make the fixing commit
yourself after that.

Some of the hooks only run on CI by default, but you can invoke them by
running with the `--hook-stage manual` argument.

## Release guidelines

The nbformat version will change in a package release only when there are
Expand Down

0 comments on commit 640a0c6

Please sign in to comment.