Skip to content

CI: add IPython testing step #6

CI: add IPython testing step

CI: add IPython testing step #6

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: |
# 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=collection -c "$command"