Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ coverage
test-results
*.log
.env
**/.env
.DS_Store
56 changes: 56 additions & 0 deletions .github/actions/notify/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Notify workflow result
description: Send a non-blocking workflow result notification

inputs:
status:
description: Workflow result
required: true
environment:
description: Deployment environment or workflow context
required: true
message:
description: Human-readable notification message
required: true
webhook-url:
description: Notification webhook URL
required: true
provider-links:
description: Safe provider links or identifiers
required: false
default: ''
priority:
description: Notification priority
required: false
default: normal

runs:
using: composite
steps:
- name: Send notification
shell: bash
env:
NOTIFICATION_STATUS: ${{ inputs.status }}
NOTIFICATION_ENVIRONMENT: ${{ inputs.environment }}
NOTIFICATION_MESSAGE: ${{ inputs.message }}
NOTIFICATION_WEBHOOK_URL: ${{ inputs.webhook-url }}
NOTIFICATION_PROVIDER_LINKS: ${{ inputs.provider-links }}
NOTIFICATION_PRIORITY: ${{ inputs.priority }}
run: |
set -euo pipefail
payload="$(jq -n \
--arg repository "$GITHUB_REPOSITORY" \
--arg commit "$GITHUB_SHA" \
--arg run_url "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
--arg environment "$NOTIFICATION_ENVIRONMENT" \
--arg status "$NOTIFICATION_STATUS" \
--arg message "$NOTIFICATION_MESSAGE" \
--arg provider_links "$NOTIFICATION_PROVIDER_LINKS" \
--arg priority "$NOTIFICATION_PRIORITY" \
'{repository: $repository, commit: $commit, workflow_run_url: $run_url, environment: $environment, result: $status, priority: $priority, message: $message, provider_links: $provider_links}')"
if ! curl --fail --silent --show-error --max-time 10 \
-X POST \
-H 'Content-Type: application/json' \
--data "$payload" \
"$NOTIFICATION_WEBHOOK_URL"; then
echo "::warning::Workflow notification failed; the primary workflow result is unchanged."
fi
27 changes: 17 additions & 10 deletions .github/actions/setup-node-pnpm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ inputs:
description: Node.js version
required: false
default: '24'
pnpm-version:
description: pnpm version
required: false
default: '10.27.0'
working-directory:
description: Working directory for the project
required: true
description: Working directory for the project (used for compatibility; the workspace root is installed)
required: false
default: .

runs:
using: composite
Expand All @@ -27,10 +24,21 @@ runs:
with:
node-version: ${{ inputs.node-version }}

- name: Resolve repository package manager
id: package-manager
shell: bash
run: |
set -euo pipefail
package_manager="$(node -p "require('./package.json').packageManager")"
case "$package_manager" in
pnpm@*) echo "version=${package_manager#pnpm@}" >> "$GITHUB_OUTPUT" ;;
*) echo "::error::The repository packageManager must use the pnpm@<version> format" >&2; exit 1 ;;
esac

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ inputs.pnpm-version }}
version: ${{ steps.package-manager.outputs.version }}

- name: Get pnpm store directory
id: pnpm-cache
Expand All @@ -41,11 +49,10 @@ runs:
uses: actions/cache@v5
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-${{ inputs.working-directory }}-${{ hashFiles(format('{0}/pnpm-lock.yaml', inputs.working-directory)) }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-${{ inputs.working-directory }}-
${{ runner.os }}-pnpm-

- name: Install dependencies
shell: bash
working-directory: ${{ inputs.working-directory }}
run: pnpm install --frozen-lockfile
99 changes: 92 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ on:
- 'apps/api/**'
- 'packages/**'
- 'e2e/**'
- 'database/**'
- 'Dockerfile'
- 'docker-compose.yml'
- 'package.json'
- 'pnpm-lock.yaml'
- 'turbo.json'
- 'playwright.config.ts'
- '.github/workflows/ci.yml'
- '.github/workflows/reusable-ci.yml'
Expand All @@ -25,6 +31,12 @@ on:
- 'apps/api/**'
- 'packages/**'
- 'e2e/**'
- 'database/**'
- 'Dockerfile'
- 'docker-compose.yml'
- 'package.json'
- 'pnpm-lock.yaml'
- 'turbo.json'
- 'playwright.config.ts'
- '.github/workflows/ci.yml'
- '.github/workflows/reusable-ci.yml'
Expand Down Expand Up @@ -52,7 +64,6 @@ jobs:
uses: ./.github/actions/setup-node-pnpm
with:
working-directory: .
node-version: '24'

- name: Check formatting
run: pnpm exec prettier --check .
Expand All @@ -67,6 +78,7 @@ jobs:
project: apps/api
filter: '@repo/api'
test-command: pnpm test
coverage-command: pnpm exec cross-env NODE_OPTIONS='--experimental-vm-modules --localstorage-file=.jest-localstorage' jest --coverage

# ==========================
# Frontend CI
Expand All @@ -79,6 +91,67 @@ jobs:
filter: '@repo/web'
test-command: pnpm test

react-doctor:
name: React Doctor
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm

- name: Run React Doctor
run: pnpm --filter @repo/web doctor

container:
name: Docker image validation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Build API image
run: docker build --build-arg APP_NAME=api -t learnix-api:ci .

- name: Build web image
run: docker build --build-arg APP_NAME=web --build-arg VITE_API_URL=http://localhost:3000 -t learnix-web:ci .

compose-smoke:
name: Compose smoke test
runs-on: ubuntu-latest
needs: [container]
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Start Compose stack and probe endpoints
shell: bash
run: |
set -Eeuo pipefail
cleanup() {
status=$?
if [ "$status" -ne 0 ]; then
docker compose logs --no-color > compose-logs.txt || true
fi
docker compose down -v || true
exit "$status"
}
trap cleanup EXIT
docker compose up -d --build
docker compose ps --wait
curl --fail --retry 10 --retry-delay 3 http://localhost:3000/health
curl --fail --retry 10 --retry-delay 3 http://localhost:5173/

- name: Upload Compose logs
if: failure()
uses: actions/upload-artifact@v6
with:
name: compose-logs
path: compose-logs.txt
if-no-files-found: ignore
retention-days: 7

# ==========================
# E2E Tests (Playwright)
# Runs only on PRs to catch regressions before merge
Expand Down Expand Up @@ -181,16 +254,28 @@ jobs:
ci-status:
name: CI Status
runs-on: ubuntu-latest
needs: [format, backend, frontend, e2e]
needs:
[format, backend, frontend, react-doctor, container, compose-smoke, e2e]
if: always()
steps:
- name: Check CI status
run: |
if [[ "${{ needs.format.result }}" == "failure" ]] || \
[[ "${{ needs.backend.result }}" == "failure" ]] || \
[[ "${{ needs.frontend.result }}" == "failure" ]] || \
[[ "${{ needs.e2e.result }}" == "failure" ]]; then
echo "❌ CI failed"
required_results=(
"${{ needs.format.result }}"
"${{ needs.backend.result }}"
"${{ needs.frontend.result }}"
"${{ needs.react-doctor.result }}"
"${{ needs.container.result }}"
"${{ needs.compose-smoke.result }}"
)
for result in "${required_results[@]}"; do
if [[ "$result" != "success" ]]; then
echo "::error::A required CI job did not succeed: $result"
exit 1
fi
done
if [[ "${{ needs.e2e.result }}" != "success" && "${{ needs.e2e.result }}" != "skipped" ]]; then
echo "::error::E2E must succeed or be intentionally skipped on non-PR events."
exit 1
fi
echo "✅ All CI checks passed"
Loading
Loading