Skip to content
Open
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
159 changes: 88 additions & 71 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,97 @@
name: Build

on:
push:
branches:
- master
pull_request:
branches:
- master
push:
branches:
- master
pull_request:
branches:
- master
env:
MAIN_PYTHON_VERSION: "3.12"

concurrency:
# Cancel previous workflow run when a new commit is pushed to a feature branch
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
test:
name: "${{ matrix.os }}: ${{ matrix.tox-env }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
tox-env:
[
py39-test,
py310-test,
py311-test,
py312-test,
py313-test,
pypy-test,
]
os: [ubuntu-24.04, windows-latest]
changed-files:
runs-on: ubuntu-latest
name: Get changed files
outputs:
any_python_changed: ${{ steps.raw-changed-python-files.outputs.any_changed }}
changed_python_files: ${{ steps.changed-python-files.outputs.all_changed_files }}
steps:
- uses: actions/checkout@v5

- name: Get changed python files
id: raw-changed-python-files
uses: tj-actions/changed-files@v46
with:
files: |
**.py
uv.lock

# Only test on a couple of versions on Windows.
exclude:
- os: windows-latest
tox-env: pypy-test
- name: Check changed python files
id: changed-python-files
env:
CHANGED_PYTHON_FILES: ${{ steps.raw-changed-python-files.outputs.all_changed_files }}
run: |
if [[ " $CHANGED_PYTHON_FILES " == *" uv.lock "* ]]; then
# if uv.lock is changed, we need to check everything
CHANGED_PYTHON_FILES="."
fi
echo "all_changed_files=$CHANGED_PYTHON_FILES" >> "$GITHUB_OUTPUT"

# Python interpreter versions. :/
include:
- tox-env: py39-test
python: "3.9"
- tox-env: py310-test
python: "3.10"
- tox-env: py311-test
python: "3.11"
- tox-env: py312-test
python: "3.12"
- tox-env: py313-test
python: "3.13"
- tox-env: pypy-test
python: pypy3.9
test:
if: needs.changed-files.outputs.any_python_changed == 'true'
name: "${{ matrix.os }}: ${{ matrix.python-version }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-24.04, windows-latest]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install Tox
run: pip install tox
- name: Tox
run: tox -e ${{ matrix.tox-env }}
steps:
- uses: actions/checkout@v5
- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
- name: Install dependencies
run: |
uv sync --frozen --all-extras --dev
- name: Run tests with coverage
run: |
uv run poe test-with-coverage -v
- name: Upload coverage reports
if: matrix.os == 'ubuntu-24.04' && matrix.python-version == env.MAIN_PYTHON_VERSION
uses: actions/upload-artifact@v4
with:
name: coverage-${{ github.run_id }}
path: reports
retention-days: 30

style:
name: Style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Check style with Ruff
id: ruff
run: |
ruff check --output-format=github .
- name: Check format with Ruff
id: ruff-format
run: |
ruff format --check .
style:
name: Style
if: needs.changed-files.outputs.any_python_changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
enable-cache: true
- name: Install dependencies
run: |
uv sync --frozen --group dev
- name: Check style with Ruff
run: |
uv run ruff check --output-format=github ${{ needs.changed-files.outputs.changed_python_files }}
- name: Check format with Ruff
run: |
uv run ruff format --check ${{ needs.changed-files.outputs.changed_python_files }}
73 changes: 73 additions & 0 deletions .github/workflows/make_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Publish Python Package

on:
workflow_dispatch:
inputs:
version:
description: 'Version of the new release, just as a number with no prepended "v"'
required: true

env:
PYTHON_VERSION: "3.12"
NEW_VERSION: ${{ inputs.version }}
NEW_TAG: v${{ inputs.version }}

jobs:
increment-version:
name: Bump version, commit and create tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
enable-cache: true
- name: Bump project version
run: uv version "${{ env.NEW_VERSION }}"

- uses: EndBug/add-and-commit@v9
id: commit_and_tag
name: Commit the changes and create tag
with:
message: "Increment version to ${{ env.NEW_VERSION }}"
tag: "${{ env.NEW_TAG }} --force"

build:
name: Build the distribution package
runs-on: ubuntu-latest
needs: increment-version
steps:
- uses: actions/checkout@v5
- name: Install uv and set the Python version
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
enable-cache: true

- name: Build a binary wheel and a source tarball
run: uv build

- name: Store the package
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: Publish distribution 📦 to PyPI
runs-on: ubuntu-latest
needs: build
environment:
name: pypi
url: https://pypi.org/p/mediafile
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v5
with:
name: python-package-distributions
path: dist/
- name: Publish
run: uv publish
20 changes: 13 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ Please follow these guidelines to ensure a smooth contribution process.

## Setup the Development Environment

We recommend using a virtual environment to manage dependencies. You can use `venv`, `conda`, or any other tool of your choice.

1. Fork/Clone the repository on GitHub
```bash
git clone <your-fork-url>
cd mediafile
```
2. Install dependencies and set up the development environment

We use `uv` to manage virtual environments. If you don't have it installed, see [here](https://pypi.org/project/uv/).

2. Install dependencies and set up the development environment (using same lockfile as production):
```bash
uv sync --frozen --group dev
```

3. Activate the virtual environment (optional):
```bash
pip install -e '.[dev]'
source .venv/bin/activate
```

## Before submitting a Pull Request
Expand All @@ -29,7 +35,7 @@ Verify that your code adheres to the project standards and conventions. Run
ruff and pytest to ensure your code is properly formatted and all tests pass.

```bash
ruff check .
ruff format .
pytest .
uv run poe format
uv run poe lint
uv run poe test
```
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Upcoming
the codebase with ``ruff``.
- Moved changelog into its own file, ``changelog.rst``. Also added github workflow
for automatic changelog reminders.
- The project now uses ``uv`` for dependency management.

v0.13.0
'''''''
Expand Down
Loading