204 lines
6.2 KiB
YAML
204 lines
6.2 KiB
YAML
name: CI
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
paths-ignore:
|
|
- .gitignore
|
|
- "*.md"
|
|
pull_request:
|
|
paths-ignore:
|
|
- .gitignore
|
|
- "*.md"
|
|
|
|
env:
|
|
PYTHON_VERSION: '3.13'
|
|
|
|
jobs:
|
|
pytest:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v6
|
|
|
|
- name: "Set up Python"
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version-file: ".python-version"
|
|
|
|
- name: "Install dependencies"
|
|
run: uv sync --frozen
|
|
|
|
- name: "Run tests"
|
|
run: uv run pytest -vvv
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v6
|
|
|
|
- name: "Set up Python"
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version-file: ".python-version"
|
|
|
|
- name: "Install dependencies"
|
|
run: |
|
|
uv sync --frozen
|
|
sudo apt update && sudo apt install -y docker-compose
|
|
|
|
- name: "Checkout JellyPlex-Watched-CI"
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: luigi311/JellyPlex-Watched-CI
|
|
path: JellyPlex-Watched-CI
|
|
|
|
- name: "Start containers"
|
|
run: |
|
|
JellyPlex-Watched-CI/start_containers.sh
|
|
|
|
# Wait for containers to start
|
|
sleep 10
|
|
|
|
for FOLDER in $(find "JellyPlex-Watched-CI" -type f -name "docker-compose.yml" -exec dirname {} \;); do
|
|
docker compose -f "${FOLDER}/docker-compose.yml" logs
|
|
done
|
|
|
|
- name: "Test Plex"
|
|
run: |
|
|
ENV_FILE="test/ci_plex.env" uv run main.py
|
|
uv run test/validate_ci_marklog.py --plex
|
|
|
|
rm mark.log
|
|
|
|
- name: "Test Jellyfin"
|
|
run: |
|
|
ENV_FILE="test/ci_jellyfin.env" uv run main.py
|
|
uv run test/validate_ci_marklog.py --jellyfin
|
|
|
|
rm mark.log
|
|
|
|
- name: "Test Emby"
|
|
run: |
|
|
ENV_FILE="test/ci_emby.env" uv run main.py
|
|
uv run test/validate_ci_marklog.py --emby
|
|
|
|
rm mark.log
|
|
|
|
- name: "Test Guids"
|
|
run: |
|
|
ENV_FILE="test/ci_guids.env" uv run main.py
|
|
uv run test/validate_ci_marklog.py --guids
|
|
|
|
rm mark.log
|
|
|
|
- name: "Test Locations"
|
|
run: |
|
|
ENV_FILE="test/ci_locations.env" uv run main.py
|
|
uv run test/validate_ci_marklog.py --locations
|
|
|
|
rm mark.log
|
|
|
|
- name: "Test writing to the servers"
|
|
run: |
|
|
# Test writing to the servers
|
|
ENV_FILE="test/ci_write.env" uv run main.py
|
|
|
|
# Test again to test if it can handle existing data
|
|
ENV_FILE="test/ci_write.env" uv run main.py
|
|
|
|
uv run test/validate_ci_marklog.py --write
|
|
|
|
rm mark.log
|
|
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- pytest
|
|
- test
|
|
env:
|
|
DEFAULT_VARIANT: alpine
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- dockerfile: Dockerfile.alpine
|
|
variant: alpine
|
|
- dockerfile: Dockerfile.slim
|
|
variant: slim
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Docker meta
|
|
id: docker_meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
${{ secrets.DOCKER_USERNAME }}/jellyplex-watched,enable=${{ secrets.DOCKER_USERNAME != '' }}
|
|
# Do not push to ghcr.io on PRs due to permission issues, only push if the owner is luigi311 so it doesnt fail on forks
|
|
ghcr.io/${{ github.repository }},enable=${{ github.event_name != 'pull_request' && github.repository_owner == 'luigi311'}}
|
|
flavor: latest=false
|
|
tags: |
|
|
type=raw,value=latest,enable=${{ matrix.variant == env.DEFAULT_VARIANT && startsWith(github.ref, 'refs/tags/') }}
|
|
type=raw,value=latest,suffix=-${{ matrix.variant }},enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
|
|
|
type=ref,event=branch,suffix=-${{ matrix.variant }}
|
|
type=ref,event=branch,enable=${{ matrix.variant == env.DEFAULT_VARIANT }}
|
|
|
|
type=ref,event=pr,suffix=-${{ matrix.variant }}
|
|
type=ref,event=pr,enable=${{ matrix.variant == env.DEFAULT_VARIANT }}
|
|
|
|
type=semver,pattern={{ version }},suffix=-${{ matrix.variant }}
|
|
type=semver,pattern={{ version }},enable=${{ matrix.variant == env.DEFAULT_VARIANT }}
|
|
|
|
type=semver,pattern={{ major }}.{{ minor }},suffix=-${{ matrix.variant }}
|
|
type=semver,pattern={{ major }}.{{ minor }},enable=${{ matrix.variant == env.DEFAULT_VARIANT }}
|
|
|
|
type=sha,suffix=-${{ matrix.variant }}
|
|
type=sha,enable=${{ matrix.variant == env.DEFAULT_VARIANT }}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to DockerHub
|
|
env:
|
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
|
if: "${{ env.DOCKER_USERNAME != '' }}"
|
|
id: docker_login
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Login to GitHub Container Registry
|
|
if: "${{ steps.docker_meta.outcome == 'success' }}"
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build Push
|
|
id: build_push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ${{ matrix.dockerfile }}
|
|
platforms: linux/amd64,linux/arm64
|
|
push: ${{ steps.docker_login.outcome == 'success' }}
|
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
|
|
|
# Echo digest so users can validate their image
|
|
- name: Image digest
|
|
if: "${{ steps.docker_meta.outcome == 'success' }}"
|
|
run: echo "${{ steps.build_push.outputs.digest }}"
|