Skip to content

Commit 713cb36

Browse files
authored
Merge pull request #800 from kevin1024/pre-commit-ci
Start using pre-commit in CI
2 parents 88cf01a + b0cb876 commit 713cb36

File tree

13 files changed

+128
-52
lines changed

13 files changed

+128
-52
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/setup-python@v5
1515
with:
1616
python-version: "3.12"
17-
17+
1818
- name: Install build dependencies
1919
run: pip install -r docs/requirements.txt
2020
- name: Rendering HTML documentation

.github/workflows/lint.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Copyright (c) 2023 Sebastian Pipping <[email protected]>
2+
# Licensed under the MIT license
3+
4+
name: Detect outdated pre-commit hooks
5+
6+
on:
7+
schedule:
8+
- cron: '0 16 * * 5' # Every Friday 4pm
9+
10+
# NOTE: This will drop all permissions from GITHUB_TOKEN except metadata read,
11+
# and then (re)add the ones listed below:
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
jobs:
17+
pre_commit_detect_outdated:
18+
name: Detect outdated pre-commit hooks
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Python 3.12
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: 3.12
27+
28+
- name: Install pre-commit
29+
run: |-
30+
pip install \
31+
--disable-pip-version-check \
32+
--no-warn-script-location \
33+
--user \
34+
pre-commit
35+
echo "PATH=${HOME}/.local/bin:${PATH}" >> "${GITHUB_ENV}"
36+
37+
- name: Check for outdated hooks
38+
run: |-
39+
pre-commit autoupdate
40+
git diff -- .pre-commit-config.yaml
41+
42+
- name: Create pull request from changes (if any)
43+
id: create-pull-request
44+
uses: peter-evans/create-pull-request@v5
45+
with:
46+
author: 'pre-commit <[email protected]>'
47+
base: master
48+
body: |-
49+
For your consideration.
50+
51+
: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.
52+
branch: precommit-autoupdate
53+
commit-message: "pre-commit: Autoupdate"
54+
delete-branch: true
55+
draft: true
56+
labels: enhancement
57+
title: "pre-commit: Autoupdate"
58+
59+
- name: Log pull request URL
60+
if: "${{ steps.create-pull-request.outputs.pull-request-url }}"
61+
run: |
62+
echo "Pull request URL is: ${{ steps.create-pull-request.outputs.pull-request-url }}"

.github/workflows/pre-commit.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2023 Sebastian Pipping <[email protected]>
2+
# Licensed under the MIT license
3+
4+
name: Run pre-commit
5+
6+
on:
7+
- pull_request
8+
- push
9+
- workflow_dispatch
10+
11+
jobs:
12+
pre-commit:
13+
name: Run pre-commit
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-python@v4
18+
with:
19+
python-version: 3.12
20+
- uses: pre-commit/[email protected]

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2023 Sebastian Pipping <[email protected]>
2+
# Licensed under the MIT license
3+
4+
repos:
5+
- repo: https://github.com/astral-sh/ruff-pre-commit
6+
rev: v0.1.7
7+
hooks:
8+
- id: ruff
9+
args: ["--show-source"]
10+
- id: ruff-format
11+
12+
- repo: https://github.com/pre-commit/pre-commit-hooks
13+
rev: v4.4.0
14+
hooks:
15+
- id: check-merge-conflict
16+
- id: end-of-file-fixer
17+
- id: trailing-whitespace

docs/_static/vcr.svg

Lines changed: 1 addition & 1 deletion
Loading

docs/advanced.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ a nice addition. Here's an example:
1616
with vcr.use_cassette('fixtures/vcr_cassettes/synopsis.yaml') as cass:
1717
response = urllib2.urlopen('http://www.zombo.com/').read()
1818
# cass should have 1 request inside it
19-
assert len(cass) == 1
19+
assert len(cass) == 1
2020
# the request uri should have been http://www.zombo.com/
2121
assert cass.requests[0].uri == 'http://www.zombo.com/'
2222
@@ -208,7 +208,7 @@ So these two calls are the same:
208208
209209
# original (still works)
210210
vcr = VCR(filter_headers=['authorization'])
211-
211+
212212
# new
213213
vcr = VCR(filter_headers=[('authorization', None)])
214214
@@ -218,7 +218,7 @@ Here are two examples of the new functionality:
218218
219219
# replace with a static value (most common)
220220
vcr = VCR(filter_headers=[('authorization', 'XXXXXX')])
221-
221+
222222
# replace with a callable, for example when testing
223223
# lots of different kinds of authorization.
224224
def replace_auth(key, value, request):
@@ -286,7 +286,7 @@ sensitive data from the response body:
286286
before_record_response=scrub_string(settings.USERNAME, 'username'),
287287
)
288288
with my_vcr.use_cassette('test.yml'):
289-
# your http code here
289+
# your http code here
290290
291291
292292
Decode compressed response

docs/changelog.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,3 @@ All help in providing PRs to close out bug issues is appreciated. Even if that i
287287
- Add support for requests / urllib3
288288
- 0.0.1
289289
- Initial Release
290-

runtests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# https://blog.ionelmc.ro/2015/04/14/tox-tricks-and-patterns/#when-it-inevitably-leads-to-shell-scripts
4-
# If you are getting an INVOCATION ERROR for this script then there is
4+
# If you are getting an INVOCATION ERROR for this script then there is
55
# a good chance you are running on Windows.
66
# You can and should use WSL for running tox on Windows when it calls bash scripts.
77
REQUESTS_CA_BUNDLE=`python3 -m pytest_httpbin.certs` exec pytest "$@"

tests/fixtures/migration/new_cassette.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
},
1616
"response": {
1717
"status": {
18-
"message": "OK",
18+
"message": "OK",
1919
"code": 200
20-
},
20+
},
2121
"headers": {
2222
"access-control-allow-origin": ["*"],
2323
"content-type": ["application/json"],
2424
"date": ["Mon, 21 Apr 2014 23:13:40 GMT"],
2525
"server": ["gunicorn/0.17.4"],
2626
"content-length": ["32"],
2727
"connection": ["keep-alive"]
28-
},
28+
},
2929
"body": {
3030
"string": "{\n \"origin\": \"217.122.164.194\"\n}"
3131
}

0 commit comments

Comments
 (0)