mirror of
https://github.com/dream-num/univer.git
synced 2026-10-02 04:24:34 +08:00
ci: enhance CI configuration (#7146)
This commit is contained in:
@@ -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 }}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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 }}
|
||||
@@ -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') }}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
+1
-1
@@ -15,7 +15,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
+1
-1
@@ -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 .",
|
||||
|
||||
+3
-1
@@ -12,7 +12,9 @@
|
||||
"outputs": ["lib/**"]
|
||||
},
|
||||
|
||||
"build:e2e": {},
|
||||
"build:e2e": {
|
||||
"outputs": ["local/**"]
|
||||
},
|
||||
|
||||
"typecheck": {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user