build: optimize dependencies management #278
Workflow file for this run
This file contains hidden or 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
| # This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
| name: Python tests | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| - "dev" | |
| - "feat/*" | |
| pull_request: | |
| branches: | |
| - "main" | |
| - "dev" | |
| - "feat/*" | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - "ubuntu-latest" | |
| - "windows-latest" | |
| - "macos-14" | |
| - "macos-15" | |
| # Ref: https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-where-your-workflow-runs/choosing-the-runner-for-a-job | |
| python-version: | |
| - "3.10" | |
| - "3.11" | |
| - "3.12" | |
| - "3.13" | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install poetry | |
| run: pipx install poetry | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'poetry' | |
| - name: Install main dependencies | |
| run: | | |
| poetry install --no-root --no-interaction | |
| - name: Check no top-level optional dependencies | |
| run: | | |
| poetry run python scripts/check_dependencies.py | |
| - name: Build sdist and wheel | |
| run: poetry build | |
| - name: Test wheel installation | |
| run: | | |
| if [ "$RUNNER_OS" = "Windows" ]; then | |
| for f in dist/*.whl; do pip install "$f"; done | |
| else | |
| pip install dist/*.whl | |
| fi | |
| pip uninstall -y memoryos | |
| - name: Test sdist installation | |
| run: | | |
| if [ "$RUNNER_OS" = "Windows" ]; then | |
| for f in dist/*.tar.gz; do pip install "$f"; done | |
| else | |
| pip install dist/*.tar.gz | |
| fi | |
| pip uninstall -y memoryos | |
| - name: Install all dependencies | |
| run: | | |
| poetry install --no-interaction --extras all --with test | |
| - name: Ruff checks | |
| run: | | |
| poetry run ruff check | |
| poetry run ruff format --check | |
| - name: PyTest unit tests | |
| run: | | |
| poetry run pytest tests -vv |