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

pre-commit checks are not being run in CI #1151

Open
JoshKarpel opened this issue Nov 10, 2022 · 0 comments
Open

pre-commit checks are not being run in CI #1151

JoshKarpel opened this issue Nov 10, 2022 · 0 comments

Comments

@JoshKarpel
Copy link
Contributor

JoshKarpel commented Nov 10, 2022

While working on #1150 I noticed that running pre-commit run --all on main right now generates a lot of diffs from the end-of-line fixer and the trailing whitespace remover:

❯ pre-commit run --all
trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing README.md
Fixing docs/examples/styles/display.css
Fixing docs/examples/guide/input/mouse01.css
Fixing docs/examples/styles/color.css
Fixing src/textual/widgets/_tree_control.py
Fixing docs/examples/styles/padding.css
Fixing imgs/codebrowser.svg
Fixing docs/index.md
Fixing docs/examples/styles/text_style.css
Fixing docs/examples/app/question03.py
Fixing docs/examples/guide/widgets/fizzbuzz02.css
Fixing docs/examples/styles/box_sizing.css
Fixing src/textual/widgets/_text_log.py
Fixing docs/examples/styles/height.css
Fixing docs/examples/styles/background.css
Fixing .github/workflows/comment.yml
Fixing docs/examples/styles/width.css
Fixing imgs/demo.svg
Fixing src/textual/demo.css
Fixing src/textual/containers.py
Fixing docs/blog/posts/release0-4-0.md
Fixing src/textual/_clock.py
Fixing docs/examples/styles/scrollbars.css
Fixing docs/roadmap.md
Fixing docs/examples/guide/screens/screen01.css
Fixing docs/examples/guide/input/key03.css
Fixing examples/dictionary.css
Fixing docs/examples/styles/overflow.css
Fixing src/textual/scroll_view.py
Fixing examples/calculator.css
Fixing docs/examples/guide/input/binding01.css
Fixing src/textual/widgets/_welcome.py
Fixing docs/examples/styles/scrollbar_size.css
Fixing docs/examples/guide/widgets/fizzbuzz01.css
Fixing pyproject.toml
Fixing docs/examples/guide/screens/screen02.css
Fixing src/textual/cli/previews/easing.py
Fixing docs/reference/index.md
Fixing docs/guide/devtools.md
Fixing docs/examples/guide/reactivity/watch01.css
Fixing docs/examples/styles/border.css
Fixing docs/examples/app/question02.css
Fixing docs/styles/index.md
Fixing docs/examples/events/dictionary.css
Fixing examples/code_browser.css
Fixing docs/examples/styles/margin.css
Fixing mkdocs.yml
Fixing docs/examples/styles/tint.css
Fixing src/textual/_cache.py
Fixing docs/stylesheets/custom.css
Fixing docs/examples/styles/visibility.css
Fixing docs/examples/styles/offset.css
Fixing docs/blog/posts/helo-world.md

fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing README.md
Fixing docs/images/dom2.excalidraw.svg
Fixing docs/images/layout/dock.excalidraw.svg
Fixing docs/images/screens/switch_screen.excalidraw.svg
Fixing docs/images/events/queue.excalidraw.svg
Fixing docs/images/events/naming.excalidraw.svg
Fixing docs/images/layout/offset.excalidraw.svg
Fixing docs/index.md
Fixing docs/images/events/bubble1.excalidraw.svg
Fixing docs/images/layout/align.excalidraw.svg
Fixing CODE_OF_CONDUCT.md
Fixing docs/images/input/coords.excalidraw.svg
Fixing docs/images/descendant_combinator.excalidraw.svg
Fixing docs/images/actions/format.excalidraw.svg
Fixing docs/images/styles/border_box.excalidraw.svg
Fixing docs/images/layout/grid.excalidraw.svg
Fixing docs/roadmap.md
Fixing docs/images/child_combinator.excalidraw.svg
Fixing docs/images/dom1.excalidraw.svg
Fixing docs/images/styles/box.excalidraw.svg
Fixing docs/images/stopwatch_widgets.excalidraw.svg
Fixing docs/images/css_stopwatch.excalidraw.svg
Fixing docs/images/events/queue2.excalidraw.svg
Fixing docs/examples/guide/dom4.css
Fixing docs/images/layout/vertical.excalidraw.svg
Fixing docs/images/styles/content_box.excalidraw.svg
Fixing docs/images/screens/push_screen.excalidraw.svg
Fixing docs/images/layout/center.excalidraw.svg
Fixing docs/images/dom3.excalidraw.svg
Fixing docs/images/layout/horizontal.excalidraw.svg
Fixing docs/images/events/bubble2.excalidraw.svg
Fixing docs/blog/index.md
Fixing docs/help.md
Fixing docs/guide/design.md
Fixing docs/images/screens/pop_screen.excalidraw.svg
Fixing docs/images/animation/animation.excalidraw.svg
Fixing docs/blog/images/faster-updates.excalidraw.svg
Fixing docs/images/stopwatch.excalidraw.svg
Fixing docs/images/events/bubble3.excalidraw.svg
Fixing docs/blog/posts/helo-world.md
Fixing docs/guide/queries.md

check yaml...............................................................Passed
black....................................................................Passed

These are admittedly trivial, but changes from something like black would be more annoying to be in an apparently-inconsistent state. black happens to be checked separately in CI right now, but you could imagine some other pre-commit checks being added that weren't also checked in CI, since they're not locked together. It can also hurt during version upgrades - if you upgrade black but don't remember to run it on everything, pre-commit won't save you on commit because it would only look at changed files.

A pattern I've often used is to run pre-commit run --all in CI. If you've pre-commit installed it should never fail your CI runs, so it shouldn't impact dev cycles much, but it also ensures that any code that does get merged will comply with all pre-commit checks.

Basic support is pretty simple - I like to use a separate GitHub Actions workflow like

name: pre-commit

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/[email protected]
      - name: Set up Python
        uses: actions/[email protected]
        with:
          python-version: "3.x"
      - name: Run pre-commit
        uses: pre-commit/[email protected]

Mostly just setting up for https://github.com/pre-commit/action, then using it. I use a separate workflow because checks don't usually need to run on all platforms/Python versions.

But, since Textual is open source, you could instead use https://pre-commit.ci/ , which comes with a variety of extra benefits as laid out on that page (mainly auto-updates and auto-fixing PRs).

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

1 participant