refactor(ci): единый ci.yml — test через E2E stage в одном run.
CI / test (push) Successful in 2m21s
CI / push-image (push) Successful in 6m24s
CI / deploy-ift (push) Successful in 18s
CI / ci-done (push) Successful in 0s
CI / e2e-ift (push) Successful in 57s
CI / deploy-stage (push) Successful in 5m26s
CI / e2e-stage (push) Successful in 1m12s

Удалены deploy/e2e workflow_run; workflow_dispatch input pipeline.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-16 16:16:00 +03:00
parent 273a4f3acf
commit b2cd4b53fc
5 changed files with 264 additions and 282 deletions
+264 -14
View File
@@ -1,14 +1,29 @@
name: CI
# PR / push: test + push образа (на push).
# push master/main: test → push-image → deploy IFT → E2E IFT → deploy stage → E2E stage (один run).
# workflow_dispatch: выбор фазы (см. input pipeline).
on:
push:
branches: [master, main]
pull_request:
workflow_dispatch:
inputs:
pipeline:
description: "Режим (push master = full автоматически)"
required: false
default: full
type: choice
options:
- full
- test-only
- deploy-ift
- e2e-ift
- deploy-stage
- e2e-stage
# Один runner (DESKTOP-SIR8B3R): параллельные workflow ломают кэш act/actions.
concurrency:
group: eventhub-frontadmin-ci-${{ github.ref }}
group: eventhub-frontadmin-${{ github.ref }}
cancel-in-progress: false
env:
@@ -18,6 +33,10 @@ env:
jobs:
test:
if: |
github.event_name == 'pull_request' ||
github.event_name == 'push' ||
(github.event_name == 'workflow_dispatch' && (github.event.inputs.pipeline == 'full' || github.event.inputs.pipeline == 'test-only'))
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
@@ -25,7 +44,6 @@ jobs:
steps:
- uses: actions/checkout@v4
# Без cache: npm — act_runner отменяет шаг на распаковке ~546MB (exit -1).
- uses: actions/setup-node@v4
with:
node-version: '22'
@@ -40,8 +58,6 @@ jobs:
echo "VITE_APP_VERSION=${APP_VERSION}" >> "$GITHUB_ENV"
echo "VITE_GIT_SHA=${GIT_SHA}" >> "$GITHUB_ENV"
echo "VITE_BUILT_AT=${BUILT_AT}" >> "$GITHUB_ENV"
echo "version=${APP_VERSION}" >> "$GITHUB_OUTPUT"
echo "git_sha=${GIT_SHA}" >> "$GITHUB_OUTPUT"
- run: npm ci
- run: npm run lint
@@ -54,7 +70,7 @@ jobs:
run: npm run test:e2e
- name: Upload dist for docker job
if: github.event_name == 'push'
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'full')
uses: actions/upload-artifact@v3
with:
name: admin-ui-dist
@@ -76,7 +92,14 @@ jobs:
push-image:
needs: test
if: github.event_name == 'push' && needs.test.outputs.ci_test_ok == '1'
if: |
always() &&
needs.test.result == 'success' &&
needs.test.outputs.ci_test_ok == '1' &&
(
github.event_name == 'push' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'full')
)
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
@@ -139,27 +162,254 @@ jobs:
if: success()
run: echo "ok=1" >> "$GITHUB_OUTPUT"
deploy-ift:
needs: push-image
if: |
always() && (
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'deploy-ift') ||
(
needs.push-image.result == 'success' &&
(
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'full')
)
)
)
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Compute image tag
id: meta
run: echo "tag=sha-${GITHUB_SHA:0:12}" >> "$GITHUB_OUTPUT"
- name: Wait for Docker daemon
run: bash scripts/ensure-docker-daemon.sh 240
- name: Login to registry
uses: docker/login-action@v2
with:
registry: git.sabilin.com
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Verify admin-ui image from CI
run: |
set -euo pipefail
TAG="${{ steps.meta.outputs.tag }}"
if ! docker buildx imagetools inspect "${REGISTRY}/eventhub-admin-ui:${TAG}" >/dev/null 2>&1; then
echo "Образ eventhub-admin-ui:${TAG} не найден — test/push-image не завершились."
exit 1
fi
echo "OK: eventhub-admin-ui:${TAG}"
- name: Deploy admin on IFT via SSH
uses: appleboy/ssh-action@v0.1.5
with:
host: ${{ secrets.IFT_SSH_HOST }}
username: ${{ secrets.IFT_SSH_USER }}
key: ${{ secrets.IFT_SSH_PRIVATE_KEY }}
script: |
export REGISTRY_USER='${{ secrets.REGISTRY_USER }}'
export REGISTRY_PASSWORD='${{ secrets.REGISTRY_PASSWORD }}'
bash /opt/eventhub-ift/devops/scripts/deploy-service.sh ift admin ${{ steps.meta.outputs.tag }}
e2e-ift:
needs: deploy-ift
if: |
always() && (
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'e2e-ift') ||
(
needs.deploy-ift.result == 'success' &&
(
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'full')
)
)
)
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- run: npm ci
- name: Install Playwright browser
run: bash scripts/install-playwright-chromium.sh
- name: Load smoke credentials from IFT .env
env:
SSH_HOST: ${{ secrets.IFT_SSH_HOST }}
SSH_USER: ${{ secrets.IFT_SSH_USER }}
SSH_KEY: ${{ secrets.IFT_SSH_PRIVATE_KEY }}
run: bash scripts/load-stand-smoke-env.sh ift
- name: E2E IFT (integration, live API)
env:
E2E_TARGET: ift
E2E_IFT_BASE_URL: ${{ secrets.E2E_IFT_BASE_URL }}
run: npm run test:e2e:ift
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@v3
with:
name: playwright-ift-report
path: playwright-report/
retention-days: 7
deploy-stage:
needs: e2e-ift
if: |
always() && (
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'deploy-stage') ||
(
needs.e2e-ift.result == 'success' &&
(
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'full')
)
)
)
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Compute image tag
id: meta
run: echo "tag=sha-${GITHUB_SHA:0:12}" >> "$GITHUB_OUTPUT"
- name: Wait for Docker daemon
run: bash scripts/ensure-docker-daemon.sh 240
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to registry
uses: docker/login-action@v2
with:
registry: git.sabilin.com
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Verify admin-ui image from CI
run: |
set -euo pipefail
TAG="${{ steps.meta.outputs.tag }}"
if ! docker buildx imagetools inspect "${REGISTRY}/eventhub-admin-ui:${TAG}" >/dev/null 2>&1; then
echo "Образ eventhub-admin-ui:${TAG} не найден — test push не завершился."
exit 1
fi
echo "OK: eventhub-admin-ui:${TAG}"
- name: Promote sha → :stage (no rebuild)
env:
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
run: |
bash scripts/clone-devops-run.sh scripts/promote-images.sh \
"${{ steps.meta.outputs.tag }}" \
"${{ steps.meta.outputs.tag }}" \
stage \
eventhub-admin-ui
- name: Deploy admin on stage via SSH
uses: appleboy/ssh-action@v0.1.5
with:
host: ${{ secrets.STAGE_SSH_HOST }}
username: ${{ secrets.STAGE_SSH_USER }}
key: ${{ secrets.STAGE_SSH_PRIVATE_KEY }}
script: |
export REGISTRY_USER='${{ secrets.REGISTRY_USER }}'
export REGISTRY_PASSWORD='${{ secrets.REGISTRY_PASSWORD }}'
bash /opt/eventhub-stage/devops/scripts/deploy-service.sh stage admin ${{ steps.meta.outputs.tag }}
- name: Prune old registry images
continue-on-error: true
env:
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
run: bash scripts/clone-devops-run.sh scripts/prune-registry-images.sh
e2e-stage:
needs: deploy-stage
if: |
always() && (
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'e2e-stage') ||
(
needs.deploy-stage.result == 'success' &&
(
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.pipeline == 'full')
)
)
)
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- run: npm ci
- name: Install Playwright browser
run: bash scripts/install-playwright-chromium.sh
- name: Load smoke credentials from stage .env
env:
SSH_HOST: ${{ secrets.STAGE_SSH_HOST }}
SSH_USER: ${{ secrets.STAGE_SSH_USER }}
SSH_KEY: ${{ secrets.STAGE_SSH_PRIVATE_KEY }}
run: bash scripts/load-stand-smoke-env.sh stage
- name: E2E stage (integration, live API)
env:
E2E_TARGET: stage
E2E_STAGE_BASE_URL: ${{ secrets.E2E_STAGE_BASE_URL }}
run: npm run test:e2e:stage
- name: Upload Playwright report
if: failure()
uses: actions/upload-artifact@v3
with:
name: playwright-stage-report
path: playwright-report/
retention-days: 7
ci-done:
needs: [test, push-image]
if: always()
if: |
always() && (
github.event_name == 'pull_request' ||
github.event_name == 'push' ||
(github.event_name == 'workflow_dispatch' && (github.event.inputs.pipeline == 'full' || github.event.inputs.pipeline == 'test-only'))
)
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Enforce CI completion
- name: Enforce CI gate (test / push on push & PR)
run: |
set -euo pipefail
TEST_OK="${{ needs.test.outputs.ci_test_ok }}"
if [ "${TEST_OK}" != "1" ]; then
echo "::error::test job incomplete (runner reported success without output)"
if [ "${{ needs.test.outputs.ci_test_ok }}" != "1" ]; then
echo "::error::test job incomplete"
exit 1
fi
if [ "${{ github.event_name }}" = "push" ]; then
if [ "${{ github.event_name }}" = "push" ] || ( [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.pipeline }}" = "full" ] ); then
if [ "${{ needs.push-image.result }}" != "success" ]; then
echo "::error::push-image must succeed, got: ${{ needs.push-image.result }}"
exit 1
fi
if [ "${{ needs.push-image.outputs.ci_push_ok }}" != "1" ]; then
echo "::error::push-image incomplete (output missing)"
echo "::error::push-image incomplete"
exit 1
fi
fi