57 lines
1.8 KiB
YAML
57 lines
1.8 KiB
YAML
name: Tests
|
|
run-name: ${{ gitea.actor }} build image and push to container registry
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'renew_tests' #1
|
|
|
|
jobs:
|
|
CreateImage:
|
|
runs-on: edge_pena_monitoring1
|
|
steps:
|
|
- name: Check out repository code
|
|
uses: http://gitea.pena:3000/PenaDevops/actions.git/checkout@v1
|
|
|
|
- name: Login to registry
|
|
run: |
|
|
podman login -u "${{ secrets.REGISTRY_USER }}" -p "${{ secrets.REGISTRY_PASSWORD }}" gitea.pena
|
|
|
|
- name: Build image
|
|
run: |
|
|
IMAGE_NAME="gitea.pena/${{ gitea.repository }}/tests:${{ gitea.run_id }}"
|
|
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
|
|
podman build -t "$IMAGE_NAME" .
|
|
|
|
- name: Push image
|
|
run: |
|
|
podman push "$IMAGE_NAME"
|
|
outputs:
|
|
image-url: ${{ env.IMAGE_NAME }}
|
|
|
|
Tests:
|
|
needs:
|
|
- CreateImage
|
|
runs-on: edge_pena_monitoring1
|
|
container:
|
|
image: ${{ needs.Build-Image.outputs.image-url }}
|
|
env:
|
|
GITHUB_RUN_NUMBER: "${{ gitea.run_id }}"
|
|
steps:
|
|
- name: Check out repository code
|
|
uses: http://gitea.pena:3000/PenaDevops/actions.git/checkout@v1
|
|
|
|
- name: Run tests on staging
|
|
run: |
|
|
echo "🧪 Запуск тестов на staging..."
|
|
export DOCKER_BUILDKIT=0
|
|
compose -f deployments/renew_tests/docker-compose.yaml up --build --abort-on-container-exit --exit-code-from app
|
|
TEST_EXIT_CODE=$?
|
|
echo "🧹 Очистка тестовых ресурсов..."
|
|
compose -f deployments/renew_tests/docker-compose.yaml down -v
|
|
if [ $TEST_EXIT_CODE -ne 0 ]; then
|
|
echo "❌ Тесты не прошли! Деплой будет остановлен."
|
|
exit $TEST_EXIT_CODE
|
|
else
|
|
echo "✅ Тесты прошли успешно!"
|
|
fi |