All checks were successful
CICD Start / Sanity and Base Decision (pull_request) Successful in 1m10s
Signed-off-by: copilotcoder <copilotcoder@darkhelm.org>
143 lines
5.1 KiB
YAML
143 lines
5.1 KiB
YAML
name: CICD Tests
|
||
|
||
on:
|
||
workflow_run:
|
||
workflows: [ "CICD Checks" ]
|
||
types: [ completed ]
|
||
workflow_dispatch:
|
||
|
||
env:
|
||
GITEA_REGISTRY: kankali.darkhelm.lan:3001
|
||
GITEA_REGISTRY_IP: 10.18.75.2
|
||
GITEA_REGISTRY_HOST: kankali.darkhelm.lan
|
||
|
||
concurrency:
|
||
group: tests-${{ github.event.workflow_run.head_sha || github.sha }}
|
||
cancel-in-progress: true
|
||
|
||
jobs:
|
||
route:
|
||
name: Route Tests Trigger
|
||
runs-on: ubuntu-act
|
||
outputs:
|
||
run_tests: ${{ steps.route.outputs.run_tests }}
|
||
head_sha: ${{ steps.route.outputs.head_sha }}
|
||
steps:
|
||
- name: Decide whether to run tests
|
||
id: route
|
||
env:
|
||
EVENT_NAME: ${{ github.event_name }}
|
||
SOURCE_CONCLUSION: ${{ github.event.workflow_run.conclusion }}
|
||
HEAD_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
|
||
run: |
|
||
echo "head_sha=${HEAD_SHA}" >> "$GITHUB_OUTPUT"
|
||
if [ "${EVENT_NAME}" = "workflow_dispatch" ]; then
|
||
echo "run_tests=true" >> "$GITHUB_OUTPUT"
|
||
elif [ "${SOURCE_CONCLUSION}" = "success" ]; then
|
||
echo "run_tests=true" >> "$GITHUB_OUTPUT"
|
||
else
|
||
echo "run_tests=false" >> "$GITHUB_OUTPUT"
|
||
fi
|
||
|
||
backend-tests:
|
||
name: Backend Tests
|
||
runs-on: ubuntu-act
|
||
needs: route
|
||
if: needs.route.outputs.run_tests == 'true'
|
||
steps:
|
||
- &configure_registry_host_step
|
||
name: Configure registry host resolution
|
||
run: |
|
||
if ! grep -q "${GITEA_REGISTRY_HOST}" /etc/hosts; then
|
||
echo "${GITEA_REGISTRY_IP} ${GITEA_REGISTRY_HOST}" >> /etc/hosts
|
||
fi
|
||
- &ensure_cicd_image_step
|
||
name: Ensure CICD image is available
|
||
run: |
|
||
IMAGE="${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${{ needs.route.outputs.head_sha }}"
|
||
if docker image inspect "${IMAGE}" >/dev/null 2>&1; then
|
||
echo "Using cached CICD image: ${IMAGE}"
|
||
else
|
||
echo "${{ secrets.PACKAGE_ACCESS_TOKEN }}" | docker login "http://${GITEA_REGISTRY}" -u "${{ secrets.REGISTRY_USER || github.actor }}" --password-stdin
|
||
docker pull "${IMAGE}"
|
||
fi
|
||
- name: Run backend tests with coverage
|
||
run: |
|
||
docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${{ needs.route.outputs.head_sha }}" 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: route
|
||
if: needs.route.outputs.run_tests == 'true'
|
||
steps:
|
||
- *configure_registry_host_step
|
||
- *ensure_cicd_image_step
|
||
- name: Run frontend tests with coverage
|
||
run: |
|
||
docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${{ needs.route.outputs.head_sha }}" 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
|
||
"
|
||
|
||
xdoctest:
|
||
name: Backend Doctests
|
||
runs-on: ubuntu-act
|
||
needs: route
|
||
if: needs.route.outputs.run_tests == 'true'
|
||
steps:
|
||
- *configure_registry_host_step
|
||
- *ensure_cicd_image_step
|
||
- name: Run backend doctests
|
||
run: |
|
||
docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${{ needs.route.outputs.head_sha }}" bash -c "
|
||
cd /workspace/backend &&
|
||
source .venv/bin/activate &&
|
||
uv run xdoctest src/ --quiet
|
||
"
|
||
|
||
integration-tests:
|
||
name: Integration Tests
|
||
runs-on: ubuntu-act
|
||
needs: backend-tests
|
||
if: needs.backend-tests.result == 'success'
|
||
steps:
|
||
- *configure_registry_host_step
|
||
- *ensure_cicd_image_step
|
||
- name: Run integration tests
|
||
run: |
|
||
docker run --rm "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${{ needs.route.outputs.head_sha }}" 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: frontend-tests
|
||
if: needs.frontend-tests.result == 'success'
|
||
steps:
|
||
- *configure_registry_host_step
|
||
- *ensure_cicd_image_step
|
||
- name: Run E2E tests
|
||
run: |
|
||
docker run --rm -e CI=true "${GITEA_REGISTRY}/darkhelm.org/plex-playlist-cicd:${{ needs.route.outputs.head_sha }}" bash -c "
|
||
cd /workspace/frontend &&
|
||
if [ -d 'tests/e2e' ] || grep -q 'playwright' package.json; then
|
||
yarn playwright --version &&
|
||
timeout 300 yarn playwright install chromium &&
|
||
yarn test:e2e --reporter=list --timeout=90000
|
||
else
|
||
echo 'ℹ No E2E tests found'
|
||
fi
|
||
"
|