Now dockerized workflow with all jobs added.
Some checks failed
Tests / TypeScript Type Check (push) Has been cancelled
Tests / ESLint Check (push) Has been cancelled
Tests / Prettier Format Check (push) Has been cancelled
Tests / Trailing Whitespace Check (push) Has been cancelled
Tests / End of File Check (push) Has been cancelled
Tests / YAML Syntax Check (push) Has been cancelled
Tests / TOML Syntax Check (push) Has been cancelled
Tests / Mixed Line Ending Check (push) Has been cancelled
Tests / TOML Formatting Check (push) Has been cancelled
Tests / Ruff Linting (push) Has been cancelled
Tests / Ruff Format Check (push) Has been cancelled
Tests / Pyright Type Check (push) Has been cancelled
Tests / Darglint Docstring Check (push) Has been cancelled
Tests / No Docstring Types Check (push) Has been cancelled
Tests / TSDoc Lint Check (push) Has been cancelled
Tests / Backend Tests (push) Has been cancelled
Tests / Frontend Tests (push) Has been cancelled
Tests / Backend Doctests (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / End-to-End Tests (push) Has been cancelled
Tests / Build and Push CICD Image (push) Has started running
Some checks failed
Tests / TypeScript Type Check (push) Has been cancelled
Tests / ESLint Check (push) Has been cancelled
Tests / Prettier Format Check (push) Has been cancelled
Tests / Trailing Whitespace Check (push) Has been cancelled
Tests / End of File Check (push) Has been cancelled
Tests / YAML Syntax Check (push) Has been cancelled
Tests / TOML Syntax Check (push) Has been cancelled
Tests / Mixed Line Ending Check (push) Has been cancelled
Tests / TOML Formatting Check (push) Has been cancelled
Tests / Ruff Linting (push) Has been cancelled
Tests / Ruff Format Check (push) Has been cancelled
Tests / Pyright Type Check (push) Has been cancelled
Tests / Darglint Docstring Check (push) Has been cancelled
Tests / No Docstring Types Check (push) Has been cancelled
Tests / TSDoc Lint Check (push) Has been cancelled
Tests / Backend Tests (push) Has been cancelled
Tests / Frontend Tests (push) Has been cancelled
Tests / Backend Doctests (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / End-to-End Tests (push) Has been cancelled
Tests / Build and Push CICD Image (push) Has started running
Signed-off-by: Cliff Hill <xlorep@darkhelm.org>
This commit is contained in:
447
.gitea/workflows/cicd.yml
Normal file
447
.gitea/workflows/cicd.yml
Normal file
@@ -0,0 +1,447 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop, feature/* ]
|
||||
pull_request:
|
||||
branches: [ main, develop ]
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
name: Build and Push CICD Image
|
||||
runs-on: ubuntu-act
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
GITHUB_WORKSPACE: ${{ github.workspace }}
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
run: |
|
||||
echo "=== Repository Checkout ==="
|
||||
cd "${GITHUB_WORKSPACE}"
|
||||
rm -rf ./* .git 2>/dev/null || true
|
||||
|
||||
# Set up SSH key
|
||||
if [ -n "${SSH_PRIVATE_KEY}" ]; then
|
||||
mkdir -p ~/.ssh
|
||||
echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
ssh-keyscan -p 2222 dogar.darkhelm.org >> ~/.ssh/known_hosts 2>/dev/null
|
||||
fi
|
||||
|
||||
# Clone repository
|
||||
GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no" \
|
||||
git clone --depth 1 --branch main \
|
||||
ssh://git@dogar.darkhelm.org:2222/DarkHelm.org/plex-playlist.git .
|
||||
|
||||
if [ -n "${GITHUB_SHA}" ]; then
|
||||
git checkout "${GITHUB_SHA}" 2>/dev/null || echo "Using main branch HEAD"
|
||||
fi
|
||||
echo "✓ Repository checkout completed"
|
||||
|
||||
- name: Build and push CICD image
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: |
|
||||
echo "=== Building CICD Image ==="
|
||||
|
||||
# Build CICD image with all tools, code, and dependencies
|
||||
docker build -f Dockerfile.cicd -t cicd:latest .
|
||||
|
||||
# Tag for Gitea container registry
|
||||
docker tag cicd:latest dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:latest
|
||||
docker tag cicd:latest dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
|
||||
# Login to Gitea container registry
|
||||
echo "${GITEA_TOKEN}" | docker login dogar.darkhelm.org -u DarkHelm.org --password-stdin
|
||||
|
||||
# Push to registry
|
||||
docker push dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:latest
|
||||
docker push dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
|
||||
echo "✓ CICD image built and pushed to registry"
|
||||
|
||||
# Pre-commit style checks - General file formatting
|
||||
trailing-whitespace:
|
||||
name: Trailing Whitespace Check
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Check trailing whitespace
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace &&
|
||||
if grep -r '[[:space:]]$' --exclude-dir=.git --exclude-dir=node_modules --exclude-dir=.venv --exclude-dir=__pycache__ .; then
|
||||
echo 'ERROR: Trailing whitespace found'
|
||||
exit 1
|
||||
else
|
||||
echo '✓ No trailing whitespace found'
|
||||
fi
|
||||
"
|
||||
|
||||
end-of-file-fixer:
|
||||
name: End of File Check
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Check end of file
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace &&
|
||||
find . -type f -name '*.py' -o -name '*.ts' -o -name '*.js' -o -name '*.vue' -o -name '*.yml' -o -name '*.yaml' -o -name '*.toml' -o -name '*.json' -o -name '*.md' | grep -v '.git/' | grep -v 'node_modules/' | grep -v '.venv/' | grep -v '__pycache__/' | while read file; do
|
||||
if [ -s \"\$file\" ] && [ \"\$(tail -c1 \"\$file\" | wc -l)\" -eq 0 ]; then
|
||||
echo \"ERROR: \$file does not end with newline\"
|
||||
exit 1
|
||||
fi
|
||||
done &&
|
||||
echo '✓ All files end with newline'
|
||||
"
|
||||
|
||||
check-yaml:
|
||||
name: YAML Syntax Check
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Check YAML files
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/backend &&
|
||||
source .venv/bin/activate &&
|
||||
cd /workspace &&
|
||||
find . -name '*.yml' -o -name '*.yaml' | grep -v '.git/' | grep -v 'node_modules/' | grep -v '.venv/' | while read file; do
|
||||
echo \"Linting \$file...\"
|
||||
if ! uv run yamllint \"\$file\"; then
|
||||
echo \"ERROR: YAML lint failed for \$file\"
|
||||
exit 1
|
||||
fi
|
||||
done &&
|
||||
echo '✓ All YAML files passed yamllint'
|
||||
"
|
||||
|
||||
check-toml:
|
||||
name: TOML Syntax Check
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Check TOML files
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/backend &&
|
||||
source .venv/bin/activate &&
|
||||
cd /workspace &&
|
||||
find . -name '*.toml' | grep -v '.git/' | grep -v 'node_modules/' | grep -v '.venv/' | while read file; do
|
||||
echo \"Checking \$file syntax...\"
|
||||
if ! python3 -c 'import tomllib, sys; tomllib.load(open(sys.argv[1], \"rb\"))' \"\$file\" 2>/dev/null; then
|
||||
echo \"ERROR: Invalid TOML syntax in \$file\"
|
||||
exit 1
|
||||
fi
|
||||
done &&
|
||||
echo '✓ All TOML files have valid syntax'
|
||||
"
|
||||
|
||||
mixed-line-ending:
|
||||
name: Mixed Line Ending Check
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Check line endings
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace &&
|
||||
if find . -name '*.py' -o -name '*.ts' -o -name '*.js' -o -name '*.vue' -o -name '*.yml' -o -name '*.yaml' -o -name '*.toml' -o -name '*.json' -o -name '*.md' | grep -v '.git/' | grep -v 'node_modules/' | grep -v '.venv/' | xargs file | grep -i 'crlf'; then
|
||||
echo 'ERROR: Mixed line endings found (CRLF detected)'
|
||||
exit 1
|
||||
else
|
||||
echo '✓ Consistent line endings (LF)'
|
||||
fi
|
||||
"
|
||||
|
||||
toml-lint:
|
||||
name: TOML Formatting Check
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Check TOML formatting
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/backend &&
|
||||
source .venv/bin/activate &&
|
||||
cd /workspace &&
|
||||
echo 'Checking TOML formatting (fails if changes needed)...' &&
|
||||
for file in \$(find . -name '*.toml' | grep -v '.git/' | grep -v 'node_modules/' | grep -v '.venv/'); do
|
||||
echo \"Checking TOML format: \$file\"
|
||||
# Use pretty-format-toml in check mode (same tool as pre-commit)
|
||||
if ! uv run pretty-format-toml --diff \$file | grep -q 'no change'; then
|
||||
echo \"ERROR: \$file needs formatting\"
|
||||
uv run pretty-format-toml --diff \$file
|
||||
exit 1
|
||||
fi
|
||||
done &&
|
||||
echo '✓ All TOML files are properly formatted'
|
||||
"
|
||||
|
||||
# Backend Python checks
|
||||
ruff-lint:
|
||||
name: Ruff Linting
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Run ruff linting
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/backend &&
|
||||
source .venv/bin/activate &&
|
||||
echo 'Running ruff check (no auto-fix)...' &&
|
||||
uv run ruff check . --config=pyproject.toml
|
||||
"
|
||||
|
||||
ruff-format:
|
||||
name: Ruff Format Check
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Check ruff formatting
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/backend &&
|
||||
source .venv/bin/activate &&
|
||||
echo 'Checking ruff formatting (fails if changes needed)...' &&
|
||||
uv run ruff format --check . --config=pyproject.toml
|
||||
"
|
||||
|
||||
pyright:
|
||||
name: Pyright Type Check
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Run pyright type checking
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/backend &&
|
||||
source .venv/bin/activate &&
|
||||
uv run pyright
|
||||
"
|
||||
|
||||
darglint:
|
||||
name: Darglint Docstring Check
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Run darglint docstring linting
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/backend &&
|
||||
source .venv/bin/activate &&
|
||||
uv run darglint src/
|
||||
"
|
||||
|
||||
no-docstring-types:
|
||||
name: No Docstring Types Check
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Check for types in docstrings
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace &&
|
||||
echo 'Checking backend Python files for types in docstrings...' &&
|
||||
find backend/src -name '*.py' -type f | xargs python3 scripts/check_no_docstring_types.py &&
|
||||
echo '✓ No prohibited types found in docstrings'
|
||||
"
|
||||
|
||||
# Frontend checks
|
||||
eslint:
|
||||
name: ESLint Check
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Run ESLint
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/frontend &&
|
||||
echo 'Running ESLint check (no auto-fix)...' &&
|
||||
yarn eslint . --max-warnings=0
|
||||
"
|
||||
|
||||
prettier:
|
||||
name: Prettier Format Check
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Check Prettier formatting
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/frontend &&
|
||||
echo 'Checking Prettier formatting (fails if changes needed)...' &&
|
||||
yarn format:check
|
||||
"
|
||||
|
||||
typescript-check:
|
||||
name: TypeScript Type Check
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Run TypeScript type checking
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/frontend &&
|
||||
yarn type-check
|
||||
"
|
||||
|
||||
tsdoc-lint:
|
||||
name: TSDoc Lint Check
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Run TSDoc linting
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/frontend &&
|
||||
echo 'Running TSDoc linting check...' &&
|
||||
# Use eslint directly without --fix to check TSDoc
|
||||
yarn eslint . --ext .ts,.vue --max-warnings=0 --no-fix
|
||||
"
|
||||
|
||||
# Unit tests with coverage
|
||||
backend-tests:
|
||||
name: Backend Tests
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Run backend tests with coverage
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/backend &&
|
||||
source .venv/bin/activate &&
|
||||
uv run pytest -v --tb=short --cov=src --cov-report=term-missing --cov-fail-under=95
|
||||
"
|
||||
|
||||
frontend-tests:
|
||||
name: Frontend Tests
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Run frontend tests with coverage
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/frontend &&
|
||||
yarn test:coverage --run --reporter=verbose --coverage.reporter=text --coverage.reporter=text-summary --coverage.thresholds.lines=85 --coverage.thresholds.functions=85 --coverage.thresholds.branches=85 --coverage.thresholds.statements=85
|
||||
"
|
||||
|
||||
# Doctest for backend
|
||||
xdoctest:
|
||||
name: Backend Doctests
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Run backend doctests
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/backend &&
|
||||
source .venv/bin/activate &&
|
||||
echo 'Running doctests...' &&
|
||||
if uv run xdoctest src/ --quiet; then
|
||||
echo '✓ All doctests passed'
|
||||
else
|
||||
echo 'ℹ No doctests found or some doctests failed'
|
||||
# Don't fail the build for missing doctests, only for failed ones
|
||||
if uv run xdoctest src/ --quiet --verbose 2>&1 | grep -q 'FAILED'; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
"
|
||||
|
||||
# Integration and E2E tests (run after unit tests complete)
|
||||
integration-tests:
|
||||
name: Integration Tests
|
||||
runs-on: ubuntu-act
|
||||
needs: [backend-tests, frontend-tests]
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Run integration tests
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/backend &&
|
||||
source .venv/bin/activate &&
|
||||
if [ -d 'tests/integration' ]; then
|
||||
uv run pytest tests/integration/ -v --tb=short
|
||||
else
|
||||
echo 'ℹ No integration tests found'
|
||||
fi
|
||||
"
|
||||
|
||||
e2e-tests:
|
||||
name: End-to-End Tests
|
||||
runs-on: ubuntu-act
|
||||
needs: [backend-tests, frontend-tests]
|
||||
steps:
|
||||
- name: Login to Gitea Container Registry
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login dogar.darkhelm.org -u ${{ github.actor }} --password-stdin
|
||||
- name: Run E2E tests
|
||||
run: |
|
||||
docker pull dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest}
|
||||
docker run --rm dogar.darkhelm.org/darkhelm.org/plex-playlist/cicd:${GITHUB_SHA:-latest} bash -c "
|
||||
cd /workspace/frontend &&
|
||||
if [ -d 'tests/e2e' ] || grep -q 'playwright' package.json; then
|
||||
yarn test:e2e || echo 'E2E tests failed or not configured yet'
|
||||
else
|
||||
echo 'ℹ No E2E tests found'
|
||||
fi
|
||||
"
|
||||
@@ -1,177 +0,0 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop, feature/* ]
|
||||
pull_request:
|
||||
branches: [ main, develop ]
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
name: Build Base Setup Image
|
||||
runs-on: ubuntu-act
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
GITHUB_WORKSPACE: ${{ github.workspace }}
|
||||
GITHUB_SHA: ${{ github.sha }}
|
||||
run: |
|
||||
echo "=== Repository Checkout ==="
|
||||
cd "${GITHUB_WORKSPACE}"
|
||||
rm -rf ./* .git 2>/dev/null || true
|
||||
|
||||
# Set up SSH key
|
||||
if [ -n "${SSH_PRIVATE_KEY}" ]; then
|
||||
mkdir -p ~/.ssh
|
||||
echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
ssh-keyscan -p 2222 dogar.darkhelm.org >> ~/.ssh/known_hosts 2>/dev/null
|
||||
fi
|
||||
|
||||
# Clone repository
|
||||
GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no" \
|
||||
git clone --depth 1 --branch main \
|
||||
ssh://git@dogar.darkhelm.org:2222/DarkHelm.org/plex-playlist.git .
|
||||
|
||||
if [ -n "${GITHUB_SHA}" ]; then
|
||||
git checkout "${GITHUB_SHA}" 2>/dev/null || echo "Using main branch HEAD"
|
||||
fi
|
||||
echo "✓ Repository checkout completed"
|
||||
|
||||
- name: Build cicd-setup image
|
||||
run: |
|
||||
echo "=== Building CICD Setup Image ==="
|
||||
|
||||
# Build the base setup image with source code
|
||||
docker build -f Dockerfile.cicd-setup -t cicd-setup:latest .
|
||||
|
||||
# Verify the image was built
|
||||
docker images | grep cicd-setup
|
||||
|
||||
echo "✓ CICD setup image ready"
|
||||
|
||||
backend-setup:
|
||||
name: Build Backend Environment
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
|
||||
steps:
|
||||
- name: Build cicd-backend image
|
||||
run: |
|
||||
echo "=== Building CICD Backend Image ==="
|
||||
|
||||
# Build the backend image extending the setup image
|
||||
docker build -f Dockerfile.cicd-backend -t cicd-backend:latest .
|
||||
|
||||
# Verify the image was built and tools are available
|
||||
docker images | grep cicd-backend
|
||||
docker run --rm cicd-backend:latest bash -c "cd /workspace/backend && ruff --version && pyright --version"
|
||||
|
||||
echo "✓ CICD backend image ready"
|
||||
|
||||
frontend-setup:
|
||||
name: Build Frontend Environment
|
||||
runs-on: ubuntu-act
|
||||
needs: setup
|
||||
|
||||
steps:
|
||||
- name: Build cicd-frontend image
|
||||
run: |
|
||||
echo "=== Building CICD Frontend Image ==="
|
||||
|
||||
# Build the frontend image extending the setup image
|
||||
docker build -f Dockerfile.cicd-frontend -t cicd-frontend:latest .
|
||||
|
||||
# Verify the image was built and tools are available
|
||||
docker images | grep cicd-frontend
|
||||
docker run --rm cicd-frontend:latest bash -c "cd /workspace/frontend && yarn eslint --version && ls -la dist/"
|
||||
|
||||
echo "✓ CICD frontend image ready"
|
||||
|
||||
backend-tests:
|
||||
name: Backend Tests
|
||||
runs-on: ubuntu-act
|
||||
needs: backend-setup
|
||||
|
||||
steps:
|
||||
- name: Run backend tests
|
||||
run: |
|
||||
echo "=== Running Backend Tests ==="
|
||||
|
||||
# Run tests using the pre-built backend image
|
||||
docker run --rm cicd-backend:latest bash -c "
|
||||
cd /workspace/backend &&
|
||||
uv run pytest -v --tb=short --cov=src --cov-report=term-missing
|
||||
"
|
||||
|
||||
echo "✓ Backend tests completed"
|
||||
|
||||
backend-lint:
|
||||
name: Backend Linting
|
||||
runs-on: ubuntu-act
|
||||
needs: backend-setup
|
||||
|
||||
steps:
|
||||
- name: Run backend linting
|
||||
run: |
|
||||
echo "=== Running Backend Linting ==="
|
||||
|
||||
# Run all backend linting tools using the pre-built image
|
||||
docker run --rm cicd-backend:latest bash -c "
|
||||
cd /workspace/backend &&
|
||||
echo '--- Running ruff linting ---' &&
|
||||
uv run ruff check . &&
|
||||
echo '--- Running ruff formatting check ---' &&
|
||||
uv run ruff format --check . &&
|
||||
echo '--- Running pyright type checking ---' &&
|
||||
uv run pyright &&
|
||||
echo '--- Running darglint docstring linting ---' &&
|
||||
uv run darglint src/
|
||||
"
|
||||
|
||||
echo "✓ Backend linting completed"
|
||||
|
||||
frontend-tests:
|
||||
name: Frontend Tests
|
||||
runs-on: ubuntu-act
|
||||
needs: frontend-setup
|
||||
|
||||
steps:
|
||||
- name: Run frontend tests
|
||||
run: |
|
||||
echo "=== Running Frontend Tests ==="
|
||||
|
||||
# Run tests using the pre-built frontend image
|
||||
docker run --rm cicd-frontend:latest bash -c "
|
||||
cd /workspace/frontend &&
|
||||
yarn test --run --reporter=verbose
|
||||
"
|
||||
|
||||
echo "✓ Frontend tests completed"
|
||||
|
||||
frontend-lint:
|
||||
name: Frontend Linting
|
||||
runs-on: ubuntu-act
|
||||
needs: frontend-setup
|
||||
|
||||
steps:
|
||||
- name: Run frontend linting
|
||||
run: |
|
||||
echo "=== Running Frontend Linting ==="
|
||||
|
||||
# Run all frontend linting tools using the pre-built image
|
||||
docker run --rm cicd-frontend:latest bash -c "
|
||||
cd /workspace/frontend &&
|
||||
echo '--- Running ESLint ---' &&
|
||||
yarn lint &&
|
||||
echo '--- Running Prettier check ---' &&
|
||||
yarn format:check &&
|
||||
echo '--- Running TypeScript type checking ---' &&
|
||||
yarn type-check &&
|
||||
echo '--- Running TSDoc linting ---' &&
|
||||
yarn lint:tsdoc
|
||||
"
|
||||
|
||||
echo "✓ Frontend linting completed"
|
||||
92
Dockerfile.cicd
Normal file
92
Dockerfile.cicd
Normal file
@@ -0,0 +1,92 @@
|
||||
# CICD Setup - Clean base image with development tools only
|
||||
FROM ubuntu:22.04
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
curl \
|
||||
ca-certificates \
|
||||
software-properties-common \
|
||||
build-essential \
|
||||
openssh-client \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Python 3.13
|
||||
RUN add-apt-repository ppa:deadsnakes/ppa \
|
||||
&& apt-get update && apt-get install -y \
|
||||
python3.13 \
|
||||
python3.13-venv \
|
||||
python3.13-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Node.js 24
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
|
||||
&& apt-get install -y nodejs \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Enable corepack for yarn and set up Yarn Berry
|
||||
RUN corepack enable \
|
||||
&& corepack prepare yarn@stable --activate \
|
||||
&& yarn set version berry
|
||||
|
||||
# Install uv package manager globally
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /workspace
|
||||
|
||||
# Copy the entire project
|
||||
COPY . .
|
||||
|
||||
# Set up Python environment for backend
|
||||
WORKDIR /workspace/backend
|
||||
ENV VIRTUAL_ENV=/workspace/backend/.venv
|
||||
RUN uv venv $VIRTUAL_ENV
|
||||
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||
|
||||
# Install backend dev dependencies
|
||||
RUN uv sync --dev
|
||||
|
||||
# Install backend package in development mode
|
||||
RUN uv pip install -e .
|
||||
|
||||
# Set up frontend dependencies
|
||||
WORKDIR /workspace/frontend
|
||||
RUN yarn install --immutable
|
||||
|
||||
# Verify all tools are working with the project
|
||||
RUN cd /workspace/backend && \
|
||||
echo "=== Backend Tools Verification ===" && \
|
||||
uv run ruff --version && \
|
||||
uv run pyright --version && \
|
||||
uv run darglint --version && \
|
||||
uv run pytest --version && \
|
||||
uv run yamllint --version && \
|
||||
uv run toml-sort --version && \
|
||||
uv run xdoctest --version
|
||||
|
||||
RUN cd /workspace/frontend && \
|
||||
echo "=== Frontend Tools Verification ===" && \
|
||||
yarn eslint --version && \
|
||||
yarn prettier --version && \
|
||||
yarn tsc --version && \
|
||||
yarn vitest --version
|
||||
|
||||
# Create a script to set up SSH for git operations (if needed for updates)
|
||||
RUN echo '#!/bin/bash' > /usr/local/bin/setup-ssh && \
|
||||
echo 'mkdir -p ~/.ssh' >> /usr/local/bin/setup-ssh && \
|
||||
echo 'echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa' >> /usr/local/bin/setup-ssh && \
|
||||
echo 'chmod 600 ~/.ssh/id_rsa' >> /usr/local/bin/setup-ssh && \
|
||||
echo 'ssh-keyscan -H github.com >> ~/.ssh/known_hosts 2>/dev/null' >> /usr/local/bin/setup-ssh && \
|
||||
echo 'ssh-keyscan -H dogar.darkhelm.org >> ~/.ssh/known_hosts 2>/dev/null' >> /usr/local/bin/setup-ssh && \
|
||||
chmod +x /usr/local/bin/setup-ssh
|
||||
|
||||
# Set Python path for backend
|
||||
ENV PYTHONPATH=/workspace/backend/src:/workspace/backend
|
||||
|
||||
# Set working directory back to root
|
||||
WORKDIR /workspace
|
||||
|
||||
# Default to bash
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
CMD ["/bin/bash"]
|
||||
@@ -1,44 +0,0 @@
|
||||
# CICD Backend - Extends setup with Python environment
|
||||
FROM cicd-setup:latest
|
||||
|
||||
# Install Python 3.13 and system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
software-properties-common \
|
||||
&& add-apt-repository ppa:deadsnakes/ppa \
|
||||
&& apt-get update && apt-get install -y \
|
||||
python3.13 \
|
||||
python3.13-venv \
|
||||
python3.13-dev \
|
||||
build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install uv package manager
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
|
||||
|
||||
# Set working directory to backend
|
||||
WORKDIR /workspace/backend
|
||||
|
||||
# Create and activate virtual environment
|
||||
ENV VIRTUAL_ENV=/workspace/backend/.venv
|
||||
RUN uv venv $VIRTUAL_ENV
|
||||
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||
|
||||
# Install backend dependencies in dev mode (includes ruff, pyright, darglint, etc.)
|
||||
RUN uv sync --dev
|
||||
|
||||
# Install the backend package in development mode
|
||||
RUN uv pip install -e .
|
||||
|
||||
# Set Python path for imports
|
||||
ENV PYTHONPATH=/workspace/backend/src:/workspace/backend
|
||||
|
||||
# Verify tools are available
|
||||
RUN which ruff && ruff --version
|
||||
RUN which pyright && pyright --version
|
||||
RUN which darglint && darglint --version
|
||||
|
||||
# Set working directory back to workspace root for flexibility
|
||||
WORKDIR /workspace
|
||||
|
||||
# Default command
|
||||
CMD ["/bin/bash"]
|
||||
@@ -1,33 +0,0 @@
|
||||
# CICD Frontend - Extends setup with Node.js environment
|
||||
FROM cicd-setup:latest
|
||||
|
||||
# Install Node.js 20
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||
&& apt-get install -y nodejs \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Enable corepack for yarn
|
||||
RUN corepack enable
|
||||
|
||||
# Set working directory to frontend
|
||||
WORKDIR /workspace/frontend
|
||||
|
||||
# Install frontend dependencies
|
||||
RUN yarn install --immutable
|
||||
|
||||
# Verify tools are available (these should be installed via package.json)
|
||||
RUN yarn eslint --version
|
||||
RUN yarn prettier --version
|
||||
RUN yarn tsc --version
|
||||
|
||||
# Build the application
|
||||
RUN yarn build
|
||||
|
||||
# Verify build output
|
||||
RUN ls -la dist/ && echo "Frontend build completed successfully"
|
||||
|
||||
# Set working directory back to workspace root for flexibility
|
||||
WORKDIR /workspace
|
||||
|
||||
# Default command
|
||||
CMD ["/bin/bash"]
|
||||
@@ -1,24 +0,0 @@
|
||||
# CICD Setup - Base image with source code checkout
|
||||
FROM ubuntu:22.04
|
||||
|
||||
# Install essential tools
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
curl \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /workspace
|
||||
|
||||
# Copy the entire project (this will be the "checkout" layer)
|
||||
COPY . .
|
||||
|
||||
# Ensure proper permissions
|
||||
RUN chmod -R 755 /workspace
|
||||
|
||||
# Default to bash for better shell support
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
# This image contains the full project source code
|
||||
CMD ["/bin/bash"]
|
||||
@@ -12,7 +12,13 @@ dev = [
|
||||
"pytest-cov>=4.1.0",
|
||||
"typeguard>=4.1.0",
|
||||
"httpx>=0.25.0", # For testing async HTTP calls
|
||||
"pytest-mock>=3.12.0"
|
||||
"pytest-mock>=3.12.0",
|
||||
# File format and linting tools
|
||||
"pyyaml>=6.0",
|
||||
"yamllint>=1.35.0",
|
||||
"toml-sort>=0.23.0",
|
||||
"language-formatters-pre-commit-hooks>=2.14.0", # For pretty-format-toml
|
||||
"xdoctest>=1.1.0" # For doctest support
|
||||
]
|
||||
|
||||
[tool.coverage]
|
||||
|
||||
Reference in New Issue
Block a user