-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from hartwork/replace-therapist-by-pre-commit
Replace Therapist by pre-commit + make GitHub Actions enforce pre-commit clean code (fixes #161)
- Loading branch information
Showing
7 changed files
with
109 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright (c) 2024 Sebastian Pipping <sebastian@pipping.org> | ||
# Licensed under the MIT license | ||
|
||
name: Detect outdated pre-commit hooks | ||
|
||
on: | ||
schedule: | ||
- cron: '0 18 * * 5' # Every Friday 6pm | ||
workflow_dispatch: | ||
|
||
# NOTE: This will drop all permissions from GITHUB_TOKEN except metadata read, | ||
# and then (re)add the ones listed below: | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
pre_commit_detect_outdated: | ||
name: Detect outdated pre-commit hooks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | ||
|
||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: Install pre-commit | ||
run: |- | ||
pip install \ | ||
--disable-pip-version-check \ | ||
--no-warn-script-location \ | ||
--user \ | ||
pre-commit | ||
echo "PATH=${HOME}/.local/bin:${PATH}" >> "${GITHUB_ENV}" | ||
- name: Check for outdated hooks | ||
run: |- | ||
pre-commit autoupdate | ||
git diff -- .pre-commit-config.yaml | ||
- name: Create pull request from changes (if any) | ||
id: create-pull-request | ||
uses: peter-evans/create-pull-request@c55203cfde3e5c11a452d352b4393e68b85b4533 # v6.0.3 | ||
with: | ||
author: 'pre-commit <pre-commit@tools.invalid>' | ||
base: master | ||
body: |- | ||
For your consideration. | ||
:warning: Please **CLOSE AND RE-OPEN** this pull request so that [further workflow runs get triggered](https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs) for this pull request. | ||
branch: precommit-autoupdate | ||
commit-message: "pre-commit: Autoupdate" | ||
delete-branch: true | ||
draft: true | ||
labels: enhancement | ||
title: "pre-commit: Autoupdate" | ||
|
||
- name: Log pull request URL | ||
if: "${{ steps.create-pull-request.outputs.pull-request-url }}" | ||
run: | | ||
echo "Pull request URL is: ${{ steps.create-pull-request.outputs.pull-request-url }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) 2024 Sebastian Pipping <sebastian@pipping.org> | ||
# Licensed under the MIT license | ||
|
||
name: Run pre-commit | ||
|
||
on: | ||
- pull_request | ||
- push | ||
- workflow_dispatch | ||
|
||
# Drop permissions to minimum for security | ||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
pre-commit: | ||
name: Run pre-commit | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | ||
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 | ||
with: | ||
python-version: 3.12 | ||
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 24.4.0 | ||
hooks: | ||
- id: black | ||
|
||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 7.0.0 | ||
hooks: | ||
- id: flake8 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
flake8==7.0.0 | ||
black==24.2.0 | ||
setuptools==69.1.1 | ||
therapist==2.0.1 | ||
pre-commit==3.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters