Test, build, and deploy ComfyUI Jobs / test-build (push) Failing after 25s
Test, build, and deploy ComfyUI Jobs / deploy (push) Skipped
Test, build, and deploy ComfyUI Jobs / browser-test (push) Skipped
Test, build, and deploy ComfyUI Jobs / qa-gate (push) Successful in 4s
209 lines
9.4 KiB
YAML
209 lines
9.4 KiB
YAML
name: Test, build, and deploy ComfyUI Jobs
|
|
on:
|
|
push:
|
|
branches: [develop, qa, main]
|
|
pull_request:
|
|
branches: [develop, qa, main]
|
|
jobs:
|
|
test-build:
|
|
runs-on: docker
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
github-server-url: https://git.dumas.ddns.net
|
|
- name: Verify runner Node.js
|
|
run: node --version && npm --version
|
|
- run: python3 scripts/verify-branch-port-mapping.py .
|
|
- run: npm ci --include=dev --prefer-offline --no-audit --no-fund
|
|
- run: npm test
|
|
- run: npm run lint
|
|
- run: npm run build
|
|
- name: Load deployment SSH key
|
|
if: ${{ gitea.event_name == 'push' }}
|
|
uses: webfactory/ssh-agent@v0.9.0
|
|
with:
|
|
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
- name: Build and publish immutable image
|
|
if: ${{ gitea.event_name == 'push' }}
|
|
shell: bash
|
|
env:
|
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
GITEA_REF: ${{ gitea.ref }}
|
|
GITEA_SHA: ${{ gitea.sha }}
|
|
run: |
|
|
set -Eeuo pipefail
|
|
mkdir -p ~/.ssh
|
|
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
|
case "$GITEA_REF" in
|
|
refs/heads/develop) TARGET_DIR=/mnt/appdata/dev/ComfyUiPortal; BRANCH=develop ;;
|
|
refs/heads/qa) TARGET_DIR=/mnt/appdata/qa/ComfyUiPortal; BRANCH=qa ;;
|
|
refs/heads/main) TARGET_DIR=/mnt/appdata/prod/ComfyUiPortal; BRANCH=main ;;
|
|
*) exit 0 ;;
|
|
esac
|
|
REPO_URL=ssh://git@git.dumas.ddns.net:222/chris.dumas/ComfyUiPortalNext.git
|
|
IMAGE_REF=git.dumas.ddns.net/chris.dumas/comfyui-portal-next:sha-${GITEA_SHA}
|
|
|
|
if [ -z "$REGISTRY_USERNAME" ] || [ -z "$REGISTRY_PASSWORD" ]; then
|
|
echo 'REGISTRY_USERNAME and REGISTRY_PASSWORD are required for registry authentication'
|
|
exit 1
|
|
fi
|
|
|
|
printf '%s' "$REGISTRY_PASSWORD" | ssh -o StrictHostKeyChecking=yes "${DEPLOY_USER}@${DEPLOY_HOST}" "docker login git.dumas.ddns.net --username '$REGISTRY_USERNAME' --password-stdin"
|
|
ssh -o StrictHostKeyChecking=yes "${DEPLOY_USER}@${DEPLOY_HOST}" "
|
|
set -Eeuo pipefail
|
|
trap 'docker logout git.dumas.ddns.net >/dev/null 2>&1 || true' EXIT
|
|
mkdir -p '$TARGET_DIR'
|
|
if [ ! -d '$TARGET_DIR/.git' ]; then git init '$TARGET_DIR' && cd '$TARGET_DIR' && git remote add origin '$REPO_URL'; else cd '$TARGET_DIR' && git remote set-url origin '$REPO_URL'; fi
|
|
cd '$TARGET_DIR'
|
|
GIT_SSH_COMMAND='ssh -p 222 -o StrictHostKeyChecking=no' git fetch origin '$BRANCH'
|
|
git reset --hard 'origin/$BRANCH'
|
|
git clean -fdx -e data/ -e data/**
|
|
if docker manifest inspect '$IMAGE_REF' >/dev/null 2>&1; then
|
|
echo 'Reusing existing immutable image $IMAGE_REF'
|
|
else
|
|
docker builder prune -af || true
|
|
docker build --tag '$IMAGE_REF' .
|
|
docker push '$IMAGE_REF'
|
|
fi
|
|
"
|
|
|
|
deploy:
|
|
if: ${{ gitea.event_name == 'push' }}
|
|
needs: test-build
|
|
runs-on: docker
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
github-server-url: https://git.dumas.ddns.net
|
|
- name: Load deployment SSH key
|
|
uses: webfactory/ssh-agent@v0.9.0
|
|
with:
|
|
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
|
|
- name: Deploy selected environment
|
|
shell: bash
|
|
env:
|
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
GITEA_REF: ${{ gitea.ref }}
|
|
GITEA_SHA: ${{ gitea.sha }}
|
|
run: |
|
|
set -Eeuo pipefail
|
|
mkdir -p ~/.ssh
|
|
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
|
case "$GITEA_REF" in
|
|
refs/heads/develop) TARGET_DIR=/mnt/appdata/dev/ComfyUiPortal; COMPOSE_FILE=docker-compose.dev.yml; PROJECT=comfyuiportal-next-dev; PORT=7002; HEALTH_URL=http://192.168.1.15:7002; BRANCH=develop ;;
|
|
refs/heads/qa) TARGET_DIR=/mnt/appdata/qa/ComfyUiPortal; COMPOSE_FILE=docker-compose.qa.yml; PROJECT=comfyuiportal-next-qa; PORT=6002; HEALTH_URL=http://192.168.1.15:6002; BRANCH=qa ;;
|
|
refs/heads/main) TARGET_DIR=/mnt/appdata/prod/ComfyUiPortal; COMPOSE_FILE=docker-compose.prod.yml; PROJECT=comfyuiportal-next-prod; PORT=5002; HEALTH_URL=http://192.168.1.15:5002; BRANCH=main ;;
|
|
*) exit 0 ;;
|
|
esac
|
|
REPO_URL=ssh://git@git.dumas.ddns.net:222/chris.dumas/ComfyUiPortalNext.git
|
|
IMAGE_REF=git.dumas.ddns.net/chris.dumas/comfyui-portal-next:sha-${GITEA_SHA}
|
|
|
|
if [ -z "$REGISTRY_USERNAME" ] || [ -z "$REGISTRY_PASSWORD" ]; then
|
|
echo 'REGISTRY_USERNAME and REGISTRY_PASSWORD are required for registry authentication'
|
|
exit 1
|
|
fi
|
|
|
|
printf '%s' "$REGISTRY_PASSWORD" | ssh -o StrictHostKeyChecking=yes "${DEPLOY_USER}@${DEPLOY_HOST}" "docker login git.dumas.ddns.net --username '$REGISTRY_USERNAME' --password-stdin"
|
|
|
|
ssh -o StrictHostKeyChecking=yes "${DEPLOY_USER}@${DEPLOY_HOST}" "
|
|
set -Eeuo pipefail
|
|
trap 'docker logout git.dumas.ddns.net >/dev/null 2>&1 || true' EXIT
|
|
mkdir -p '$TARGET_DIR'
|
|
if [ ! -d '$TARGET_DIR/.git' ]; then git init '$TARGET_DIR' && cd '$TARGET_DIR' && git remote add origin '$REPO_URL'; else cd '$TARGET_DIR' && git remote set-url origin '$REPO_URL'; fi
|
|
cd '$TARGET_DIR'
|
|
GIT_SSH_COMMAND='ssh -p 222 -o StrictHostKeyChecking=no' git fetch origin '$BRANCH'
|
|
git reset --hard 'origin/$BRANCH'
|
|
git clean -fdx -e data/ -e data/**
|
|
docker ps -q --filter publish=$PORT | xargs -r docker rm -f
|
|
docker compose -p '$PROJECT' -f docker-compose.yml -f '$COMPOSE_FILE' down --remove-orphans || true
|
|
IMAGE_REF='$IMAGE_REF' docker compose -p '$PROJECT' -f docker-compose.yml -f '$COMPOSE_FILE' pull
|
|
IMAGE_REF='$IMAGE_REF' docker compose -p '$PROJECT' -f docker-compose.yml -f '$COMPOSE_FILE' up -d
|
|
"
|
|
for attempt in 1 2 3 4 5 6; do curl --fail --silent --show-error --max-time 15 "$HEALTH_URL/api/health" && exit 0 || sleep 5; done
|
|
exit 1
|
|
|
|
browser-test:
|
|
if: ${{ gitea.event_name == 'push' && (gitea.ref == 'refs/heads/develop' || gitea.ref == 'refs/heads/qa') }}
|
|
needs: deploy
|
|
timeout-minutes: 35
|
|
runs-on: docker
|
|
env:
|
|
PLAYWRIGHT_BROWSERS_PATH: .playwright-browsers
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
github-server-url: https://git.dumas.ddns.net
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
- name: Install Playwright Chromium
|
|
run: npx playwright install --with-deps chromium
|
|
- name: Resolve browser test target
|
|
shell: bash
|
|
env:
|
|
GITEA_REF: ${{ gitea.ref }}
|
|
run: |
|
|
set -Eeuo pipefail
|
|
case "$GITEA_REF" in
|
|
refs/heads/develop) echo "E2E_BASE_URL=http://192.168.1.15:7002" >> "$GITHUB_ENV"; echo "E2E_ENVIRONMENT=dev" >> "$GITHUB_ENV" ;;
|
|
refs/heads/qa) echo "E2E_BASE_URL=http://192.168.1.15:6002" >> "$GITHUB_ENV"; echo "E2E_ENVIRONMENT=qa" >> "$GITHUB_ENV" ;;
|
|
*) echo "Unexpected browser-test ref: $GITEA_REF"; exit 1 ;;
|
|
esac
|
|
if [ -z "${{ secrets.COMFYUI_PORTAL_E2E_USERNAME }}" ] || [ -z "${{ secrets.COMFYUI_PORTAL_E2E_PASSWORD }}" ]; then
|
|
echo "COMFYUI_PORTAL_E2E_USERNAME and COMFYUI_PORTAL_E2E_PASSWORD must be configured before browser tests can run."
|
|
exit 1
|
|
fi
|
|
- name: Run browser tests against selected environment
|
|
id: browser
|
|
continue-on-error: true
|
|
env:
|
|
E2E_USERNAME: ${{ secrets.COMFYUI_PORTAL_E2E_USERNAME }}
|
|
E2E_PASSWORD: ${{ secrets.COMFYUI_PORTAL_E2E_PASSWORD }}
|
|
run: |
|
|
set +e
|
|
timeout --signal=TERM --kill-after=30s 30m npm run test:playwright
|
|
status=$?
|
|
exit "$status"
|
|
- name: Track browser failures in Gitea
|
|
if: always()
|
|
env:
|
|
GITEA_API_TOKEN: ${{ github.token }}
|
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
|
GITEA_RUN_ID: ${{ gitea.run_id }}
|
|
GITEA_SHA: ${{ gitea.sha }}
|
|
E2E_ENVIRONMENT: ${{ gitea.ref == 'refs/heads/qa' && 'qa' || 'dev' }}
|
|
BROWSER_TEST_OUTCOME: ${{ steps.browser.outcome }}
|
|
run: npm run qa:report
|
|
- name: Fail browser job when tests fail
|
|
if: ${{ steps.browser.outcome == 'failure' }}
|
|
run: exit 1
|
|
|
|
qa-gate:
|
|
if: ${{ always() && (gitea.event_name == 'push' || gitea.event_name == 'pull_request') }}
|
|
needs: [test-build, deploy, browser-test]
|
|
timeout-minutes: 5
|
|
runs-on: docker
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
github-server-url: https://git.dumas.ddns.net
|
|
- name: Check automated QA blockers
|
|
env:
|
|
GITEA_API_TOKEN: ${{ github.token }}
|
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
|
run: npm run qa:gate
|