The release workflow pushes version bump commits directly to main, but branch protection rules block the default GITHUB_TOKEN from bypassing required status checks and PR requirements. Using a dedicated GitHub App (sanjibdevnathlabs-release-bot) generates installation tokens that are permitted through the ruleset bypass list, and keeps the bot identity on release commits instead of a personal account. The Docker Build workflow previously used a paths filter, causing it to not trigger at all for non-Docker PRs — leaving the required github/docker-build-check status permanently pending. Now the workflow always triggers but checks for Docker-related file changes first, skipping builds when unnecessary while still reporting the status check as passed.
162 lines
4.7 KiB
YAML
162 lines
4.7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main, develop]
|
|
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
check-changes:
|
|
name: Check for app changes
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
should_test: ${{ steps.filter.outputs.should_test }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Check changed files
|
|
id: filter
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "push" ]; then
|
|
echo "should_test=true" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
CHANGED=$(git diff --name-only origin/main...HEAD || true)
|
|
if echo "$CHANGED" | grep -qE '^(src/|frontend/|tests/|package\.json|package-lock\.json|tsconfig\.json|vite\.config|vitest\.config|playwright\.config)'; then
|
|
echo "should_test=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "No application code changed, skipping tests"
|
|
echo "should_test=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
build-and-test:
|
|
name: Build & Test (Node ${{ matrix.node-version }})
|
|
needs: check-changes
|
|
if: needs.check-changes.outputs.should_test == 'true'
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
node-version: [18.x, 20.x, 22.x]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Type check
|
|
run: npm run type-check
|
|
|
|
- name: Build
|
|
run: npm run build
|
|
|
|
- name: Unit & integration tests
|
|
run: npm test
|
|
|
|
- name: Check build artifacts
|
|
run: |
|
|
test -f dist/index.js
|
|
test -f dist/server.js
|
|
test -d dist/frontend
|
|
|
|
- name: Upload build artifacts
|
|
if: matrix.node-version == '20.x'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: build-artifacts
|
|
path: dist/
|
|
retention-days: 7
|
|
|
|
lint-check:
|
|
name: Lint Check
|
|
needs: check-changes
|
|
if: needs.check-changes.outputs.should_test == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20.x'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Check for TypeScript errors
|
|
run: npm run type-check
|
|
|
|
e2e:
|
|
name: E2E Tests
|
|
needs: [check-changes, build-and-test]
|
|
if: needs.check-changes.outputs.should_test == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20.x'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build
|
|
run: npm run build
|
|
|
|
- name: Install Playwright browsers
|
|
run: ./node_modules/.bin/playwright install --with-deps chromium
|
|
|
|
- name: Run E2E tests
|
|
run: npm run test:e2e
|
|
env:
|
|
EXCALIDRAW_DB_PATH: /tmp/excalidraw-e2e-ci.db
|
|
|
|
- name: Upload Playwright report
|
|
if: failure()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: playwright-report
|
|
path: playwright-report/
|
|
retention-days: 7
|
|
|
|
ci-status:
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: false
|
|
name: CI Status Check
|
|
needs: [check-changes, build-and-test, lint-check, e2e]
|
|
if: always()
|
|
permissions:
|
|
statuses: write
|
|
steps:
|
|
- name: Failed
|
|
id: failed
|
|
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
|
|
run: |
|
|
curl -X POST -H "Content-Type: application/json" -H "Authorization: token ${{ github.token }}" \
|
|
-d '{ "state" : "failure" , "context" : "github/ci-status-check" , "description" : "CI checks failed", "target_url" : "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" }' \
|
|
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }}
|
|
exit 1
|
|
- name: Success
|
|
if: steps.failed.conclusion == 'skipped'
|
|
run: |
|
|
curl -X POST -H "Content-Type: application/json" -H "Authorization: token ${{ github.token }}" \
|
|
-d '{ "state" : "success" , "context" : "github/ci-status-check" , "description" : "CI checks passed", "target_url" : "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" }' \
|
|
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }}
|