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

✨ Migrate from Poetry to UV for build System #234

Merged
merged 28 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
399b8d2
:recycle: migrate from Poetry to Hatch for build system
yezz123 Dec 23, 2024
1f9e280
:fire: remove Poetry configuration across multiple modules
yezz123 Dec 23, 2024
ec32da5
:recycle: update project dependencies to use direct paths and migrate…
yezz123 Dec 24, 2024
630b145
:recycle: migrate from Poetry to uv for dependency management and upd…
yezz123 Dec 24, 2024
f1b2b1c
update abis
EvolveArt Dec 24, 2024
9518085
update abis
EvolveArt Dec 24, 2024
8798af7
:bug: exclude JSON files from end-of-file fixer in pre-commit configu…
yezz123 Dec 24, 2024
c0f3641
:bug: fix missing dependencies
yezz123 Dec 24, 2024
d2f488c
:recycle: update dependencies across multiple projects for consistenc…
yezz123 Dec 24, 2024
9f5adb8
:recycle: update dependency versions for consistency and compatibility
yezz123 Dec 24, 2024
73043fd
:bug: update pytest configuration for async fixtures and improve even…
yezz123 Dec 24, 2024
454ffc7
fix: checkpointer test
EvolveArt Dec 24, 2024
a89b0eb
:bug: add pytest configuration for asyncio and improve event loop man…
yezz123 Dec 24, 2024
ceb7fed
:bug: fix checkpointer tests
yezz123 Dec 24, 2024
25f2bc0
:bug: fix event loop scope in fixtures and update fixture parameters
yezz123 Dec 24, 2024
f64e402
Merge branch 'dependencies-migration' of https://github.com/Astraly-L…
EvolveArt Dec 24, 2024
20150d4
fix: deploy oracle fixture
EvolveArt Dec 24, 2024
a3548a7
:sparkles: fix Linting issue
yezz123 Dec 24, 2024
c91d4ff
fix: okx future fetcher test
EvolveArt Dec 25, 2024
1d00c89
feat: add Docker image build workflow and integrate with pull request…
yezz123 Dec 25, 2024
a3488ff
:bug: specify Dockerfile path in docker-test workflow
yezz123 Dec 25, 2024
2995166
:recycle: remove `merkle-maker` from docker-test workflow package matrix
yezz123 Dec 25, 2024
528252b
:sparkles: update Dockerfile to install pipx correctly and improve st…
yezz123 Dec 25, 2024
f7a0194
:recycle: streamline Dockerfile by consolidating dependency
yezz123 Dec 25, 2024
c67d1c3
:recycle: update Dockerfile to install uv from GitHub and streamline …
yezz123 Dec 25, 2024
b75fce4
:recycle: refactor Dockerfiles to standardize build stages and improv…
yezz123 Dec 25, 2024
800cef9
:recycle: update workflows to standardize package version extraction …
yezz123 Dec 25, 2024
fb1c34c
:sparkles: fix the current version of the SDK
yezz123 Dec 26, 2024
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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
TESTNET_ACCOUNT_ADDRESS=
TESTNET_PRIVATE_KEY=
TESTNET_PRIVATE_KEY=
3 changes: 2 additions & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:

- name: Extract package version
run: |
export PACKAGE_VERSION=$(grep 'version = "' ./${{ matrix.package }}/pyproject.toml | grep -m 1 -e '[0-9][0-9a-zA-Z]*[-.a-z0-9]*' -o)
PKG_PATH=$(echo ${{ matrix.package }} | tr '-' '_')
export PACKAGE_VERSION=$(grep -o '".*"' ./${{ matrix.package }}/$PKG_PATH/__init__.py | tr -d '"')
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo $PACKAGE_VERSION

Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Task - Build Docker Image

on:
workflow_dispatch:
workflow_call:

