mirror of
https://github.com/infinilabs/coco-app.git
synced 2025-12-16 03:27:43 +01:00
* build: add web build ci * chore: remove test code * Update .github/workflows/frontend-ci.yml Co-authored-by: SteveLauC <stevelauc@outlook.com> --------- Co-authored-by: SteveLauC <stevelauc@outlook.com>
66 lines
2.1 KiB
YAML
66 lines
2.1 KiB
YAML
name: Frontend Code Check
|
|
|
|
on:
|
|
pull_request:
|
|
# Only run it when Frontend code changes
|
|
paths:
|
|
- 'src/**'
|
|
- 'tsup.config.ts'
|
|
- 'package.json'
|
|
|
|
jobs:
|
|
check:
|
|
strategy:
|
|
matrix:
|
|
platform: [ubuntu-latest, windows-latest, macos-latest]
|
|
|
|
runs-on: ${{ matrix.platform }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
# No need to pass the version arg as it is specified by "packageManager" in package.json
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Switch platformAdapter to Web adapter
|
|
shell: bash
|
|
run: >
|
|
node -e "const fs=require('fs');const f='src/utils/platformAdapter.ts';
|
|
let s=fs.readFileSync(f,'utf8');
|
|
s=s.replace(/import\\s*\\{\\s*createTauriAdapter\\s*\\}\\s*from\\s*\\\"\\.\\/tauriAdapter\\\";/,'import { createWebAdapter } from \\\"./webAdapter\\\";');
|
|
s=s.replace(/let\\s+platformAdapter\\s*=\\s*createTauriAdapter\\(\\);/,'let platformAdapter = createWebAdapter();');
|
|
fs.writeFileSync(f,s);"
|
|
|
|
- name: Build web (Tauri dependency check)
|
|
run: pnpm build:web
|
|
|
|
- name: Verify no Tauri refs in web output
|
|
run: |
|
|
if grep -R -n -E '@tauri-apps|tauri-plugin' out/search-chat; then
|
|
echo 'Tauri references found in web build output';
|
|
exit 1;
|
|
else
|
|
echo 'No Tauri references found';
|
|
fi
|
|
|
|
- name: Restore platformAdapter to Tauri adapter
|
|
run: >
|
|
node -e "const fs=require('fs');const f='src/utils/platformAdapter.ts';
|
|
let s=fs.readFileSync(f,'utf8');
|
|
s=s.replace(/import\\s*\\{\\s*createWebAdapter\\s*\\}\\s*from\\s*\\\"\\.\\/webAdapter\\\";/,'import { createTauriAdapter } from \\\"./tauriAdapter\\\";');
|
|
s=s.replace(/let\\s+platformAdapter\\s*=\\s*createWebAdapter\\(\\);/,'let platformAdapter = createTauriAdapter();');
|
|
fs.writeFileSync(f,s);"
|
|
|
|
- name: Build frontend
|
|
run: pnpm build
|