Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

ci: improve workflow caching

白熱7a31b6198dab
diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml
index cfccf7d194..5f7e2d09ff 100644
--- a/.github/actions/setup-node/action.yml
+++ b/.github/actions/setup-node/action.yml
@@ -1,6 +1,11 @@
name: Node Setup
description: Node.js setup for CI, including cache configuration
+inputs:
+ save-cache:
+ description: Save a new pnpm store cache entry from this job
+ default: 'false'
+
runs:
using: composite
steps:
@@ -13,8 +18,28 @@ runs:
uses: actions/setup-node@v6
with:
node-version: 24.3.0
- cache: pnpm
+
+ - name: Get pnpm store path
+ id: pnpm-store
+ shell: bash
+ run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT"
+
+ - name: Restore pnpm store
+ id: pnpm-cache
+ uses: actions/cache/restore@v6
+ with:
+ path: ${{ steps.pnpm-store.outputs.path }}
+ key: pnpm-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json', 'pnpm-lock.yaml', 'pnpm-workspace.yaml') }}
+ restore-keys: |
+ pnpm-${{ runner.os }}-${{ runner.arch }}-
- name: Install dependencies
- run: pnpm install
+ run: pnpm install --frozen-lockfile
shell: bash
+
+ - name: Save pnpm store
+ if: inputs.save-cache == 'true' && github.ref_name == github.event.repository.default_branch && steps.pnpm-cache.outputs.cache-hit != 'true'
+ uses: actions/cache/save@v6
+ with:
+ path: ${{ steps.pnpm-store.outputs.path }}
+ key: pnpm-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json', 'pnpm-lock.yaml', 'pnpm-workspace.yaml') }}
diff --git a/.github/workflows/build-packages.yml b/.github/workflows/build-packages.yml
index 35aab9feb7..b845de1d87 100644
--- a/.github/workflows/build-packages.yml
+++ b/.github/workflows/build-packages.yml
@@ -27,6 +27,7 @@ jobs:
build:
if: github.repository == 'dream-num/univer' && (github.event_name != 'pull_request' || !github.event.pull_request.draft)
runs-on: ubuntu-latest
+ timeout-minutes: 15
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
@@ -42,6 +43,8 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
+ with:
+ save-cache: 'true'
- name: 📦 Build
run: pnpm build:ci
diff --git a/.github/workflows/ci-quality-checks.yml b/.github/workflows/ci-quality-checks.yml
index b2f3cda3f1..221c02af6f 100644
--- a/.github/workflows/ci-quality-checks.yml
+++ b/.github/workflows/ci-quality-checks.yml
@@ -29,8 +29,8 @@ jobs:
name: test shard (${{ matrix.shard-index }}/${{ matrix.shard-total }})
if: github.repository == 'dream-num/univer' && (github.event_name != 'pull_request' || !github.event.pull_request.draft)
runs-on: ubuntu-latest
+ timeout-minutes: 15
strategy:
- fail-fast: false
matrix:
shard-index: [1, 2, 3, 4]
shard-total: [4]
@@ -60,7 +60,8 @@ jobs:
test:
name: test
if: always() && github.repository == 'dream-num/univer' && (github.event_name != 'pull_request' || !github.event.pull_request.draft)
- runs-on: ubuntu-latest
+ runs-on: minimum-runner
+ timeout-minutes: 5
needs: test-shard
steps:
@@ -76,6 +77,7 @@ jobs:
eslint:
if: github.repository == 'dream-num/univer' && (github.event_name != 'pull_request' || !github.event.pull_request.draft)
runs-on: ubuntu-latest
+ timeout-minutes: 10
steps:
- name: Checkout
@@ -87,7 +89,8 @@ jobs:
uses: ./.github/actions/setup-node
- name: Restore ESLint cache
- uses: actions/cache@v6
+ id: eslint-cache
+ uses: actions/cache/restore@v6
with:
path: .eslintcache
key: eslint-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'package.json', 'eslint.config.ts') }}-${{ github.sha }}
@@ -97,9 +100,17 @@ jobs:
- name: 🌡️ Run ESLint
run: pnpm lint --quiet --cache --cache-location .eslintcache
+ - name: Save ESLint cache
+ if: github.ref_name == github.event.repository.default_branch && steps.eslint-cache.outputs.cache-hit != 'true'
+ uses: actions/cache/save@v6
+ with:
+ path: .eslintcache
+ key: eslint-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'package.json', 'eslint.config.ts') }}-${{ github.sha }}
+
typecheck:
if: github.repository == 'dream-num/univer' && (github.event_name != 'pull_request' || !github.event.pull_request.draft)
runs-on: ubuntu-latest
+ timeout-minutes: 10
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
diff --git a/.github/workflows/dev-performance-log.yml b/.github/workflows/dev-performance-log.yml
index ebc9d91a83..997b828ae4 100644
--- a/.github/workflows/dev-performance-log.yml
+++ b/.github/workflows/dev-performance-log.yml
@@ -16,6 +16,7 @@ jobs:
e2e-test:
if: github.repository == 'dream-num/univer'
runs-on: ubuntu-latest
+ timeout-minutes: 20
env:
GH_TOKEN: ${{ github.token }}
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index aa32968dd9..59bd005c20 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -17,7 +17,6 @@ concurrency:
permissions:
contents: read
pull-requests: write
- actions: write
env:
TURBO_TELEMETRY_DISABLED: '1'
@@ -27,9 +26,9 @@ jobs:
name: e2e-test shard (${{ matrix.shard-index }}/${{ matrix.shard-total }})
if: github.repository == 'dream-num/univer' && (github.event_name != 'pull_request' || !github.event.pull_request.draft)
runs-on: ubuntu-latest
+ timeout-minutes: 15
strategy:
- fail-fast: false
matrix:
shard-index: [1, 2, 3, 4]
shard-total: [4]
@@ -47,7 +46,8 @@ jobs:
uses: ./.github/actions/setup-node
- name: Cache Playwright browsers
- uses: actions/cache@v6
+ id: playwright-cache
+ uses: actions/cache/restore@v6
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
@@ -55,6 +55,13 @@ jobs:
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps chromium
+ - name: Save Playwright browsers
+ if: matrix.shard-index == 1 && steps.playwright-cache.outputs.cache-hit != 'true'
+ uses: actions/cache/save@v6
+ with:
+ path: ~/.cache/ms-playwright
+ key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
+
- name: Build E2E Client
run: pnpm build:e2e
@@ -74,7 +81,7 @@ jobs:
with:
name: playwright-report-${{ matrix.shard-index }}-of-${{ matrix.shard-total }}
path: playwright-report/
- retention-days: 30
+ retention-days: 7
- name: Upload HeapSnapshots
uses: actions/upload-artifact@v7
@@ -86,7 +93,8 @@ jobs:
e2e-test:
name: e2e-test
- runs-on: ubuntu-latest
+ runs-on: minimum-runner
+ timeout-minutes: 5
needs: e2e-shard
if: ${{ always() && github.repository == 'dream-num/univer' && (github.event_name != 'pull_request' || !github.event.pull_request.draft) }}
diff --git a/.github/workflows/release-npm.yml b/.github/workflows/release-npm.yml
index 7678931b26..5452093f25 100644
--- a/.github/workflows/release-npm.yml
+++ b/.github/workflows/release-npm.yml
@@ -19,30 +19,10 @@ env:
TURBO_TELEMETRY_DISABLED: '1'
jobs:
- prepare:
- if: github.repository == 'dream-num/univer'
- runs-on: ubuntu-latest
-
- outputs:
- release_type: ${{ steps.release-type.outputs.value }}
-
- steps:
- - name: 🚚 Get release type
- id: release-type
- env:
- REF_NAME: ${{ github.ref_name }}
- run: |
- if [[ "$REF_NAME" =~ -(alpha|beta|rc)\. ]]; then
- extracted_type="${BASH_REMATCH[1]}"
- echo "value=$extracted_type" >> "$GITHUB_OUTPUT"
- else
- echo "value=stable" >> "$GITHUB_OUTPUT"
- fi
-
release-npm:
- needs: [prepare]
if: github.repository == 'dream-num/univer'
runs-on: ubuntu-latest
+ timeout-minutes: 30
permissions:
contents: read
id-token: write
@@ -67,17 +47,17 @@ jobs:
- name: 🚚 Install dependencies and build
run: |
- pnpm install
+ pnpm install --frozen-lockfile
pnpm build
- name: 🐙 Publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
- RELEASE_TYPE: ${{ needs.prepare.outputs.release_type }}
+ REF_NAME: ${{ github.ref_name }}
run: |
- if [[ "$RELEASE_TYPE" == "stable" ]]; then
- pnpm publish --access public -r --no-git-checks
+ if [[ "$REF_NAME" =~ -(alpha|beta|rc)\. ]]; then
+ pnpm publish --access public --tag "${BASH_REMATCH[1]}" -r --no-git-checks
else
- pnpm publish --access public --tag "$RELEASE_TYPE" -r --no-git-checks
+ pnpm publish --access public -r --no-git-checks
fi
diff --git a/.github/workflows/update-playwright-snapshots.yml b/.github/workflows/update-playwright-snapshots.yml
index 10dea9e92f..7a03234834 100644
--- a/.github/workflows/update-playwright-snapshots.yml
+++ b/.github/workflows/update-playwright-snapshots.yml
@@ -11,6 +11,7 @@ jobs:
update-snapshots:
if: github.repository == 'dream-num/univer'
runs-on: ubuntu-latest
+ timeout-minutes: 30
env:
GH_TOKEN: ${{ github.token }}