Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ToshY committed Jul 6, 2024
0 parents commit 1ed48e8
Show file tree
Hide file tree
Showing 31 changed files with 1,482 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.git
.gitignore
.github
.idea
.dockerignore
Dockerfile
compose.yml
compose.yaml
compose.override.yml
compose.override.yaml
__pycache__/
.ruff_cache/
.mypy_cache/
.pre-commit-config.yaml
Taskfile.yml
input/
docs/
mkdocs.yml
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
target-branch: "main"
schedule:
interval: "weekly"
day: "sunday"
- package-ecosystem: "pip"
directory: "/"
target-branch: "main"
schedule:
interval: "weekly"
day: "sunday"
30 changes: 30 additions & 0 deletions .github/workflows/codequality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Codequality with Ruff

on:
push:
branches:
- main
pull_request_target:
branches:
- main

jobs:
ruff:
name: Run codequality checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install requirements
run: pip install -r requirements.txt -r requirements.dev.txt

- name: Ruff check
run: ruff check .
30 changes: 30 additions & 0 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Codestyle with Black

on:
push:
branches:
- main
pull_request_target:
branches:
- main

jobs:
black:
name: Run codestyle checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install requirements
run: pip install -r requirements.txt -r requirements.dev.txt

- name: Black check
run: black . --check
44 changes: 44 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: docs

on:
push:
branches:
- main

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pages
uses: actions/configure-pages@v5

- name: Build docs
run: docker run --rm -v ${PWD}:/docs ghcr.io/squidfunk/mkdocs-material:9.5 build

- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./site

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
65 changes: 65 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Release

on:
release:
types:
- published

env:
DOCKER_IMAGE: toshy/mkvexport

jobs:
release:
name: Build docker image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ env.DOCKER_IMAGE }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build base image
uses: docker/build-push-action@v6
with:
context: .
load: true
target: prod
tags: ${{ env.DOCKER_IMAGE }}:prod

- name: Test base image
run: |
docker run --rm ${{ env.DOCKER_IMAGE }}:prod --help
- name: Build and push production image
uses: docker/build-push-action@v6
with:
context: .
push: true
target: prod
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
32 changes: 32 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Pip audit

on:
push:
branches:
- main
pull_request_target:
branches:
- main

jobs:
security:
name: Run pip-audit
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install requirements
run: |
pip install -r requirements.txt
pip install --no-cache-dir --upgrade --force-reinstall 'setuptools>=65.5.1'
- name: Pip audit
uses: pypa/[email protected]
30 changes: 30 additions & 0 deletions .github/workflows/statictyping.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Static typing with Mypy

on:
push:
branches:
- main
pull_request_target:
branches:
- main

jobs:
mypy:
name: Run Mypy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install requirements
run: pip install -r requirements.txt -r requirements.dev.txt

- name: Mypy check
run: mypy .
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# cache
__pycache__/
**/__pycache__/
.ruff_cache/
.mypy_cache/
# miscellaneous
input/
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
fail_fast: true
repos:
- repo: local
hooks:
- id: ruff
name: Ruff
entry: docker compose run -T --rm dev ruff check .
language: system
always_run: true
pass_filenames: false
- id: black
name: Black
entry: docker compose run -T --rm dev black . --check --diff --color
language: system
always_run: true
pass_filenames: false
- id: static
name: Mypy
entry: docker compose run -T --rm dev mypy .
language: system
always_run: true
pass_filenames: false
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
ARG PYTHON_IMAGE_VERSION=3.11

FROM python:${PYTHON_IMAGE_VERSION}-slim-bookworm AS base

LABEL maintainer="ToshY (github.com/ToshY)"

ENV PIP_ROOT_USER_ACTION ignore

WORKDIR /build

RUN <<EOT bash
set -ex
apt-get update
apt install -y build-essential cmake wget
wget -O /usr/share/keyrings/gpg-pub-moritzbunkus.gpg https://mkvtoolnix.download/gpg-pub-moritzbunkus.gpg
echo "deb [signed-by=/usr/share/keyrings/gpg-pub-moritzbunkus.gpg] https://mkvtoolnix.download/debian/ bookworm main" > /etc/apt/sources.list.d/mkvtoolnix.download.list
echo "deb-src [signed-by=/usr/share/keyrings/gpg-pub-moritzbunkus.gpg] https://mkvtoolnix.download/debian/ bookworm main" >> /etc/apt/sources.list.d/mkvtoolnix.download.list
apt-get update
apt install -y mkvtoolnix
apt-get clean
rm -rf /var/lib/apt/lists/*
EOT

COPY requirements.txt ./

RUN pip install --no-cache-dir -r requirements.txt \
&& pip install --no-cache-dir --upgrade --force-reinstall 'setuptools>=65.5.1'

FROM base AS prod

COPY . .

RUN pip install .

WORKDIR /app

RUN <<EOT bash
set -ex
mkdir -p ./{input,output}
rm -rf /build
EOT

ENTRYPOINT ["mkvexport"]

FROM base AS dev

WORKDIR /app

COPY requirements.dev.txt ./

RUN pip install --no-cache-dir -r requirements.dev.txt
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 ToshY

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 1ed48e8

Please sign in to comment.