diff --git a/.github/actions/setup-project/action.yml b/.github/actions/setup-project/action.yml new file mode 100644 index 00000000..a58020ec --- /dev/null +++ b/.github/actions/setup-project/action.yml @@ -0,0 +1,66 @@ +name: "Setup Project" +description: "Common setup steps for CI workflows - checkout, Node.js, dependencies, and native modules" + +inputs: + node-version: + description: "Node.js version to use" + required: false + default: "22" + check-lockfile: + description: "Run lockfile lint check for SSH URLs" + required: false + default: "false" + rebuild-node-pty-path: + description: "Working directory for node-pty rebuild (empty = root)" + required: false + default: "" + +runs: + using: "composite" + steps: + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + cache: "npm" + cache-dependency-path: package-lock.json + + - name: Check for SSH URLs in lockfile + if: inputs.check-lockfile == 'true' + shell: bash + run: npm run lint:lockfile + + - name: Configure Git for HTTPS + shell: bash + # Convert SSH URLs to HTTPS for git dependencies (e.g., @electron/node-gyp) + # This is needed because SSH authentication isn't available in CI + run: git config --global url."https://github.com/".insteadOf "git@github.com:" + + - name: Install dependencies + shell: bash + # Use npm install instead of npm ci to correctly resolve platform-specific + # optional dependencies (e.g., @tailwindcss/oxide, lightningcss binaries) + # Skip scripts to avoid electron-builder install-app-deps which uses too much memory + run: npm install --ignore-scripts + + - name: Install Linux native bindings + shell: bash + # Workaround for npm optional dependencies bug (npm/cli#4828) + # Explicitly install Linux bindings needed for build tools + run: | + npm install --no-save --force --ignore-scripts \ + @rollup/rollup-linux-x64-gnu@4.53.3 \ + @tailwindcss/oxide-linux-x64-gnu@4.1.17 + + - name: Rebuild native modules (root) + if: inputs.rebuild-node-pty-path == '' + shell: bash + # Rebuild node-pty and other native modules for Electron + run: npm rebuild node-pty + + - name: Rebuild native modules (workspace) + if: inputs.rebuild-node-pty-path != '' + shell: bash + # Rebuild node-pty and other native modules needed for server + run: npm rebuild node-pty + working-directory: ${{ inputs.rebuild-node-pty-path }} diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index f90cc174..9f8e49a8 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -18,37 +18,11 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v4 + - name: Setup project + uses: ./.github/actions/setup-project with: - node-version: "22" - cache: "npm" - cache-dependency-path: package-lock.json - - - name: Configure Git for HTTPS - # Convert SSH URLs to HTTPS for git dependencies (e.g., @electron/node-gyp) - # This is needed because SSH authentication isn't available in CI - run: git config --global url."https://github.com/".insteadOf "git@github.com:" - - - name: Install dependencies - # Use npm install instead of npm ci to correctly resolve platform-specific - # optional dependencies (e.g., @tailwindcss/oxide, lightningcss binaries) - # Skip scripts to avoid electron-builder install-app-deps which uses too much memory - run: npm install --ignore-scripts - - - name: Install Linux native bindings - # Workaround for npm optional dependencies bug (npm/cli#4828) - # Explicitly install Linux bindings needed for build tools - run: | - npm install --no-save --force --ignore-scripts \ - @rollup/rollup-linux-x64-gnu@4.53.3 \ - @tailwindcss/oxide-linux-x64-gnu@4.1.17 - - - name: Rebuild native modules - # Rebuild node-pty and other native modules needed for server - # This is separate from electron-builder install-app-deps to avoid OOM - run: npm rebuild node-pty - working-directory: apps/server + check-lockfile: "true" + rebuild-node-pty-path: "apps/server" - name: Install Playwright browsers run: npx playwright install --with-deps chromium diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 882dbddb..38e0c978 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -17,39 +17,10 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v4 + - name: Setup project + uses: ./.github/actions/setup-project with: - node-version: "22" - cache: "npm" - cache-dependency-path: package-lock.json - - - name: Check for SSH URLs in lockfile - run: npm run lint:lockfile - - - name: Configure Git for HTTPS - # Convert SSH URLs to HTTPS for git dependencies (e.g., @electron/node-gyp) - # This is needed because SSH authentication isn't available in CI - run: git config --global url."https://github.com/".insteadOf "git@github.com:" - - - name: Install dependencies - # Use npm install instead of npm ci to correctly resolve platform-specific - # optional dependencies (e.g., @tailwindcss/oxide, lightningcss binaries) - # Skip scripts to avoid electron-builder install-app-deps which uses too much memory - run: npm install --ignore-scripts - - - name: Install Linux native bindings - # Workaround for npm optional dependencies bug (npm/cli#4828) - # Explicitly install Linux bindings needed for build tools - run: | - npm install --no-save --force --ignore-scripts \ - @rollup/rollup-linux-x64-gnu@4.53.3 \ - @tailwindcss/oxide-linux-x64-gnu@4.1.17 - - - name: Rebuild native modules for Electron - # Rebuild node-pty and other native modules for Electron after npm install --ignore-scripts - # Avoids using electron-builder install-app-deps to prevent OOM issues - run: npm rebuild node-pty + check-lockfile: "true" - name: Run build:electron (dir only - faster CI) run: npm run build:electron:dir diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 13194d23..1d15b425 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,37 +17,11 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v4 + - name: Setup project + uses: ./.github/actions/setup-project with: - node-version: "22" - cache: "npm" - cache-dependency-path: package-lock.json - - - name: Configure Git for HTTPS - # Convert SSH URLs to HTTPS for git dependencies (e.g., @electron/node-gyp) - # This is needed because SSH authentication isn't available in CI - run: git config --global url."https://github.com/".insteadOf "git@github.com:" - - - name: Install dependencies - # Use npm install instead of npm ci to correctly resolve platform-specific - # optional dependencies (e.g., @tailwindcss/oxide, lightningcss binaries) - # Skip scripts to avoid electron-builder install-app-deps which uses too much memory - run: npm install --ignore-scripts - - - name: Install Linux native bindings - # Workaround for npm optional dependencies bug (npm/cli#4828) - # Explicitly install Linux bindings needed for build tools - run: | - npm install --no-save --force --ignore-scripts \ - @rollup/rollup-linux-x64-gnu@4.53.3 \ - @tailwindcss/oxide-linux-x64-gnu@4.1.17 - - - name: Rebuild native modules - # Rebuild node-pty and other native modules needed for server - # This is separate from electron-builder install-app-deps to avoid OOM - run: npm rebuild node-pty - working-directory: apps/server + check-lockfile: "true" + rebuild-node-pty-path: "apps/server" - name: Run server tests with coverage run: npm run test:server:coverage