diff --git a/.github/workflows/build.yml b/.github/workflows/build-packages.yml similarity index 94% rename from .github/workflows/build.yml rename to .github/workflows/build-packages.yml index 822e2a3e92d6..f7429bfb190b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build-packages.yml @@ -29,7 +29,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + uses: actions/checkout@v7 with: repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} ref: ${{ github.event.pull_request.head.sha || github.sha }} diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-quality-checks.yml similarity index 72% rename from .github/workflows/ci-test.yml rename to .github/workflows/ci-quality-checks.yml index e47088f2be2b..303549b6e4d8 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-quality-checks.yml @@ -28,7 +28,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: persist-credentials: false @@ -48,15 +48,23 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: persist-credentials: false - name: Setup Node.js uses: ./.github/actions/setup-node + - name: Restore ESLint cache + uses: actions/cache@v6 + with: + path: .eslintcache + key: eslint-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'package.json', 'eslint.config.ts') }}-${{ github.sha }} + restore-keys: | + eslint-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'package.json', 'eslint.config.ts') }}- + - name: 🌡️ Run ESLint - run: pnpm lint --quiet + run: pnpm lint --quiet --cache --cache-location .eslintcache typecheck: runs-on: ubuntu-latest @@ -66,7 +74,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: persist-credentials: false diff --git a/.github/workflows/setup.yml b/.github/workflows/collect-pr-metadata.yml similarity index 88% rename from .github/workflows/setup.yml rename to .github/workflows/collect-pr-metadata.yml index 47d47942b96a..3d6cfcf58e5a 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/collect-pr-metadata.yml @@ -31,25 +31,25 @@ jobs: printf '%s\n' "$PR_STATE" > ./pr-state.txt - name: Upload PR number - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: pr-id path: ./pr-id.txt - name: Upload PR ref - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: pr-ref path: ./pr-ref.txt - name: Upload PR repo - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: pr-repo path: ./pr-repo.txt - name: Upload PR state - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: pr-state path: ./pr-state.txt diff --git a/.github/workflows/deploy-github-pages.yml b/.github/workflows/deploy-github-pages.yml new file mode 100644 index 000000000000..f1882fa6b56a --- /dev/null +++ b/.github/workflows/deploy-github-pages.yml @@ -0,0 +1,128 @@ +name: 🌐 Deploy to GitHub Pages + +on: + push: + branches: [dev] + tags: + - 'v*.*.*' + - 'v*.*.*-alpha.*' + - 'v*.*.*-beta.*' + - 'v*.*.*-rc.*' + +concurrency: + group: github-pages + cancel-in-progress: false + +permissions: + contents: write + pull-requests: read + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + persist-credentials: false + + - name: Setup Node.js + uses: ./.github/actions/setup-node + + # ================= Deploy Demo ================= + - name: 📦 Build demo + run: pnpm build:demo + + - name: Copy demo to workspace + run: | + mkdir -p dist + cp -r ./examples/local/* dist + + - name: 📦 Build react16 demo + run: | + pnpm use:react16 + pnpm build:demo + + - name: Copy react16 demo + run: | + mkdir -p dist/react16 + cp -r ./examples/local/* dist/react16 + + # ================= Deploy Storybook ================= + - name: 📦 Build storybook + run: pnpm storybook:build + + - name: Copy storybook + run: | + mkdir -p dist/storybook + cp -r ./common/storybook/storybook-static/* dist/storybook + + - name: Checkout existing Pages branch + uses: actions/checkout@v7 + continue-on-error: true + with: + ref: gh-pages + path: gh-pages-current + persist-credentials: false + + - name: Preserve recent PR previews + env: + GH_TOKEN: ${{ github.token }} + run: | + if [ ! -d gh-pages-current/pr-preview ]; then + exit 0 + fi + + mkdir -p dist/pr-preview + cutoff_epoch=$(date -u -d '30 days ago' +%s) + shopt -s nullglob + + for preview_dir in gh-pages-current/pr-preview/pr-*; do + pr_number="${preview_dir##*/pr-}" + if [[ ! "$pr_number" =~ ^[0-9]+$ ]]; then + echo "Prune unexpected preview directory: ${preview_dir}" + continue + fi + + if ! pr_info=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${pr_number}" --jq '[.state, (.closed_at // "")] | @tsv' 2>/dev/null); then + echo "Prune preview for missing PR #${pr_number}" + continue + fi + + IFS=$'\t' read -r state closed_at <<< "$pr_info" + if [ "$state" = "open" ]; then + echo "Keep preview for open PR #${pr_number}" + cp -a "$preview_dir" "dist/pr-preview/" + continue + fi + + if [ -n "$closed_at" ]; then + closed_epoch=$(date -u -d "$closed_at" +%s) + if [ "$closed_epoch" -ge "$cutoff_epoch" ]; then + echo "Keep preview for recently closed PR #${pr_number}" + cp -a "$preview_dir" "dist/pr-preview/" + continue + fi + fi + + echo "Prune preview for PR #${pr_number}" + done + + - name: Check Pages publish size + run: | + size_kb=$(du -sk dist | awk '{print $1}') + max_kb=950000 + echo "Pages publish directory size: ${size_kb} KB" + if [ "$size_kb" -gt "$max_kb" ]; then + echo "Pages publish directory exceeds ${max_kb} KB. Largest entries:" + du -h -d 2 dist | sort -hr | head -50 + exit 1 + fi + + # ================= Deploy to GitHub Pages ================= + - name: 🚀 Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dist diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/deploy-pr-preview.yml similarity index 93% rename from .github/workflows/preview-deploy.yml rename to .github/workflows/deploy-pr-preview.yml index 011c82d61340..c754131a8eb7 100644 --- a/.github/workflows/preview-deploy.yml +++ b/.github/workflows/deploy-pr-preview.yml @@ -33,7 +33,7 @@ jobs: steps: # Get PR id from artifact - name: download pr artifact - uses: dawidd6/action-download-artifact@v9 + uses: dawidd6/action-download-artifact@v21 with: workflow: ${{ github.event.workflow_run.workflow_id }} run_id: ${{ github.event.workflow_run.id }} @@ -45,7 +45,7 @@ jobs: # Get PR ref from artifact - name: download pr artifact - uses: dawidd6/action-download-artifact@v9 + uses: dawidd6/action-download-artifact@v21 with: workflow: ${{ github.event.workflow_run.workflow_id }} run_id: ${{ github.event.workflow_run.id }} @@ -57,7 +57,7 @@ jobs: # Get PR repo from artifact - name: download pr artifact - uses: dawidd6/action-download-artifact@v9 + uses: dawidd6/action-download-artifact@v21 with: workflow: ${{ github.event.workflow_run.workflow_id }} run_id: ${{ github.event.workflow_run.id }} @@ -69,7 +69,7 @@ jobs: # Get PR state from artifact - name: download pr state artifact - uses: dawidd6/action-download-artifact@v9 + uses: dawidd6/action-download-artifact@v21 with: workflow: ${{ github.event.workflow_run.workflow_id }} run_id: ${{ github.event.workflow_run.id }} @@ -87,7 +87,7 @@ jobs: steps: # ================= Create Comment ================= - name: 🧽 Find And Delete Comment - uses: peter-evans/find-comment@v2 + uses: peter-evans/find-comment@v4 if: ${{ needs.setup.outputs.id != '' }} id: fc with: @@ -96,7 +96,7 @@ jobs: body-includes: View Deployment - name: 📝 Create or update comment - uses: peter-evans/create-or-update-comment@v3 + uses: peter-evans/create-or-update-comment@v5 if: ${{ needs.setup.outputs.id != '' }} with: comment-id: ${{ steps.fc.outputs.comment-id }} @@ -120,19 +120,19 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: repository: ${{ needs.setup.outputs.repo }} ref: ${{ needs.setup.outputs.ref }} persist-credentials: false - name: Setup pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@v6 with: run_install: false - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: 24.3.0 cache: pnpm @@ -198,7 +198,7 @@ jobs: steps: # ================= Create Comment ================= - name: 🧽 Find And Delete Comment - uses: peter-evans/find-comment@v2 + uses: peter-evans/find-comment@v4 if: ${{ needs.setup.outputs.id != '' }} id: fc with: @@ -207,7 +207,7 @@ jobs: body-includes: View Deployment - name: 📝 Create or update comment - uses: peter-evans/create-or-update-comment@v3 + uses: peter-evans/create-or-update-comment@v5 if: ${{ needs.setup.outputs.id != '' }} with: comment-id: ${{ steps.fc.outputs.comment-id }} diff --git a/.github/workflows/dev-performance-log.yml b/.github/workflows/dev-performance-log.yml index 782fe535fe14..ebc9d91a83ba 100644 --- a/.github/workflows/dev-performance-log.yml +++ b/.github/workflows/dev-performance-log.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: persist-credentials: false @@ -38,7 +38,7 @@ jobs: uses: ./.github/actions/setup-node - name: Cache Playwright browsers - uses: actions/cache@v4 + uses: actions/cache@v6 with: path: ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }} diff --git a/.github/workflows/sync-pro.yml b/.github/workflows/dispatch-sync-univer-pro.yml similarity index 100% rename from .github/workflows/sync-pro.yml rename to .github/workflows/dispatch-sync-univer-pro.yml diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 4b4a7aa5b5a9..f19925c131c1 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -18,15 +18,22 @@ env: TURBO_TELEMETRY_DISABLED: '1' jobs: - e2e-test: + e2e-shard: + name: e2e-test shard (${{ matrix.shard-index }}/${{ matrix.shard-total }}) runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + shard-index: [1, 2, 3, 4] + shard-total: [4] + env: GH_TOKEN: ${{ github.token }} steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: persist-credentials: false @@ -34,7 +41,7 @@ jobs: uses: ./.github/actions/setup-node - name: Cache Playwright browsers - uses: actions/cache@v4 + uses: actions/cache@v6 with: path: ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }} @@ -46,27 +53,43 @@ jobs: run: pnpm build:e2e - name: Run Playwright Tests - run: pnpm exec playwright test + run: pnpm exec playwright test --shard=${{ matrix.shard-index }}/${{ matrix.shard-total }} - name: Write Playwright Report to PR Comment - uses: daun/playwright-report-summary@v3 + uses: daun/playwright-report-summary@v4 if: always() with: report-file: playwright-report.json custom-info: 'For more information, [see full report and artifacts](https://github.com/dream-num/univer/actions/runs/${{ github.run_id }})' - name: Upload Artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 if: ${{ !cancelled() }} with: - name: playwright-report + name: playwright-report-${{ matrix.shard-index }}-of-${{ matrix.shard-total }} path: playwright-report/ retention-days: 30 - name: Upload HeapSnapshots - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 if: ${{ failure() }} with: - name: snapshots + name: snapshots-${{ matrix.shard-index }}-of-${{ matrix.shard-total }} path: test-results/*.heapsnapshot retention-days: 3 + + e2e-test: + name: e2e-test + runs-on: ubuntu-latest + needs: e2e-shard + if: ${{ always() }} + + steps: + - name: Check shard results + run: | + if [ "${{ needs.e2e-shard.result }}" != "success" ]; then + echo "One or more e2e shards failed: ${{ needs.e2e-shard.result }}" + exit 1 + fi + + echo "All e2e shards passed" diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml deleted file mode 100644 index c7e78660226b..000000000000 --- a/.github/workflows/pages.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: 🌐 Deploy to GitHub Pages - -on: - push: - branches: [dev] - tags: - - 'v*.*.*' - - 'v*.*.*-alpha.*' - - 'v*.*.*-beta.*' - - 'v*.*.*-rc.*' - -concurrency: - group: github-pages - cancel-in-progress: false - -permissions: - contents: write - -jobs: - deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Setup Node.js - uses: ./.github/actions/setup-node - - # ================= Deploy Demo ================= - - name: 📦 Build demo - run: pnpm build:demo - - - name: Copy demo to workspace - run: | - mkdir -p dist - cp -r ./examples/local/* dist - - - name: 📦 Build react16 demo - run: | - pnpm use:react16 - pnpm build:demo - - - name: Copy react16 demo - run: | - mkdir -p dist/react16 - cp -r ./examples/local/* dist/react16 - - # ================= Deploy Storybook ================= - - name: 📦 Build storybook - run: pnpm storybook:build - - - name: Copy storybook - run: | - mkdir -p dist/storybook - cp -r ./common/storybook/storybook-static/* dist/storybook - - # ================= Deploy to GitHub Pages ================= - - name: 🚀 Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./dist - keep_files: true diff --git a/.github/workflows/release.yml b/.github/workflows/release-npm.yml similarity index 93% rename from .github/workflows/release.yml rename to .github/workflows/release-npm.yml index 5532356fa152..7733b3c9eaff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release-npm.yml @@ -27,7 +27,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: persist-credentials: false @@ -56,18 +56,18 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: ref: ${{ github.ref_name }} persist-credentials: false - name: Install pnpm - uses: pnpm/action-setup@v4 + uses: pnpm/action-setup@v6 with: run_install: false - name: Install Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: 24.3.0 registry-url: https://registry.npmjs.org diff --git a/.github/workflows/semgrep.yml b/.github/workflows/security-semgrep.yml similarity index 98% rename from .github/workflows/semgrep.yml rename to .github/workflows/security-semgrep.yml index 5258e8d9d3b7..32c07bc286e3 100644 --- a/.github/workflows/semgrep.yml +++ b/.github/workflows/security-semgrep.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: persist-credentials: false @@ -103,7 +103,7 @@ jobs: - name: Upload Semgrep report artifact if: ${{ always() }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: semgrep-sarif-${{ github.run_id }} path: reports/semgrep.sarif diff --git a/.github/workflows/sync-mirror.yml b/.github/workflows/sync-gitee-mirror.yml similarity index 100% rename from .github/workflows/sync-mirror.yml rename to .github/workflows/sync-gitee-mirror.yml diff --git a/.github/workflows/update-snapshots-manually.yml b/.github/workflows/update-playwright-snapshots.yml similarity index 96% rename from .github/workflows/update-snapshots-manually.yml rename to .github/workflows/update-playwright-snapshots.yml index 965e5b60cc8e..929e76cdcf59 100644 --- a/.github/workflows/update-snapshots-manually.yml +++ b/.github/workflows/update-playwright-snapshots.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: persist-credentials: false diff --git a/.github/workflows/check-pr.yml b/.github/workflows/validate-pr-title.yml similarity index 100% rename from .github/workflows/check-pr.yml rename to .github/workflows/validate-pr-title.yml diff --git a/package.json b/package.json index 3c53a20030a3..bbcaa0538643 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "build:plugins": "turbo build --filter '!./common/*' --filter '!./presets/**'", "build:presets": "turbo build --filter './presets/**...' --filter '!./presets/**' && turbo build --filter './presets/**'", "build:demo": "pnpm --filter univer-examples build:demo", - "build:e2e": "pnpm --filter univer-examples build:e2e", + "build:e2e": "turbo build:e2e --filter univer-examples", "serve:e2e": "serve ./examples/local", "test:e2e": "playwright test", "lint": "eslint .", diff --git a/turbo.json b/turbo.json index 5b9087dc7b92..b27f031b2a97 100644 --- a/turbo.json +++ b/turbo.json @@ -12,7 +12,9 @@ "outputs": ["lib/**"] }, - "build:e2e": {}, + "build:e2e": { + "outputs": ["local/**"] + }, "typecheck": {} }