feat: 更新 npm 运行脚本路径,以支持跨目录调用 #45
This file contains hidden or 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: npm run electron | |
| on: | |
| push: | |
| branches: | |
| - run* | |
| - test* | |
| - release* | |
| paths-ignore: | |
| - "_script/**" | |
| - "doc/**" | |
| - "**/*.md" | |
| - "**/.gitignore" | |
| - "**/LICENSE" | |
| jobs: | |
| npm-run-electron: | |
| runs-on: ${{ matrix.os }}-latest | |
| env: | |
| ELECTRON_CACHE: ${{ github.workspace }}/.cache/electron | |
| ELECTRON_BUILDER_CACHE: ${{ github.workspace }}/.cache/electron-builder | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - windows | |
| - ubuntu | |
| - macos | |
| node: | |
| - 22 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4.1.7 | |
| with: | |
| submodules: true | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: 'Setup Node.js "${{ matrix.node }}.x" environment' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| registry-url: https://npm.pkg.github.com/ | |
| cache: pnpm | |
| - name: Setup Python environment (Mac) Because of electron-builder install-app-deps requires Python setup tools | |
| if: matrix.os == 'macos' | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Print | |
| run: | | |
| echo "github.ref_type = ${{ github.ref_type }}"; | |
| echo "github.ref = ${{ github.ref }}"; | |
| echo "github.ref_name = ${{ github.ref_name }}"; | |
| - name: "npm -v | pnpm -v | python --version" | |
| run: | | |
| echo "======================================================================"; | |
| echo "npm -v"; | |
| echo "--------------------"; | |
| npm -v; | |
| echo "======================================================================"; | |
| echo "pnpm -v"; | |
| echo "--------------------"; | |
| pnpm -v; | |
| echo "======================================================================"; | |
| echo "python --version"; | |
| echo "--------------------"; | |
| python --version; | |
| - name: Setup electron cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ github.workspace }}/.cache/electron | |
| key: ${{ runner.os }}-electron-cache-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-electron-cache- | |
| - name: Setup electron-builder cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ github.workspace }}/.cache/electron-builder | |
| key: ${{ runner.os }}-electron-builder-cache-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-electron-builder-cache- | |
| - name: pnpm install | |
| run: | | |
| echo "======================================================================"; | |
| dir || ls -lah; | |
| echo "======================================================================"; | |
| echo "pnpm install"; | |
| echo "--------------------"; | |
| pnpm install; | |
| - name: npm run electron (auto-exit after 30min) | |
| run: | | |
| echo "======================================================================"; | |
| echo "cd packages/gui"; | |
| echo "--------------------"; | |
| cd packages/gui; | |
| dir || ls -lah; | |
| echo "======================================================================"; | |
| echo "npm run electron with timeout"; | |
| echo "--------------------"; | |
| if [ "$RUNNER_OS" = "Windows" ]; then | |
| powershell ../../scripts/run-electron-with-timeout.ps1 | |
| else | |
| bash ../../scripts/run-electron-with-timeout.sh | |
| fi |