Claude Mosaiq demo #2320
Workflow file for this run
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: Library | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
release: | |
types: | |
- created | |
jobs: | |
# ============================================================================= | |
PreCommit: | |
# if: false | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
timeout-minutes: 60 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pre-commit | |
key: pre-commit-cache | |
- name: Run Pre-Commit | |
run: | | |
pip install pre-commit | |
pre-commit run --all-files | |
- name: Fix any issues | |
id: fix_issues | |
if: failure() | |
run: | | |
git config --local user.email "pre-commit-bot@pymedphys.com" | |
git config --local user.name "PyMedPhys Pre-Commit Bot" | |
git add -A | |
git stash | |
git checkout $GITHUB_HEAD_REF | |
git pull | |
pre-commit run --all-files || true | |
git commit -m "Fix pre-commit failures" -a | |
- name: Get GitHub App token for installation | |
id: generate-token | |
if: failure() && steps.fix_issues.outcome == 'success' | |
uses: tibdex/github-app-token@v2.1.0 | |
with: | |
app_id: ${{ secrets.PYMEDPHYS_CI_BOT_ID }} | |
private_key: ${{ secrets.PYMEDPHYS_CI_BOT_TOKEN }} | |
- name: Push changes | |
if: failure() && steps.fix_issues.outcome == 'success' | |
uses: ad-m/github-push-action@v0.8.0 | |
with: | |
github_token: ${{ steps.generate-token.outputs.token }} | |
branch: ${{ github.event.pull_request.head.ref }} | |
# ============================================================================= | |
Tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ["ubuntu", "macos", "windows"] | |
task: | |
[ | |
"tests", | |
"docs", | |
"stackoverflow", | |
"updates", | |
"cypress", | |
"slow", | |
"pyright", | |
"propagate", | |
] | |
exclude: | |
- os: "windows" | |
task: "stackoverflow" | |
- os: "windows" | |
task: "updates" | |
- os: "windows" | |
task: "slow" | |
- os: "windows" | |
task: "pyright" | |
- os: "windows" | |
task: "propagate" | |
- os: "windows" | |
task: "cypress" | |
- os: "macos" | |
task: "stackoverflow" | |
- os: "macos" | |
task: "updates" | |
- os: "macos" | |
task: "cypress" | |
- os: "macos" | |
task: "slow" | |
- os: "macos" | |
task: "pyright" | |
- os: "macos" | |
task: "propagate" | |
include: | |
# Spread the below across the range of supported Python versions. | |
- os: "ubuntu" | |
python-version: "3.11" # TODO: Upgrade this to 3.12 | |
- os: "windows" | |
python-version: "3.10" | |
- os: "macos" | |
python-version: "3.9" | |
runs-on: ${{ matrix.os }}-latest | |
timeout-minutes: 60 | |
steps: | |
- uses: actions/checkout@v4 | |
if: matrix.task != 'propagate' | |
- uses: actions/checkout@v4 | |
if: matrix.task == 'propagate' | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Get full Python version | |
id: full-python-version | |
shell: bash | |
run: | | |
echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT | |
# ----------------------------------------------------------------------------- | |
# Set up pip | |
- name: Get pip cache dir | |
id: pip-cache | |
shell: bash | |
run: | | |
python -m pip install -U pip # to ensure version > 20 to have cache dir | |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT | |
- name: Pip Cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
key: pip-${{ matrix.task }}-${{ runner.os }}-${{ steps.full-python-version.outputs.version }} | |
# ----------------------------------------------------------------------------- | |
# Upgrade pip and setuptools, and install poetry | |
- name: Upgrade pip and setuptools | |
run: | | |
pip install --upgrade pip setuptools | |
- name: Install Poetry | |
uses: snok/install-poetry@v1.3.4 | |
with: | |
version: 1.7.1 | |
virtualenvs-create: true | |
- name: Update PATH in Windows | |
if: matrix.os == 'windows' | |
run: | | |
Add-Content -Path $env:GITHUB_PATH -Value "$env:USERPROFILE\.local\bin" | |
Get-Content -Path $env:GITHUB_PATH | |
# ----------------------------------------------------------------------------- | |
# No import and run CLI with no dependencies | |
- name: Build wheel | |
if: matrix.task == 'tests' | |
run: | | |
poetry build --format wheel | |
- name: Install wheel | |
if: matrix.task == 'tests' && matrix.os == 'windows' | |
run: | | |
python -m pip install (Get-Item .\dist\*.whl) | |
- name: Install wheel | |
if: matrix.task == 'tests' && matrix.os != 'windows' | |
run: | | |
python -m pip install ./dist/*.whl | |
- name: Run clean tests | |
if: matrix.task == 'tests' | |
run: | | |
pymedphys --help | |
python -c "import pymedphys" | |
python -c "import pymedphys.beta" | |
python -c "import pymedphys.experimental" | |
# Remove confusion for tests down the line | |
- name: Remove base install of pymedphys | |
if: matrix.task == 'tests' | |
run: | | |
pip uninstall -y pymedphys | |
# ----------------------------------------------------------------------------- | |
# Set up Poetry | |
- name: Configure poetry | |
run: | | |
poetry config virtualenvs.in-project true | |
- name: Poetry Cache | |
uses: actions/cache@v3 | |
id: poetry-cache | |
with: | |
path: .venv | |
key: venv-${{ matrix.task }}-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} | |
# This is from <https://github.com/python-poetry/poetry/blob/639d5e057/.github/workflows/main.yml#L57-L60> | |
- name: Ensure cache is healthy | |
if: steps.poetry-cache.outputs.cache-hit == 'true' | |
shell: bash | |
run: | | |
timeout 10s poetry run pip --version || rm -rf .venv | |
# Install Node | |
- uses: actions/setup-node@v3 | |
if: matrix.task == 'cypress' || matrix.task == 'pyright' || matrix.task == 'build' | |
with: | |
node-version: "14" | |
# cache: "yarn" # TODO: Sort out this cache parameter | |
# ----------------------------------------------------------------------------- | |
## Plain install | |
- name: Install a plain environment | |
if: matrix.task == 'stackoverflow' | |
run: | | |
poetry install -E user | |
## Install with Documentation Environment | |
- name: Install a docs environment | |
if: matrix.task == 'docs' | |
run: | | |
poetry install -E docs | |
## Install with Tests Environment | |
# TODO: Redesign CI to be more efficient once this issue lands python-poetry/poetry#4842 | |
- name: Install a tests/doctests environment | |
if: matrix.task == 'tests' || matrix.task == 'cypress' || matrix.task == 'slow' || matrix.task == 'pyright' | |
run: | | |
poetry install -E user -E tests -E doctests | |
## Install remaining packages for pyright | |
- name: Install a propagate environment | |
if: matrix.task == 'pyright' || matrix.task == 'propagate' | |
run: | | |
poetry install -E propagate || poetry lock --no-update && poetry install -E propagate | |
## Update all packages and then install with tests environment | |
- name: Update all packages then install with tests and user environment | |
if: matrix.task == 'updates' | |
run: | | |
poetry install -E user -E tests -E docs | |
poetry update | |
poetry install -E user -E tests -E docs | |
# ----------------------------------------------------------------------------- | |
# PyMedPhys Data Cache | |
- name: Get PyMedPhys cache directory | |
id: pymedphys-cache-location | |
if: matrix.task != 'pyright' | |
shell: bash | |
run: | | |
echo "dir=$(poetry run python -c 'import pymedphys._config as cf; print(str(cf.get_config_dir()))')" >> $GITHUB_OUTPUT | |
- name: PyMedPhys Cache | |
id: pymedphys-cache | |
if: matrix.task != 'pyright' | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.pymedphys-cache-location.outputs.dir }} | |
key: pymedphys-${{ matrix.task }}-${{ runner.os }}-${{ hashFiles('**/hashes.json') }} | |
# ----------------------------------------------------------------------------- | |
# TESTS | |
## Propagate | |
- name: See if propagate is needed | |
if: matrix.task == 'propagate' | |
id: propagate-test | |
shell: bash | |
run: | | |
echo "status=before" >> $GITHUB_OUTPUT | |
poetry check | |
## Pyright | |
- name: Install and run pyright | |
if: matrix.task == 'pyright' | |
run: | | |
npm install -g pyright | |
poetry run pyright | |
## Pytest | |
- name: Run basic pytest tests | |
if: matrix.task == 'tests' || matrix.task == 'updates' | |
run: | | |
poetry run pymedphys dev tests -v | |
## Doctest | |
- name: Run doctest tests | |
if: matrix.os == 'ubuntu' && matrix.task == 'tests' | |
run: | | |
poetry run pymedphys dev doctests -v | |
## Pylint | |
- name: Run pylint tests | |
if: matrix.os == 'ubuntu' && ( matrix.task == 'tests' || matrix.task == 'updates' ) | |
run: | | |
poetry run pymedphys dev lint | |
## Slow | |
- name: Run slow tests | |
if: matrix.task == 'slow' | |
run: | | |
poetry run pymedphys dev tests -v --slow | |
## Docs | |
- name: Download docs files | |
if: matrix.task == 'docs' && matrix.os == 'ubuntu' | |
run: | | |
poetry run python -c "import pymedphys; pymedphys.data_path('original_dose_beam_4.dcm'); pymedphys.data_path('logfile_dose_beam_4.dcm');" | |
- name: Build docs | |
if: matrix.task == 'docs' || matrix.task == 'updates' | |
run: | | |
poetry run pymedphys dev docs | |
- name: Add GitHub Pages Config Files | |
if: matrix.task == 'docs' && matrix.os == 'ubuntu' && github.event_name == 'push' | |
run: | | |
echo docs.pymedphys.com > lib/pymedphys/docs/_build/html/CNAME | |
touch lib/pymedphys/docs/_build/html/.nojekyll | |
- name: Deploy docs | |
if: matrix.task == 'docs' && matrix.os == 'ubuntu' && github.event_name == 'push' | |
uses: JamesIves/github-pages-deploy-action@4.1.3 | |
with: | |
branch: docs | |
folder: lib/pymedphys/docs/_build/html | |
ssh-key: ${{ secrets.DEPLOY_KEY }} | |
## Stackoverflow | |
- name: Run stackoverflow example(s) | |
if: matrix.task == 'stackoverflow' | |
run: | | |
poetry run python ./examples/stackoverflow/gamma.py | |
## Cypress | |
- name: Run Cypress tests | |
if: matrix.task == 'cypress' | |
run: | | |
poetry run pymedphys dev tests --cypress | |
- uses: actions/upload-artifact@v2 | |
if: failure() && matrix.task == 'cypress' | |
with: | |
name: cypress-videos | |
path: pymedphys/tests/e2e/cypress/videos |