feat: přidání testů – Jest unit testy + Playwright E2E + CI pipeline #54
+28
-18
@@ -3,7 +3,7 @@ name: CI
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- '**'
|
- "**"
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
@@ -22,7 +22,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: "22"
|
||||||
|
|
||||||
- run: npm install -g yarn
|
- run: npm install -g yarn
|
||||||
|
|
||||||
@@ -42,14 +42,14 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
NODE_ENV: test
|
NODE_ENV: test
|
||||||
JWT_SECRET: test-secret-min-32-chars-aaaaaaa!
|
JWT_SECRET: test-secret-min-32-chars-aaaaaaa!
|
||||||
MOCK_DATA: 'true'
|
MOCK_DATA: "true"
|
||||||
STORAGE: json
|
STORAGE: json
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: "22"
|
||||||
|
|
||||||
- run: npm install -g yarn
|
- run: npm install -g yarn
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: "22"
|
||||||
|
|
||||||
- run: npm install -g yarn
|
- run: npm install -g yarn
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: "22"
|
||||||
|
|
||||||
- run: npm install -g yarn
|
- run: npm install -g yarn
|
||||||
|
|
||||||
@@ -131,16 +131,16 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
REDIS_ARGS: "--save '' --loglevel warning"
|
REDIS_ARGS: "--save '' --loglevel warning"
|
||||||
env:
|
env:
|
||||||
CI: 'true'
|
CI: "true"
|
||||||
NODE_ENV: test
|
NODE_ENV: test
|
||||||
JWT_SECRET: test-secret-min-32-chars-aaaaaaa!
|
JWT_SECRET: test-secret-min-32-chars-aaaaaaa!
|
||||||
MOCK_DATA: 'true'
|
MOCK_DATA: "true"
|
||||||
STORAGE: redis
|
STORAGE: redis
|
||||||
REDIS_HOST: redis
|
REDIS_HOST: redis
|
||||||
REDIS_PORT: '6379'
|
REDIS_PORT: "6379"
|
||||||
HTTP_REMOTE_USER_ENABLED: 'true'
|
HTTP_REMOTE_USER_ENABLED: "true"
|
||||||
HTTP_REMOTE_USER_HEADER_NAME: remote-user
|
HTTP_REMOTE_USER_HEADER_NAME: remote-user
|
||||||
HTTP_REMOTE_TRUSTED_IPS: '127.0.0.1,::1,::ffff:127.0.0.1'
|
HTTP_REMOTE_TRUSTED_IPS: "127.0.0.1,::1,::ffff:127.0.0.1"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -161,7 +161,8 @@ jobs:
|
|||||||
run: cp -r client/dist server/public
|
run: cp -r client/dist server/public
|
||||||
|
|
||||||
- name: Install e2e dependencies and browsers
|
- name: Install e2e dependencies and browsers
|
||||||
run: cd e2e && yarn install --frozen-lockfile && yarn playwright install firefox --with-deps
|
run: cd e2e && yarn install --frozen-lockfile && yarn playwright install firefox
|
||||||
|
--with-deps
|
||||||
|
|
||||||
- name: Run Playwright tests
|
- name: Run Playwright tests
|
||||||
run: cd e2e && yarn test
|
run: cd e2e && yarn test
|
||||||
@@ -186,7 +187,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: "22"
|
||||||
|
|
||||||
- run: npm install -g yarn
|
- run: npm install -g yarn
|
||||||
|
|
||||||
@@ -219,28 +220,32 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.REPO_URL }}/${{ secrets.REPO_NAME }}:latest
|
tags: ${{ secrets.REPO_URL }}/${{ secrets.REPO_NAME }}:latest
|
||||||
|
|
||||||
# ─── 5. Discord notification (master only, always) ────────────────────────
|
# ─── 5. Notifications ────────────────────────
|
||||||
|
|
||||||
discord-notify:
|
notify:
|
||||||
name: Discord notification
|
name: Notify
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [ server-build, client-build, server-test, e2e, docker-build ]
|
needs: [ server-build, client-build, server-test, e2e, docker-build ]
|
||||||
if: always() && github.event_name == 'push' && github.ref == 'refs/heads/master'
|
if: always() && github.event_name == 'push'
|
||||||
steps:
|
steps:
|
||||||
- name: Send webhook
|
- name: Send webhook
|
||||||
env:
|
env:
|
||||||
DISCORD_WEBHOOK_ID: ${{ secrets.DISCORD_WEBHOOK_ID }}
|
DISCORD_WEBHOOK_ID: ${{ secrets.DISCORD_WEBHOOK_ID }}
|
||||||
DISCORD_WEBHOOK_TOKEN: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
|
DISCORD_WEBHOOK_TOKEN: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
|
||||||
|
NTFY_URL: ${{ secrets.NTFY_URL }}
|
||||||
BUILD_RESULT: ${{ needs.docker-build.result }}
|
BUILD_RESULT: ${{ needs.docker-build.result }}
|
||||||
RUN_NUMBER: ${{ github.run_number }}
|
RUN_NUMBER: ${{ github.run_number }}
|
||||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{
|
||||||
|
github.run_id }}
|
||||||
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
||||||
COMMIT_AUTHOR: ${{ github.event.head_commit.author.name }}
|
COMMIT_AUTHOR: ${{ github.event.head_commit.author.name }}
|
||||||
run: |
|
run: |
|
||||||
if [ "$BUILD_RESULT" = "success" ]; then
|
if [ "$BUILD_RESULT" = "success" ]; then
|
||||||
MSG="✅ Sestavení #${RUN_NUMBER} proběhlo úspěšně."
|
MSG="✅ Sestavení #${RUN_NUMBER} proběhlo úspěšně."
|
||||||
|
NTFY_TAGS="white_check_mark"
|
||||||
else
|
else
|
||||||
MSG="❌ Sestavení #${RUN_NUMBER} selhalo."
|
MSG="❌ Sestavení #${RUN_NUMBER} selhalo."
|
||||||
|
NTFY_TAGS="x"
|
||||||
fi
|
fi
|
||||||
FULL_MSG="$(printf '%s\n\nPipeline: %s\nPoslední commit: %sAutor: %s' \
|
FULL_MSG="$(printf '%s\n\nPipeline: %s\nPoslední commit: %sAutor: %s' \
|
||||||
"$MSG" "$RUN_URL" "$COMMIT_MESSAGE" "$COMMIT_AUTHOR")"
|
"$MSG" "$RUN_URL" "$COMMIT_MESSAGE" "$COMMIT_AUTHOR")"
|
||||||
@@ -248,3 +253,8 @@ jobs:
|
|||||||
"https://discord.com/api/webhooks/${DISCORD_WEBHOOK_ID}/${DISCORD_WEBHOOK_TOKEN}" \
|
"https://discord.com/api/webhooks/${DISCORD_WEBHOOK_ID}/${DISCORD_WEBHOOK_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
--data "$(jq -n --arg content "$FULL_MSG" '{content: $content}')"
|
--data "$(jq -n --arg content "$FULL_MSG" '{content: $content}')"
|
||||||
|
curl -s -X POST "${NTFY_URL}" \
|
||||||
|
-H "Title: Luncher CI #${RUN_NUMBER}" \
|
||||||
|
-H "Tags: ${NTFY_TAGS}" \
|
||||||
|
-H "Click: ${RUN_URL}" \
|
||||||
|
-d "${FULL_MSG}"
|
||||||
|
|||||||
Reference in New Issue
Block a user