-
Notifications
You must be signed in to change notification settings - Fork 2
63 lines (51 loc) · 1.7 KB
/
pre-commit-self-hosted.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: pre-commit-self-hosted
on:
push:
pull_request:
workflow_dispatch:
jobs:
lint:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
name: Check code style
runs-on: self-hosted
strategy:
fail-fast: false
defaults:
run:
shell: bash -l -vxeo pipefail {0}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Install dev dependencies
run: |
python3 -m pip install pre-commit black isort
python3 -m pip list
- name: Run pre-commit
run: |
pre-commit run --all-files --show-diff
- name: Python/IPython info
run: |
which python
python -VV
which ipython
ipython -V
- name: Test the code
run: |
cd ~/.ipython/profile_collection/
# This is what IPython does internally to load the startup files:
command="
import os
import glob
ip = get_ipython()
startup_files = sorted(glob.glob(os.path.join(os.getcwd(), 'startup/*.py')))
if os.path.isfile('.ci/drop-in.py'):
startup_files.append('.ci/drop-in.py')
if not startup_files:
raise SystemExit(f'Cannot find any startup files in {os.getcwd()}')
for f in startup_files:
if not os.path.isfile(f):
raise FileNotFoundError(f'File {f} cannot be found.')
print(f'Executing {f} in CI')
ip.parent._exec_file(f)"
ipython --profile=test -c "$command"