From 3f4b1ee8921b3c07a30dc0e550aa1cc1fc6655a2 Mon Sep 17 00:00:00 2001 From: Max Rakitin Date: Fri, 6 Sep 2024 16:39:47 -0400 Subject: [PATCH] CI: add IPython testing step --- .github/workflows/pre-commit-self-hosted.yml | 27 +++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pre-commit-self-hosted.yml b/.github/workflows/pre-commit-self-hosted.yml index b5d920a..9859d11 100644 --- a/.github/workflows/pre-commit-self-hosted.yml +++ b/.github/workflows/pre-commit-self-hosted.yml @@ -32,9 +32,30 @@ jobs: run: | pre-commit run --all-files --show-diff - - name: Test IPython + - name: Python/IPython info run: | + which python + python -VV + which ipython ipython -V - python -VV - ipython --profile=collection + + - 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"