Skip to content

Commit

Permalink
docs: fix pnpm cache
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 committed Dec 24, 2024
1 parent 6ae58c5 commit 66274bb
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 18 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/beta_site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,39 @@ on:
jobs:
build:
name: Build Docusaurus
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'pnpm'

# 添加 pnpm 安装
- name: Install pnpm
run: npm install -g pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

# 安装根目录依赖
- name: Install root dependencies
run: pnpm install

# 构建根目录项目
- name: Build root project
run: pnpm run build --if-present

# site 目录使用 npm,需要单独配置 npm 缓存
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: site/package-lock.json

Expand Down
39 changes: 31 additions & 8 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: Node.js CI

on:
push:
branches: [main]
branches: [v4-next]
paths-ignore:
- .github/workflows/site.yml
- '.github/workflows/site.yml'
- 'site/**'
- '*.md'
pull_request:
paths-ignore:
- .github/workflows/site.yml
- '.github/workflows/site.yml'
- 'site/**'
- '*.md'

Expand All @@ -18,7 +18,7 @@ jobs:
timeout-minutes: 60
strategy:
matrix:
node-version: [16, 18, 'lts/*']
node-version: [18]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
services:
Expand Down Expand Up @@ -86,20 +86,42 @@ jobs:
- name: Git checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: 4.2

- run: npm run install_npm
- run: npm install && npm install codecov
- run: npm run build --if-present
- run: npm run cov
- name: Start Mosquitto
uses: namoshek/mosquitto-github-action@v1
with:
version: 'latest'
ports: '1883:1883 8883:8883'
config: ${{ github.workspace }}/packages/mqtt/scripts/mosquitto.conf
container-name: 'mqtt'

- name: Install dependencies
run: pnpm install

- name: Install codecov
run: pnpm add -g codecov

- name: Build
run: pnpm run build --if-present

- name: Run tests and coverage
run: pnpm run cov
env:
RABBITMQ_URL: amqp://localhost:${{ job.services.rabbitmq.ports[5672] }}
ALI_SDK_OSS_REGION: ${{ secrets.ALI_SDK_OSS_REGION }}
Expand All @@ -111,6 +133,7 @@ jobs:
ALI_SDK_STS_SECRET: ${{ secrets.ALI_SDK_STS_SECRET }}
ALI_SDK_STS_BUCKET: ${{ secrets.ALI_SDK_STS_BUCKET }}
ALI_SDK_STS_ROLE: ${{ secrets.ALI_SDK_STS_ROLE }}

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4

Expand Down

0 comments on commit 66274bb

Please sign in to comment.