|
| 1 | +name: PR Validation - Test and Build |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - main |
| 8 | + paths-ignore: |
| 9 | + - '*.md' |
| 10 | + - '.vscode/**' |
| 11 | + - '.idea/**' |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: pr-validation-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + validate: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + env: |
| 22 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v6 |
| 26 | + |
| 27 | + - name: Install Node.js |
| 28 | + uses: actions/setup-node@v6 |
| 29 | + with: |
| 30 | + node-version: lts/* |
| 31 | + |
| 32 | + - name: Setup pnpm |
| 33 | + uses: pnpm/action-setup@v6 |
| 34 | + with: |
| 35 | + version: 'latest' |
| 36 | + run_install: false |
| 37 | + |
| 38 | + - name: Get pnpm store directory |
| 39 | + id: pnpm-cache |
| 40 | + shell: bash |
| 41 | + run: | |
| 42 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT |
| 43 | +
|
| 44 | + - name: Cache dependencies |
| 45 | + uses: actions/cache@v5 |
| 46 | + with: |
| 47 | + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} |
| 48 | + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 49 | + restore-keys: | |
| 50 | + ${{ runner.os }}-pnpm- |
| 51 | +
|
| 52 | + - name: Install Dependencies |
| 53 | + run: pnpm install |
| 54 | + |
| 55 | + - name: Install Playwright Browser |
| 56 | + if: ${{ hashFiles('wiki/tiddlers/tests/playwright/**/*.ts') != '' }} |
| 57 | + run: pnpm exec playwright install --with-deps chromium |
| 58 | + |
| 59 | + - name: Lint Code |
| 60 | + run: pnpm exec eslint ./src --max-warnings 0 |
| 61 | + continue-on-error: true |
| 62 | + |
| 63 | + - name: Run Tests |
| 64 | + run: pnpm run test |
| 65 | + |
| 66 | + - name: Run Playwright E2E Tests |
| 67 | + if: ${{ hashFiles('wiki/tiddlers/tests/playwright/**/*.ts') != '' }} |
| 68 | + run: pnpm run test:playwright |
| 69 | + |
| 70 | + - name: Build Plugins |
| 71 | + run: pnpm run build |
| 72 | + |
| 73 | + - name: Build Static Website |
| 74 | + run: pnpm run publish |
| 75 | + |
| 76 | + - name: Upload Build Artifacts |
| 77 | + if: always() |
| 78 | + uses: actions/upload-artifact@v7 |
| 79 | + with: |
| 80 | + name: build-artifacts |
| 81 | + path: dist/ |
| 82 | + retention-days: 5 |
| 83 | + |
| 84 | + - name: Comment PR with Results |
| 85 | + if: failure() && github.event_name == 'pull_request' |
| 86 | + uses: actions/github-script@v9 |
| 87 | + with: |
| 88 | + script: | |
| 89 | + github.rest.issues.createComment({ |
| 90 | + issue_number: context.issue.number, |
| 91 | + owner: context.repo.owner, |
| 92 | + repo: context.repo.repo, |
| 93 | + body: '❌ PR validation failed. Please check the workflow logs for details.' |
| 94 | + }) |
| 95 | +
|
| 96 | + - name: Comment PR with Success |
| 97 | + if: success() && github.event_name == 'pull_request' |
| 98 | + uses: actions/github-script@v9 |
| 99 | + with: |
| 100 | + script: | |
| 101 | + github.rest.issues.createComment({ |
| 102 | + issue_number: context.issue.number, |
| 103 | + owner: context.repo.owner, |
| 104 | + repo: context.repo.repo, |
| 105 | + body: '✅ PR validation passed successfully!' |
| 106 | + }) |
0 commit comments