-
-
Notifications
You must be signed in to change notification settings - Fork 24
Migrate morango to uv for package management #296
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,38 @@ | ||
| name: Docs | ||
|
|
||
| on: [push, pull_request] | ||
|
|
||
| jobs: | ||
| pre_job: | ||
| name: Path match check | ||
| runs-on: ubuntu-latest | ||
| # Map a step output to a job output | ||
| outputs: | ||
| should_skip: ${{ steps.skip_check.outputs.should_skip }} | ||
| steps: | ||
| - id: skip_check | ||
| uses: fkirc/skip-duplicate-actions@master | ||
| with: | ||
| github_token: ${{ github.token }} | ||
| paths: '["docs/**", "requirements/docs.txt"]' | ||
| docs: | ||
| name: Checking docs build | ||
| needs: pre_job | ||
| if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: 3.9 | ||
| - name: pip cache | ||
| uses: actions/cache@v5 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-docs-${{ hashFiles('requirements/docs.txt') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pip-docs | ||
| - name: Install system dependencies | ||
| run: | | ||
| sudo apt-get -y -qq update | ||
| sudo apt-get install -y swig openssl libssl-dev | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements/docs.txt | ||
| pip install -e . | ||
| - name: Check Docs build | ||
| run: make docs | ||
| pre_job: | ||
| name: Path match check | ||
| runs-on: ubuntu-latest | ||
| # Map a step output to a job output | ||
| outputs: | ||
| should_skip: ${{ steps.skip_check.outputs.should_skip }} | ||
| steps: | ||
| - id: skip_check | ||
| uses: fkirc/skip-duplicate-actions@master | ||
| with: | ||
| github_token: ${{ github.token }} | ||
| paths: '["docs/**", "pyproject.toml"]' | ||
| docs: | ||
| name: Checking docs build | ||
| needs: pre_job | ||
| if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Install system dependencies | ||
| run: | | ||
| sudo apt-get -y -qq update | ||
| sudo apt-get install -y swig openssl libssl-dev | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| python-version: 3.9 | ||
| activate-environment: "true" | ||
| enable-cache: "true" | ||
| - name: Install dependencies | ||
| run: uv sync --extra docs | ||
| - name: Check Docs build | ||
| run: make docs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,10 +12,34 @@ jobs: | |
| uses: fkirc/skip-duplicate-actions@master | ||
| with: | ||
| github_token: ${{ github.token }} | ||
| paths: '["morango/migrations/*.py", ".github/workflows/check_migrations_sqlite.yml", "setup.py", "requirements/*.txt"]' | ||
| paths: '["morango/migrations/*.py", ".github/workflows/check_migrations_sqlite.yml", "pyproject.toml"]' | ||
| build: | ||
| name: Build wheel | ||
| needs: pre_job | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Install uv | ||
| if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| python-version: 3.9 | ||
| enable-cache: "true" | ||
| - name: Build wheel | ||
| if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
| run: uv build --wheel | ||
| - name: Upload wheel artifact | ||
| if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: wheel | ||
| path: dist/*.whl | ||
| retention-days: 1 | ||
| migration_test: | ||
| name: SQLite migration tests | ||
| needs: pre_job | ||
| needs: [pre_job, build] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's a concern in morango - but once concern I've had in Kolibri is that our workflows are overly granular. I've experimented with having more top level "CI" in some repos recently - so that our CI checks become more of a cascade (make sure it builds first, then test kind of thing). With no good way in Github Actions to group workflows better, I am tempted to do more of this - but morango doesn't have enough for this to be a concern! |
||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: python:3.7-buster | ||
|
|
@@ -32,6 +56,13 @@ jobs: | |
| if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
| with: | ||
| lfs: true | ||
| fetch-depth: 0 | ||
| - name: Download wheel artifact | ||
| if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: wheel | ||
| path: dist/ | ||
| - name: Build SQLite 3.25.3 | ||
| if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
| run: | | ||
|
|
@@ -54,7 +85,7 @@ jobs: | |
| ${{ runner.os }}-pip- | ||
| - name: Install dependencies | ||
| if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
| run: pip install . | ||
| run: pip install $(ls dist/*.whl | head -n 1)[test] | ||
| - name: Run migrations | ||
| if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | ||
| run: python tests/testapp/manage.py migrate | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,26 @@ | ||
| # This workflow will upload a Python Package using Twine when a release is created | ||
| # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries | ||
|
|
||
| # This workflow uses actions that are not certified by GitHub. | ||
| # They are provided by a third-party and are governed by | ||
| # separate terms of service, privacy policy, and support | ||
| # documentation. | ||
| # This workflow will upload a Python Package using uv when a release is created | ||
| # uv provides fast, modern Python package building and publishing | ||
|
|
||
| name: Upload Python Package | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: 3.9 | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install setuptools wheel twine | ||
| - name: Build and publish | ||
| env: | ||
| TWINE_USERNAME: __token__ | ||
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
| run: | | ||
| python setup.py sdist bdist_wheel | ||
| twine upload dist/* | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| python-version: 3.9 | ||
| activate-environment: "true" | ||
| enable-cache: "true" | ||
| - name: Build package | ||
| run: uv build | ||
| - name: Publish package | ||
| env: | ||
| UV_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | ||
| run: uv publish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just want to see if i'm understanding this well from the reviewer guidance. so this part is new because it gives us more similarity (and.... therefore increased confidence?) to the build process for morango releases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is the result of the complexity in that with older versions of python, we can't simply use
pip install .for Morango having the more modernpyproject.toml. It needs more modern build tools that don't support older versions of python.Morango's build and publish always uses python 3.9, so this mimics that to create a wheel file which CAN be installed later (line 88):
$(ls dist/*.whl | head -n 1)this is just a subshell to use globbing sincepipwants a full file name[test]this tells pip to install thetestextras defined in thepyproject.tomlSo the result is that this is indeed more realistic tests by testing the wheel that we'd publish (built on 3.9) instead of building a wheel within each python version being tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting - this might make doing a parallel version in Kolibri slightly more challenging, because there we build the whl file in Python 3.6 to bundle the dependencies (I am sure we'll find a work around, but this is good extra context).