ci: add pull request validation workflow

This commit is contained in:
xiwangly2
2026-09-26 15:32:26 +08:00
parent dba015eed4
commit 3d36b994c5
7 changed files with 193 additions and 49 deletions

View File

@@ -80,12 +80,16 @@ jobs:
with:
node-version: '22.16.0'
cache: 'npm'
cache-dependency-path: |
package-lock.json
client/package-lock.json
server/package-lock.json
- name: Install dependencies
run: |
npm install
cd client && npm install
cd ../server && npm install
npm ci
npm ci --prefix client
npm ci --prefix server
- name: Build Linux ${{ matrix.arch }} package
run: ${{ matrix.package_command }}
env:
@@ -111,15 +115,15 @@ jobs:
with:
node-version: '22.16.0'
cache: 'npm'
cache-dependency-path: |
package-lock.json
client/package-lock.json
server/package-lock.json
- name: Install dependencies
run: |
npm install
cd client
npm install
cd ..
cd server
npm install
cd ..
npm ci
npm ci --prefix client
npm ci --prefix server
- name: Build package
run: npm run package:windows
env:

106
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,106 @@
name: CI
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
- ready_for_review
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CI: true
NODE_VERSION: '22.16.0'
jobs:
server:
name: Server test and build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: server/package-lock.json
- name: Install server dependencies
run: npm ci
working-directory: server
- name: Run server tests
run: npm test
working-directory: server
- name: Build server
run: npm run build
working-directory: server
client:
name: Client test and build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: client/package-lock.json
- name: Install client dependencies
run: npm ci
working-directory: client
- name: Run client tests
run: npm test
working-directory: client
- name: Build client
run: npm run build
working-directory: client
project-scripts:
name: Project scripts
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: package-lock.json
- name: Install root dependencies
run: npm ci
- name: Check packaging scripts syntax
run: |
node --check scripts/package.js
node --check scripts/resolve-build-version.js
- name: Resolve build version
run: node scripts/resolve-build-version.js