issues/27: autotest foundation — TestTraceProcessor, PHPUnit suites, CI coverage
backend-ci-cd / parse-tag (push) Has been cancelled
backend-ci-cd / test (push) Has been cancelled
backend-ci-cd / test-prod-skip (push) Has been cancelled
backend-ci-cd / build-and-push (push) Has been cancelled
backend-ci-cd / deploy-gitops (push) Has been cancelled
backend-ci-cd / parse-tag (push) Has been cancelled
backend-ci-cd / test (push) Has been cancelled
backend-ci-cd / test-prod-skip (push) Has been cancelled
backend-ci-cd / build-and-push (push) Has been cancelled
backend-ci-cd / deploy-gitops (push) Has been cancelled
This commit is contained in:
+61
-22
@@ -1,7 +1,6 @@
|
||||
name: backend-ci-cd
|
||||
|
||||
# CI/CD: только push git-тега (ручное тегирование на ветке prod|test|stage).
|
||||
# Push в ветки и feature-ветки pipeline не запускают.
|
||||
# CI/CD: только push git-тега. Pre-deploy tests на test|stage; prod — без тестов (ручной аппрув релиза).
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -14,25 +13,6 @@ env:
|
||||
IMAGE_DEPLOY: git.sova.local/sova/backend
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.4'
|
||||
extensions: pdo_pgsql, redis, intl, zip, gd
|
||||
- name: Prepare CI environment
|
||||
run: |
|
||||
cp .env.ci .env.local
|
||||
mkdir -p config/jwt var
|
||||
openssl genrsa -out config/jwt/private.pem 2048
|
||||
openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pem
|
||||
- run: composer install --prefer-dist --no-interaction
|
||||
- run: composer phpunit || true
|
||||
- run: composer audit || true
|
||||
|
||||
parse-tag:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
@@ -48,8 +28,67 @@ jobs:
|
||||
echo "env=$(echo "$TAG" | sed -E 's/backend-v([0-9.]+)-([a-z]+)/\2/')" >> "$GITHUB_OUTPUT"
|
||||
echo "version=$(echo "$TAG" | sed -E 's/backend-v([0-9.]+).*/\1/')" >> "$GITHUB_OUTPUT"
|
||||
|
||||
test:
|
||||
needs: [parse-tag]
|
||||
if: needs.parse-tag.outputs.env != 'prod'
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
env:
|
||||
POSTGRES_USER: ci
|
||||
POSTGRES_PASSWORD: ci
|
||||
POSTGRES_DB: ci
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd "pg_isready -U ci -d ci"
|
||||
--health-interval 5s
|
||||
--health-timeout 5s
|
||||
--health-retries 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.4'
|
||||
extensions: pdo_pgsql, redis, intl, zip, gd
|
||||
coverage: xdebug
|
||||
- name: Prepare CI environment
|
||||
run: |
|
||||
cp .env.ci .env.local
|
||||
mkdir -p config/jwt var/coverage
|
||||
openssl genrsa -out config/jwt/private.pem 2048
|
||||
openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pem
|
||||
- run: composer install --prefer-dist --no-interaction
|
||||
- name: Unit tests + coverage
|
||||
run: composer phpunit:coverage
|
||||
- name: Integration tests (test contour only)
|
||||
if: needs.parse-tag.outputs.env == 'test'
|
||||
continue-on-error: true
|
||||
run: |
|
||||
php bin/console doctrine:database:create --if-not-exists --env=test || true
|
||||
php bin/console doctrine:migrations:migrate --no-interaction --env=test || true
|
||||
composer phpunit:integration
|
||||
- name: Upload coverage
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: backend-coverage-${{ needs.parse-tag.outputs.full_tag }}
|
||||
path: var/coverage/
|
||||
retention-days: 14
|
||||
- run: composer audit || true
|
||||
|
||||
test-prod-skip:
|
||||
needs: [parse-tag]
|
||||
if: needs.parse-tag.outputs.env == 'prod'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "Prod tag — automated tests skipped (no tests on production contour)."
|
||||
|
||||
build-and-push:
|
||||
needs: [test, parse-tag]
|
||||
needs: [parse-tag, test, test-prod-skip]
|
||||
if: always() && (needs.test.result == 'success' || needs.test.result == 'skipped') && (needs.test-prod-skip.result == 'success' || needs.test-prod-skip.result == 'skipped')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
Reference in New Issue
Block a user