Skip to content

Commit

Permalink
Merge pull request #159 from onerandomusername/fix-precommit
Browse files Browse the repository at this point in the history
run pre-commit in gha workflows
  • Loading branch information
Akarys42 authored Dec 26, 2021
2 parents e1054fa + d0b1610 commit fe42628
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/lint-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ jobs:
pip install poetry
poetry install
# We will not run `black` or `flake8` here, as we will use a separate
# black and flake8 action. As pre-commit does not support user installs,
# we set PIP_USER=0 to not do a user install.
- name: Run pre-commit hooks
id: pre-commit
run: export PIP_USER=0; SKIP="black,flake8" poetry run pre-commit run --all-files

# Run flake8 and have it format the linting errors in the format of
# the GitHub Workflow command to register error annotations. This
# means that our flake8 output is automatically added as an error
Expand All @@ -48,11 +55,16 @@ jobs:
# Format used:
# ::error file={filename},line={line},col={col}::{message}
- name: Run flake8
# this check ensures that black always runs if the pre-commit step ran
# Its best to only have to fix pre-commit once than twice
if: always() && (steps.pre-commit.outcome == 'success' || steps.pre-commit.outcome == 'failure')
run: "poetry run flake8 \
--format='::error file=%(path)s,line=%(row)d,col=%(col)d::[flake8] %(code)s: %(text)s'"

# Run black
- name: Run black
# see flake8's comment above
if: always() && (steps.pre-commit.outcome == 'success' || steps.pre-commit.outcome == 'failure')
run: poetry run black . --check --diff

# Prepare the Pull Request Payload artifact. If this fails, we
Expand Down

0 comments on commit fe42628

Please sign in to comment.