Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update python and move package to uv #67

Merged
merged 23 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .cspell/custom-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ imwrite
Interp
ipykernel
ipympl
ipynb
ipython
ipywidgets
irfft
isin
kernelspec
kwds
labview
Expand Down Expand Up @@ -104,6 +106,7 @@ pcolormesh
Phoibos
polyfit
polyval
pydata
pyenv
pygments
pynxtools
Expand Down Expand Up @@ -132,6 +135,7 @@ typehints
TZCYXS
undoc
venv
viewcode
vline
vmax
vmin
Expand Down
136 changes: 86 additions & 50 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,46 @@ on:
push:
branches: [ main ]
paths:
- specsanalyzer/**/*
- specsscan/**/*
- src/specsanalyzer/**/*
- src/specsscan/**/*
- tutorial/**
- .github/workflows/documentation.yml
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:


# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
env:
UV_SYSTEM_PYTHON: true

jobs:
build:
runs-on: ubuntu-latest
steps:
# Check out repo and set up Python
- name: Check out the repository
uses: actions/checkout@v4
# Check out repo and set up Python
- uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0

# see https://stackoverflow.com/questions/57612428/cloning-private-github-repository-within-organisation-in-actions and https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key
- name: checkout test data
- name: Fetch test data
run: |
eval `ssh-agent -s`
ssh-add - <<< '${{ secrets.TEST_DATA_ACCESS_KEY }}'
git submodule sync --recursive
git submodule update --init --recursive
git submodule update --init --recursive --jobs=4

# Use cached python and dependencies, install poetry
- name: "Setup Python, Poetry and Dependencies"
uses: packetcoders/action-setup-cache-python-poetry@main
# Setup python
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.8
poetry-version: 1.8.5
python-version: "3.10"

- name: Install dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Install notebook dependencies
run: poetry install -E notebook --with docs
- name: Install package
run: |
uv pip install ".[docs,notebook]"

- name: Install pandoc
run: |
Expand All @@ -61,37 +54,80 @@ jobs:
- name: copy tutorial files to docs
run: |
cp -r $GITHUB_WORKSPACE/tutorial $GITHUB_WORKSPACE/docs/
cp -r $GITHUB_WORKSPACE/specsscan/config $GITHUB_WORKSPACE/docs/specsscan/
mkdir $GITHUB_WORKSPACE/docs/tests
cp -r $GITHUB_WORKSPACE/tests/data $GITHUB_WORKSPACE/docs/tests/

# To be included later
# - name: Cache docs build
# id: cache-docs
# uses: actions/cache@v3
# with:
# path: $GITHUB_WORKSPACE/_build
# key: ${{ runner.os }}-docs
mkdir -p $GITHUB_WORKSPACE/docs/src/specsscan
cp -r $GITHUB_WORKSPACE/src/specsscan/config $GITHUB_WORKSPACE/docs/src/specsscan

- name: build Sphinx docs
run: poetry run sphinx-build -b html $GITHUB_WORKSPACE/docs $GITHUB_WORKSPACE/_build

- name: Setup Pages
uses: actions/configure-pages@v3
run: sphinx-build -b html $GITHUB_WORKSPACE/docs $GITHUB_WORKSPACE/_build

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-artifact@v4
with:
path: '_build'
name: sphinx-docs
path: _build

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# this job pushes the built documentation to the docs repository
push:
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
- name: Checkout docs repo
uses: actions/checkout@v2
with:
repository: ${{ github.repository_owner }}/docs
token: ${{ secrets.GITHUB_TOKEN }}
path: 'docs-repo'

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Setup SSH
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_DOCS_DEPLOY_KEY }}

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: sphinx-docs
path: sphinx-docs

- name: Determine version folder
id: version-folder
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
echo "folder=specsanalyzer/$VERSION" >> $GITHUB_OUTPUT
rm docs-repo/specsanalyzer/stable
ln -s -r docs-repo/specsanalyzer/$VERSION docs-repo/specsanalyzer/stable
elif [[ $GITHUB_REF == refs/heads/main ]]; then
echo "folder=specsanalyzer/latest" >> $GITHUB_OUTPUT
else
echo "folder=specsanalyzer/develop" >> $GITHUB_OUTPUT
fi

- name: Update switcher.json
run: |
VERSION=`grep "<title>" sphinx-docs/index.html | sed -n 's/.*specsanalyzer \(.*\) documentation.*/\1/p'`
echo "python docs-repo/specsanalyzer/update_switcher.py docs-repo/specsanalyzer/switcher.json $GITHUB_REF $VERSION"
python docs-repo/specsanalyzer/update_switcher.py docs-repo/specsanalyzer/switcher.json $GITHUB_REF $VERSION

- name: Copy documentation to the right version folder
run: |
mkdir -p docs-repo/${{ steps.version-folder.outputs.folder }}
cp -r sphinx-docs/* docs-repo/${{ steps.version-folder.outputs.folder }}
rm -rf docs-repo/${{ steps.version-folder.outputs.folder }}/.doctrees
rm -rf docs-repo/${{ steps.version-folder.outputs.folder }}/tutorial/*.ipynb

- name: Push changes
run: |
cd docs-repo
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "Update documentation"
git push
33 changes: 20 additions & 13 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,49 @@ on:
paths-ignore:
pyproject.toml

env:
UV_SYSTEM_PYTHON: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
# Check out repo and set up Python
- uses: actions/checkout@v3
with:
lfs: true
- uses: actions/checkout@v4

# see https://stackoverflow.com/questions/57612428/cloning-private-github-repository-within-organisation-in-actions and https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key
- name: checkout test data
- name: Fetch test data
run: |
eval `ssh-agent -s`
ssh-add - <<< '${{ secrets.TEST_DATA_ACCESS_KEY }}'
git submodule sync --recursive
git submodule update --init --recursive
git submodule update --init --recursive --jobs=4

# Use cached python and dependencies, install poetry
- name: "Setup Python, Poetry and Dependencies"
uses: packetcoders/action-setup-cache-python-poetry@main
# Setup python
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.8
poetry-version: 1.8.5
python-version: "3.10"

- name: Install dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Install package
run: |
uv pip install ".[dev]"
# Linting steps, execute all linters even if one fails
- name: ruff
run:
poetry run ruff specsanalyzer specsscan tests
ruff check src/specsanalyzer src/specsscan tests
- name: ruff formatting
if: ${{ always() }}
run:
poetry run ruff format --check specsanalyzer specsscan tests
ruff format --check src/specsanalyzer src/specsscan tests
- name: mypy
if: ${{ always() }}
run:
poetry run mypy specsanalyzer specsscan tests
mypy src/specsanalyzer src/specsscan tests
- name: spellcheck
if: ${{ always() }}
uses: streetsidesoftware/cspell-action@v6
Expand Down
Loading
Loading