Skip to content
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
6 changes: 6 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@
a5b5c6c8ff61b0271df36e17633c34503f1de189
# Fixed imports
bb3857d297596b589302c9d7b4bd166e5184a59b
# Fix linting issues
e9e44272a6ba8ae93f94e40ec63f43b25547bf12
# Fix docs formatting
f27a994243f5933344b9e65cda0c5e5d6641fe91
# Fix docs links
7eb134b3726b9729c3c0d8be42dbd4e1930a4260
16 changes: 16 additions & 0 deletions .github/problem-matchers/sphinx-build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "sphinx-build",
"severity": "error",
"pattern": [
{
"regexp": "^(/[^:]+):((\\d+):)?(\\sWARNING:)?\\s*(.+)$",
"file": 1,
"line": 3,
"message": 5
}
]
}
]
}
17 changes: 17 additions & 0 deletions .github/problem-matchers/sphinx-lint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "sphinx-lint",
"severity": "error",
"pattern": [
{
"regexp": "^([^:]+):(\\d+):\\s+(.*)\\s\\(([a-z-]+)\\)$",
"file": 1,
"line": 2,
"message": 3,
"code": 4
}
]
}
]
}
56 changes: 0 additions & 56 deletions .github/workflows/build.yml

This file was deleted.

146 changes: 146 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Lint check
run-name: Lint code
on:
pull_request:
push:
branches:
- master

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/master' }}

env:
PYTHON_VERSION: "3.9"

jobs:
changed-files:
runs-on: ubuntu-latest
name: Get changed files
outputs:
any_docs_changed: ${{ steps.changed-doc-files.outputs.any_changed }}
any_python_changed: ${{ steps.raw-changed-python-files.outputs.any_changed }}
changed_doc_files: ${{ steps.changed-doc-files.outputs.all_changed_files }}
changed_python_files: ${{ steps.changed-python-files.outputs.all_changed_files }}
steps:
- uses: actions/checkout@v5
- name: Get changed docs files
id: changed-doc-files
uses: tj-actions/changed-files@v46
with:
files: |
docs/**
- name: Get changed python files
id: raw-changed-python-files
uses: tj-actions/changed-files@v46
with:
files: |
**.py
poetry.lock

- 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 " == *" poetry.lock "* ]]; then
# if poetry.lock is changed, we need to check everything
CHANGED_PYTHON_FILES="."
fi
echo "all_changed_files=$CHANGED_PYTHON_FILES" >> "$GITHUB_OUTPUT"

format:
if: needs.changed-files.outputs.any_python_changed == 'true'
runs-on: ubuntu-latest
name: Check formatting
needs: changed-files
steps:
- uses: actions/checkout@v5
- name: Install Python tools
uses: BrandonLWhite/[email protected]
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry

- name: Install dependencies
run: poetry install --only=lint

- name: Check code formatting
# the job output will contain colored diffs with what needs adjusting
run: poe check-format --output-format=github ${{ needs.changed-files.outputs.changed_python_files }}

lint:
if: needs.changed-files.outputs.any_python_changed == 'true'
runs-on: ubuntu-latest
name: Check linting
needs: changed-files
steps:
- uses: actions/checkout@v5
- name: Install Python tools
uses: BrandonLWhite/[email protected]
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry

- name: Install dependencies
run: poetry install --only=lint

- name: Lint code
run: poe lint --output-format=github ${{ needs.changed-files.outputs.changed_python_files }}

mypy:
if: needs.changed-files.outputs.any_python_changed == 'true'
runs-on: ubuntu-latest
name: Check types with mypy
needs: changed-files
steps:
- uses: actions/checkout@v5
- name: Install Python tools
uses: BrandonLWhite/[email protected]
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry

- name: Install dependencies
run: poetry install --only=lint

- name: Type check code
uses: liskin/gh-problem-matcher-wrap@v3
with:
linters: mypy
run: poe check-types --show-column-numbers --no-error-summary .

docs:
if: needs.changed-files.outputs.any_docs_changed == 'true'
runs-on: ubuntu-latest
name: Check docs
needs: changed-files
steps:
- uses: actions/checkout@v5
- name: Install Python tools
uses: BrandonLWhite/[email protected]
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry

- name: Install dependencies
run: poetry install --extras=docs

- name: Add Sphinx problem matchers
run: |
echo "::add-matcher::.github/problem-matchers/sphinx-build.json"
echo "::add-matcher::.github/problem-matchers/sphinx-lint.json"

- name: Check docs formatting
run: poe format-docs --check

- name: Lint docs
run: poe lint-docs

- name: Build docs
run: poe docs -- -e 'SPHINXOPTS=--fail-on-warning --keep-going'
47 changes: 47 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Test
on:
pull_request:
push:
branches:
- master

jobs:
test:
name: Run tests
permissions:
id-token: write
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v5
- name: Install Python tools
uses: BrandonLWhite/[email protected]
- name: Setup Python with poetry caching
# poetry cache requires poetry to already be installed, weirdly
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: poetry

- name: Test
env:
POETRY_VIRTUALENVS_IN_PROJECT: true
run: |-
poetry install
poe test-with-coverage

- name: Upload test results to Codecov
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload code coverage
uses: codecov/codecov-action@v5
with:
files: ./coverage.xml
flags: ${{ matrix.platform}}_python${{ matrix.python-version }}
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }}
79 changes: 79 additions & 0 deletions .github/workflows/make_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Make a release

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.9
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@v4
- name: Install Python tools
uses: BrandonLWhite/[email protected]
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry

- name: Bump project version
run: poetry 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@v4
with:
ref: ${{ env.NEW_TAG }}

- name: Install Python tools
uses: BrandonLWhite/[email protected]
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry

- name: Build a binary wheel and a source tarball
run: poetry 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@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Loading