ci: split api inventory e2e into artifact-backed job
Some checks failed
Some checks failed
This commit is contained in:
@@ -156,15 +156,36 @@ jobs:
|
|||||||
. .venv/bin/activate
|
. .venv/bin/activate
|
||||||
uv sync --dev --frozen
|
uv sync --dev --frozen
|
||||||
|
|
||||||
- name: Run Django tests
|
- name: Run regular pytest suite
|
||||||
env:
|
env:
|
||||||
DJANGO_SETTINGS_MODULE: settings.test
|
DJANGO_SETTINGS_MODULE: settings.test
|
||||||
SECRET_KEY: test-secret-key-for-ci
|
SECRET_KEY: test-secret-key-for-ci
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
. .venv/bin/activate
|
|
||||||
export PYTHONPATH="${PWD}/src:${PYTHONPATH:-}"
|
export PYTHONPATH="${PWD}/src:${PYTHONPATH:-}"
|
||||||
python src/manage.py test tests --verbosity=2
|
.venv/bin/python -m pytest tests --ignore=tests/test_api_inventory_e2e.py -q
|
||||||
|
|
||||||
|
- name: Pack prepared test workspace
|
||||||
|
if: success()
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
tar \
|
||||||
|
--exclude='.git' \
|
||||||
|
--exclude='ci-test-workspace.tar.gz' \
|
||||||
|
--exclude='.pytest_cache' \
|
||||||
|
--exclude='htmlcov' \
|
||||||
|
--exclude='__pycache__' \
|
||||||
|
-czf ci-test-workspace.tar.gz \
|
||||||
|
.
|
||||||
|
|
||||||
|
- name: Upload prepared test workspace
|
||||||
|
if: success()
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ci-test-workspace
|
||||||
|
path: ci-test-workspace.tar.gz
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
- name: Telegram notify (test failed)
|
- name: Telegram notify (test failed)
|
||||||
if: failure()
|
if: failure()
|
||||||
@@ -195,20 +216,77 @@ jobs:
|
|||||||
--data-urlencode "text=${MSG}" \
|
--data-urlencode "text=${MSG}" \
|
||||||
|| echo "Telegram notification failed; continue pipeline"
|
|| echo "Telegram notification failed; continue pipeline"
|
||||||
|
|
||||||
|
test_api_inventory_e2e:
|
||||||
|
name: Run API Inventory E2E Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
needs: [test]
|
||||||
|
if: ${{ needs.test.result == 'success' }}
|
||||||
|
env:
|
||||||
|
TG_BOT_KEY: ${{ secrets.TG_BOT_KEY }}
|
||||||
|
TG_CHANNEL: ${{ secrets.TG_CHANNEL }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download prepared test workspace
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: ci-test-workspace
|
||||||
|
|
||||||
|
- name: Extract prepared test workspace
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
tar -xzf ci-test-workspace.tar.gz
|
||||||
|
|
||||||
|
- name: Run API inventory pytest suite
|
||||||
|
env:
|
||||||
|
DJANGO_SETTINGS_MODULE: settings.test
|
||||||
|
SECRET_KEY: test-secret-key-for-ci
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
export PYTHONPATH="${PWD}/src:${PYTHONPATH:-}"
|
||||||
|
.venv/bin/python -m pytest tests/test_api_inventory_e2e.py -q
|
||||||
|
|
||||||
|
- name: Telegram notify (api inventory e2e failed)
|
||||||
|
if: failure()
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
if [ -z "${TG_BOT_KEY:-}" ] || [ -z "${TG_CHANNEL:-}" ]; then
|
||||||
|
echo "TG_BOT_KEY or TG_CHANNEL is not set; skip telegram notification"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
MSG="❌ [mostovik-backend] api inventory e2e failed
|
||||||
|
branch=${GITHUB_REF_NAME}
|
||||||
|
sha=${GITHUB_SHA}
|
||||||
|
actor=${GITHUB_ACTOR}"
|
||||||
|
|
||||||
|
curl -fsS \
|
||||||
|
--connect-timeout 5 \
|
||||||
|
--max-time 15 \
|
||||||
|
--retry 2 \
|
||||||
|
--retry-delay 2 \
|
||||||
|
--retry-all-errors \
|
||||||
|
-X POST "https://api.telegram.org/bot${TG_BOT_KEY}/sendMessage" \
|
||||||
|
-d "chat_id=${TG_CHANNEL}" \
|
||||||
|
--data-urlencode "text=${MSG}" \
|
||||||
|
|| echo "Telegram notification failed; continue pipeline"
|
||||||
|
|
||||||
notify_success:
|
notify_success:
|
||||||
name: Telegram Notify Success
|
name: Telegram Notify Success
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 1
|
timeout-minutes: 1
|
||||||
needs: [lint, test]
|
needs: [lint, test, test_api_inventory_e2e]
|
||||||
if: |
|
if: |
|
||||||
always() &&
|
always() &&
|
||||||
needs.lint.result == 'success' &&
|
needs.lint.result == 'success' &&
|
||||||
needs.test.result == 'success'
|
needs.test.result == 'success' &&
|
||||||
|
needs.test_api_inventory_e2e.result == 'success'
|
||||||
env:
|
env:
|
||||||
TG_BOT_KEY: ${{ secrets.TG_BOT_KEY }}
|
TG_BOT_KEY: ${{ secrets.TG_BOT_KEY }}
|
||||||
TG_CHANNEL: ${{ secrets.TG_CHANNEL }}
|
TG_CHANNEL: ${{ secrets.TG_CHANNEL }}
|
||||||
steps:
|
steps:
|
||||||
- name: Telegram notify (lint+test success)
|
- name: Telegram notify (lint+tests+e2e success)
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
env:
|
env:
|
||||||
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
||||||
@@ -219,7 +297,7 @@ jobs:
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MSG="✅ [mostovik-backend] lint + tests passed
|
MSG="✅ [mostovik-backend] lint + tests + api inventory e2e passed
|
||||||
branch=${GITHUB_REF_NAME}
|
branch=${GITHUB_REF_NAME}
|
||||||
sha=${GITHUB_SHA}
|
sha=${GITHUB_SHA}
|
||||||
actor=${GITHUB_ACTOR}
|
actor=${GITHUB_ACTOR}
|
||||||
|
|||||||
Reference in New Issue
Block a user