Files
tubesync/.github/workflows/ci.yaml
T
2025-03-19 02:05:33 -04:00

84 lines
3.0 KiB
YAML

name: Run Django tests for TubeSync
env:
IMAGE_NAME: tubesync
on:
workflow_dispatch:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Install Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pipenv
pipenv install --system --skip-lock
- name: Set up Django environment
run: |
cp -v -p tubesync/tubesync/local_settings.py.example tubesync/tubesync/local_settings.py
cp -v -a -t "${Python3_ROOT_DIR}"/lib/python3.*/site-packages/yt_dlp/ patches/yt_dlp/*
- name: Run Django tests
run: cd tubesync && python3 manage.py test --verbosity=2
containerise:
if: ${{ !cancelled() }}
needs: test
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Set environment variables with GitHub CLI
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
{
# Fetch the latest+1 release from yt-dlp/FFmpeg-Builds
var='FFMPEG_DATE' ;
delim='"'"${var}"'_EOF"' ;
jq_arg='.[1].tag_name[10:]' ;
printf -- '%s<<%s\n' "${var}" "${delim}" ;
gh api repos/yt-dlp/FFmpeg-Builds/releases --cache 12h --jq "${jq_arg}" ;
printf -- '%s\n' "${delim}" ;
unset -v delim jq_arg var ;
} >> "${GITHUB_ENV}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Log into GitHub Container Registry
env:
DOCKER_REGISTRY: https://ghcr.io
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_TOKEN: ${{ 'meeb' == github.repository_owner && secrets.REGISTRY_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
run: echo "${DOCKER_TOKEN}" | docker login --password-stdin --username "${DOCKER_USERNAME}" "${DOCKER_REGISTRY}"
- name: Lowercase github username for ghcr
id: string
uses: ASzc/change-string-case-action@v6
with:
string: ${{ github.actor }}
- name: Build and push
timeout-minutes: 60
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: ${{ 'success' == needs.test.result && 'meeb' == github.repository_owner && 'true' || 'false' }}
tags: ghcr.io/${{ steps.string.outputs.lowercase }}/${{ env.IMAGE_NAME }}:latest
cache-from: type=registry,ref=ghcr.io/${{ steps.string.outputs.lowercase }}/${{ env.IMAGE_NAME }}:latest
cache-to: type=inline
build-args: |
IMAGE_NAME=${{ env.IMAGE_NAME }}
FFMPEG_DATE=${{ env.FFMPEG_DATE }}