issues/27: CI Jest coverage on test and stage tags
This commit is contained in:
+37
-20
@@ -1,6 +1,6 @@
|
|||||||
name: adminpanel-ci-cd
|
name: adminpanel-ci-cd
|
||||||
|
|
||||||
# CI/CD: только push git-тега (ручное тегирование на ветке prod|test|stage).
|
# Pre-deploy: Jest + coverage on test|stage tags. Prod — без автотестов.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -13,18 +13,6 @@ env:
|
|||||||
IMAGE_DEPLOY: git.sova.local/sova/adminpanel
|
IMAGE_DEPLOY: git.sova.local/sova/adminpanel
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '24'
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
if [ -f package-lock.json ]; then npm ci; else npm install; fi
|
|
||||||
- run: npm run build
|
|
||||||
|
|
||||||
parse-tag:
|
parse-tag:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
@@ -40,8 +28,42 @@ jobs:
|
|||||||
echo "env=$(echo "$TAG" | sed -E 's/adminpanel-v([0-9.]+)-([a-z]+)/\2/')" >> "$GITHUB_OUTPUT"
|
echo "env=$(echo "$TAG" | sed -E 's/adminpanel-v([0-9.]+)-([a-z]+)/\2/')" >> "$GITHUB_OUTPUT"
|
||||||
echo "version=$(echo "$TAG" | sed -E 's/adminpanel-v([0-9.]+).*/\1/')" >> "$GITHUB_OUTPUT"
|
echo "version=$(echo "$TAG" | sed -E 's/adminpanel-v([0-9.]+).*/\1/')" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
test:
|
||||||
|
needs: [parse-tag]
|
||||||
|
if: needs.parse-tag.outputs.env != 'prod'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '24'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
if [ -f package-lock.json ]; then npm ci; else npm install; fi
|
||||||
|
- name: Lint
|
||||||
|
run: npm run lint
|
||||||
|
- name: Unit tests + coverage
|
||||||
|
run: npm run test:ci
|
||||||
|
- name: Build
|
||||||
|
run: npm run build
|
||||||
|
- name: Upload coverage
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: adminpanel-coverage-${{ needs.parse-tag.outputs.full_tag }}
|
||||||
|
path: coverage/
|
||||||
|
retention-days: 14
|
||||||
|
|
||||||
|
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."
|
||||||
|
|
||||||
build-and-push:
|
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
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -95,13 +117,8 @@ jobs:
|
|||||||
git add "apps/adminpanel/values-${ENV}.yaml"
|
git add "apps/adminpanel/values-${ENV}.yaml"
|
||||||
git diff --cached --quiet && { echo "No changes"; exit 0; }
|
git diff --cached --quiet && { echo "No changes"; exit 0; }
|
||||||
git commit -m "chore(adminpanel): bump ${ENV} to ${TAG}"
|
git commit -m "chore(adminpanel): bump ${ENV} to ${TAG}"
|
||||||
if git push origin "${ENV}"; then
|
if git push origin "${ENV}"; then exit 0; fi
|
||||||
echo "Push OK on attempt ${attempt}"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "Push failed, retry ${attempt}/${MAX_RETRIES}..."
|
|
||||||
git reset --hard HEAD~1
|
git reset --hard HEAD~1
|
||||||
sleep $((attempt * 2))
|
sleep $((attempt * 2))
|
||||||
done
|
done
|
||||||
echo "Failed to push after ${MAX_RETRIES} attempts"
|
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"lint-fix": "eslint . --fix",
|
"lint-fix": "eslint . --fix",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "jest --runInBand",
|
"test": "jest --runInBand",
|
||||||
|
"test:ci": "jest --runInBand --coverage --coverageReporters=text-summary --coverageReporters=lcov",
|
||||||
"test-watch": "jest --watch",
|
"test-watch": "jest --watch",
|
||||||
"test-clear-cache": "jest --clearCache"
|
"test-clear-cache": "jest --clearCache"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user