feat: 使用corepack管理PNM版本,锁定为[email protected],增加ci脚本支持快速下载依赖 #11933
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Node.js CI | |
on: | |
push: | |
branches: [v4-next] | |
paths-ignore: | |
- 'site/**' | |
- '*.md' | |
pull_request: | |
paths-ignore: | |
- 'site/**' | |
- '*.md' | |
jobs: | |
build: | |
timeout-minutes: 60 | |
strategy: | |
matrix: | |
node-version: [18] | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
services: | |
redis: | |
image: redis | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 6379:6379 | |
rabbitmq: | |
image: rabbitmq:latest | |
ports: | |
- 5672/tcp | |
options: --health-cmd "rabbitmqctl node_health_check" --health-interval 10s --health-timeout 5s --health-retries 5 | |
zookeeper: | |
image: wurstmeister/zookeeper | |
ports: | |
- 2181:2181 | |
env: | |
ALLOW_ANONYMOUS_LOGIN: yes | |
options: >- | |
--health-cmd "echo mntr | nc -w 2 -q 2 localhost 2181" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
kafka: | |
image: wurstmeister/kafka | |
ports: | |
- 9092:9092 | |
options: >- | |
--health-cmd "kafka-broker-api-versions.sh --version" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
env: | |
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092 | |
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092 ## 修改:宿主机IP | |
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181" | |
KAFKA_ADVERTISED_PORT: 9092 | |
# postgres: | |
# image: postgres:alpine | |
# ports: | |
# - 5432:5432 | |
# env: | |
# POSTGRES_DB: db_ci_test | |
# POSTGRES_USER: postgres | |
# POSTGRES_PASSWORD: postgres | |
# # needed because the postgres container does not provide a healthcheck | |
# options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
etcd: | |
image: bitnami/etcd | |
options: >- | |
--name Etcd-server | |
--publish 2379:2379 | |
--publish 2380:2380 | |
--env ALLOW_NONE_AUTHENTICATION=yes | |
--env ETCD_ADVERTISE_CLIENT_URLS=http://etcd-server:2379 | |
steps: | |
- name: Git checkout | |
uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9.6.0 | |
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 | |
- 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: ./scripts/ci | |
- 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 }} | |
ALI_SDK_OSS_ENDPOINT: ${{ secrets.ALI_SDK_OSS_ENDPOINT }} | |
ALI_SDK_OSS_ID: ${{ secrets.ALI_SDK_OSS_ID }} | |
ALI_SDK_OSS_SECRET: ${{ secrets.ALI_SDK_OSS_SECRET }} | |
ALI_SDK_OSS_BUCKET: ${{ secrets.ALI_SDK_OSS_BUCKET }} | |
ALI_SDK_STS_ID: ${{ secrets.ALI_SDK_STS_ID }} | |
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 | |
# | |
# build-windows: | |
# runs-on: windows-latest | |
# | |
# strategy: | |
# matrix: | |
# node-version: [12, 14.x] | |
# | |
# steps: | |
# - uses: actions/checkout@v2 | |
# - name: Use Node.js ${{ matrix.node-version }} | |
# uses: actions/setup-node@v1 | |
# with: | |
# node-version: ${{ matrix.node-version }} | |
# - run: npm install | |
# - run: npm run build --if-present | |
# - run: npm run cov |