jobs:
build_containers:
strategy:
matrix:
package: [pragma-sdk, price-pusher, vrf-listener, checkpointer]
runs-on: ubuntu-latest
permissions:
checks: write
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Extract package version
if: matrix.package == 'pragma-sdk'
run: |
PKG_PATH=$(echo ${{ matrix.package }} | tr '-' '_')
export PACKAGE_VERSION=$(grep -o '".*"' ./${{ matrix.package }}/$PKG_PATH/__init__.py | tr -d '"')
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo $PACKAGE_VERSION
- name: Build Docker Image
id: docker_build
uses: docker/[email protected]
with:
context: .
file: ./${{ matrix.package }}/Dockerfile
build-args: ${{ matrix.package == 'pragma-sdk' && format('PRAGMA_PACKAGE_VERSION={0}', env.PACKAGE_VERSION) || '' }}
56 changes: 14 additions & 42 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,29 @@
---
name: Task - Lint, Format & Typecheck

on:
workflow_dispatch:
workflow_call:

env:
PYTHON_VERSION: 3.12.4
PYTHON_VERSION: 3.12

jobs:
lint-format-typecheck:
continue-on-error: true
lint:
runs-on: ubuntu-latest
strategy:
matrix:
package:
[
pragma-utils,
pragma-sdk,
price-pusher,
vrf-listener,
checkpointer,
merkle-maker,
lp-pricer,
]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: CfirTsabari/actions-pipx@v1
- name: Install poetry
run: pipx install poetry
- name: Set up Python 3.12.4
uses: actions/setup-python@v4
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
enable-cache: true

- name: Install dependencies
run: |
cd ${{ matrix.package }}
poetry install
- name: Check poetry.lock
run: |
cd ${{ matrix.package }}
poetry lock --check
- name: Run lint
run: |
cd ${{ matrix.package }}
poetry run poe lint
- name: Run format
run: |
cd ${{ matrix.package }}
poetry run poe format_check
- name: Run typecheck
run: |
cd ${{ matrix.package }}
poetry run poe typecheck
run: uv sync --python ${{ env.PYTHON_VERSION }} --all-extras

- uses: pre-commit/[email protected]
with:
extra_args: --all-files --verbose
env:
SKIP: no-commit-to-branch
31 changes: 21 additions & 10 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,26 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: CfirTsabari/actions-pipx@v1
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5

- name: set up python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- run: pipx inject poetry poetry-monorepo-dependency-plugin
- run: poetry config repositories.test-pypi https://test.pypi.org/legacy/
- run: poetry config pypi-token.test-pypi ${{ secrets.TEST_PYPI_API_TOKEN }}
- run: poetry build -f sdist
- run: poetry publish -r test-pypi --skip-existing

- name: install
run: pip install -U build

- name: check version
id: check-tag
uses: samuelcolvin/[email protected]
with:
version_file_path: pragma_sdk/__init__.py

- name: build
run: python -m build

- name: Upload package to PyPI
uses: pypa/[email protected]
with:
repository-url: https://test.pypi.org/legacy/
password: ${{ secrets.PYPI_API_TOKEN }}
74 changes: 15 additions & 59 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,26 @@ defaults:
run:
working-directory: pragma-sdk

env:
PYTHON_VERSION: 3.12.4

jobs:
bump_version:
release:
name: Pypi Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Commitizen
run: pip install --upgrade Commitizen
- name: Configure Git
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Bump version
run: |
git fetch --tags
cz bump --retry || echo "probably nothing to do"
- name: Push changes
run: |
TAG=$(git tag --points-at HEAD)
if [[ $TAG ]]; then
echo "Version bumped to $TAG"
git push
git push --tags
else
echo "Version NOT bumped"
fi
enable-cache: true

pypi_publish:
needs: [bump_version]
name: Upload package to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: CfirTsabari/actions-pipx@v1
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
- name: check GITHUB_REF matches package version
uses: samuelcolvin/[email protected]
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- run: pipx inject poetry poetry-monorepo-dependency-plugin
- run: poetry config pypi-token.pypi "${{ secrets.PYPI_API_KEY }}"
- run: poetry build -f sdist
- run: poetry publish --skip-existing
version_file_path: pragma_sdk/__init__.py

