TidGi-Desktop/.github/workflows/test.yml
lin onetwo 81e5e2e671 Optimize test artifact handling and Git log logging
Update CI workflow to clean up large cache folders in test artifacts and only upload logs, settings, and screenshots to reduce artifact size. Refactor useGitLogData to log immediately after state updates for improved E2E test reliability, removing unnecessary setTimeout.
2026-01-18 17:24:46 +08:00

76 lines
2.8 KiB
YAML

name: Test
on:
workflow_call:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Install Node.js
uses: actions/setup-node@v5
with:
node-version: lts/*
# Install C++ build tools for native modules (nsfw, better-sqlite3)
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential
- name: Install dependencies
run: pnpm install
- name: Rebuild native modules for Electron
run: pnpm exec electron-rebuild -f -w better-sqlite3,nsfw
- name: Run linting
run: pnpm run lint --max-warnings 0
# Install minimal Linux dependencies for Electron GUI testing https://www.electronjs.org/docs/latest/tutorial/testing-on-headless-ci
- name: Install Linux GUI dependencies
run: |
sudo apt-get update
sudo apt-get install -y xvfb
# Install Chinese fonts and locale support for i18n testing
sudo apt-get install -y fonts-noto-cjk fonts-wqy-zenhei language-pack-zh-hans
sudo locale-gen zh_CN.UTF-8
- name: Run tests
# E2E GUI tests with Electron on Linux require a virtual framebuffer, upgrade screen size from time to time.
run: xvfb-run --auto-servernum --server-args="-screen 0 2560x1440x24" pnpm run test
env:
CI: true
DISPLAY: :99
# Set Chinese locale for i18n testing
LANG: zh_CN.UTF-8
LC_ALL: zh_CN.UTF-8
timeout-minutes: 15
# Upload test artifacts (screenshots, logs)
- name: Upload test artifacts
if: always()
run: |
mv test-artifacts test-artifacts-ci || true
# Remove large cache folders to save space, keep only logs and settings
find test-artifacts-ci -type d -name "Cache" -o -name "Code Cache" -o -name "GPUCache" -o -name "DawnGraphiteCache" -o -name "DawnWebGPUCache" -o -name "Crashpad" -o -name "cache-database" -o -name "DevToolsActivePort" -o -name "Dictionaries" -o -name "Local Storage" -o -name "Network Persistent State" -o -name "Partitions" -o -name "Session Storage" -o -name "Shared Dictionary" | xargs rm -rf || true
echo "Cleaned up test-artifacts-ci cache folders"
continue-on-error: true
- uses: actions/upload-artifact@v4
if: always()
with:
name: test-artifacts-ci
path: |
test-artifacts-ci/**/logs/
test-artifacts-ci/**/settings/
test-artifacts-ci/**/screenshots/
retention-days: 7
continue-on-error: true