pre-commit #32
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
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 | |
testing: | |
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository | |
name: Test profile | |
runs-on: self-hosted | |
needs: [lint] | |
strategy: | |
fail-fast: false | |
defaults: | |
run: | |
shell: bash -l -eo pipefail {0} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
- name: Python/IPython info | |
run: | | |
which python | |
python -VV | |
which ipython | |
ipython -V | |
- name: Test the code | |
run: | | |
#cd ~/.ipython/profile_collection/ | |
cd /home/xf31id/test_fly/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" |