update_lock:
needs: [pypi_publish]
name: Update lock file
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: CfirTsabari/actions-pipx@v1
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
- run: uv build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- run: sh scripts/poetry_lock_update.sh
password: ${{ secrets.PYPI_API_KEY }}
skip-existing: true
4 changes: 4 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ jobs:
tests:
name: Build & Integration Tests
uses: ./.github/workflows/tests.yml

build_containers:
name: Build Docker Image
uses: ./.github/workflows/docker-test.yml
34 changes: 15 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_call:

env:
PYTHON_VERSION: 3.12.4
PYTHON_VERSION: 3.12

jobs:
tests:
Expand All @@ -26,27 +26,23 @@ jobs:
]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: "true"
- uses: CfirTsabari/actions-pipx@v1
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
- uses: astral-sh/setup-uv@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
enable-cache: true
- name: Install dependencies
run: |
cd ${{ matrix.package }}
poetry install
uv sync --python ${{ env.PYTHON_VERSION }} --all-extras

- name: Cache contracts
id: cache-contracts
uses: actions/cache@v3
with:
path: ./pragma-oracle/pragma-oracle/target
key: ${{ runner.os }}-contracts-${{ hashFiles('./pragma-oracle/pragma-oracle/src', 'poetry.lock') }}
key: ${{ runner.os }}-contracts-${{ hashFiles('./pragma-oracle/pragma-oracle/src') }}

- uses: software-mansion/setup-scarb@v1
with:
Expand All @@ -66,7 +62,7 @@ jobs:
# Extract the relative path of the file for comparison
rel_path=${file#./pragma-oracle/pragma-oracle/target/dev}
# Use diff to compare the file with its counterpart in the SDK directory
diff "$file" "pragma-sdk/pragma_sdk/onchain/abis$rel_path" || (echo "Error: $rel_path in pragma-oracle/target does not match with pragma-sdk/pragma_sdk/onchain/abis/" && exit 1)
diff "$file" "pragma-sdk/pragma_sdk/onchain/abis$rel_path" || (echo "Error: $rel_path in pragma-oracle/target does not match with pragma-sdk/pragma_sdk/onchain/abis/" && exit 1)
done
- name: Install rust
run: |
Expand All @@ -87,19 +83,19 @@ jobs:
# See: https://github.com/astraly-labs/pragma-sdk/issues/153
cd ${{ matrix.package }}
if [ "${{ matrix.package }}" = "pragma-sdk" ]; then
poetry run poe test_client
poetry run poe test_vrf
poetry run poe test_fetchers
poetry run poe test_merkle_feed
poetry run poe test_unit
poetry run poe test_update_client
uv run poe test_client
uv run poe test_vrf
uv run poe test_fetchers
uv run poe test_merkle_feed
uv run poe test_unit
uv run poe test_update_client
else
poetry run poe test
uv run poe test
fi
- name: Generate coverage in XML
run: |
cd ${{ matrix.package }}
poetry run coverage xml
uv run coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
env:
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "pragma-oracle"]
path = pragma-oracle
url = https://github.com/Astraly-Labs/pragma-oracle.git
url = https://github.com/Astraly-Labs/pragma-oracle.git
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-toml
- id: check-yaml
args: [ --allow-multiple-documents ]
- id: end-of-file-fixer
exclude: '.*\.json$'
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.1
hooks:
- id: ruff
args:
- --fix
- id: ruff-format
11 changes: 5 additions & 6 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ build:
python: "3.12"
jobs:
post_create_environment:
# Install poetry
# https://python-poetry.org/docs/#installing-manually
- python -m pip install poetry
# Install uv
# https://docs.astral.sh/uv/
- python -m pip install uv
post_install:
# Install only dependencies including docs
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
- cd pragma-sdk && VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs && cd ..
- cd pragma-sdk && VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH uv sync --all-extras && cd ..

sphinx:
configuration: pragma-sdk/docs/source/conf.py
fail_on_warning: true
fail_on_warning: true
Loading
Loading