permissions: contents: 'read' packages: 'read' on: workflow_call: inputs: version: description: 'The version of the published package' required: true type: 'string' cli-package-name: description: 'The name of the CLI package to install' required: true type: 'string' secrets: GEMINI_API_KEY: required: true jobs: e2e_linux: name: 'E2E Test (Linux) - ${{ matrix.sandbox }}' if: | (github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || (github.event.pull_request.head.repo.full_name == github.repository) || (github.event.label.name == 'maintainer:e2e:ok')) runs-on: 'gemini-cli-ubuntu-16-core' strategy: fail-fast: false matrix: sandbox: - 'sandbox:none' - 'sandbox:docker' node-version: - '20.x' steps: - name: 'Checkout (fork)' uses: 'actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955' # ratchet:actions/checkout@v5 if: "github.event_name == 'pull_request_target'" with: ref: '${{ github.event.pull_request.head.sha }}' repository: '${{ github.event.pull_request.head.repo.full_name }}' - name: 'Checkout (internal)' uses: 'actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955' # ratchet:actions/checkout@v5 if: "github.event_name != 'pull_request_target'" with: ref: '${{ github.event.inputs.branch_ref || github.ref }}' - name: 'Setup NPMRC' uses: './.github/actions/setup-npmrc' with: github-token: '${{ secrets.GITHUB_TOKEN }}' - name: 'Install dependencies' run: 'npm install ${{ inputs.cli-package-name }}@${{ inputs.version }}' - name: 'Set up Docker' if: "matrix.sandbox == 'sandbox:docker'" uses: 'docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435' # ratchet:docker/setup-buildx-action@v3 - name: 'Run E2E tests' env: GEMINI_API_KEY: '${{ secrets.GEMINI_API_KEY }}' KEEP_OUTPUT: 'true' VERBOSE: 'true' INTEGRATION_TEST_USE_INSTALLED_GEMINI: 'true' shell: 'bash' run: | if [[ "${{ matrix.sandbox }}" == "sandbox:docker" ]]; then npm run test:integration:sandbox:docker else npm run test:integration:sandbox:none fi e2e_mac: name: 'E2E Test (macOS)' if: | (github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || (github.event.pull_request.head.repo.full_name == github.repository) || (github.event.label.name == 'maintainer:e2e:ok')) runs-on: 'macos-latest' steps: - name: 'Checkout (fork)' uses: 'actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955' # ratchet:actions/checkout@v5 if: "github.event_name == 'pull_request_target'" with: ref: '${{ github.event.pull_request.head.sha }}' repository: '${{ github.event.pull_request.head.repo.full_name }}' - name: 'Checkout (internal)' uses: 'actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955' # ratchet:actions/checkout@v5 if: "github.event_name != 'pull_request_target'" with: ref: '${{ github.event.inputs.branch_ref || github.ref }}' - name: 'Set up Node.js 20.x' uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions-node@v4 with: node-version: '20.x' - name: 'Setup NPMRC' uses: './.github/actions/setup-npmrc' with: github-token: '${{ secrets.GITHUB_TOKEN }}' - name: 'Install dependencies' run: 'npm install @google-gemini/gemini-cli@${{ inputs.version }}' - name: 'Fix rollup optional dependencies on macOS' if: "runner.os == 'macOS'" run: | npm cache clean --force - name: 'Run E2E tests (non-Windows)' if: "runner.os != 'Windows'" env: GEMINI_API_KEY: '${{ secrets.GEMINI_API_KEY }}' KEEP_OUTPUT: 'true' SANDBOX: 'sandbox:none' VERBOSE: 'true' INTEGRATION_TEST_USE_INSTALLED_GEMINI: 'true' run: 'npm run test:integration:sandbox:none' e2e_windows: name: 'Slow E2E - Win' if: | (github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || (github.event.pull_request.head.repo.full_name == github.repository) || (github.event.label.name == 'maintainer:e2e:ok')) runs-on: 'gemini-cli-windows-16-core' continue-on-error: true steps: - name: 'Checkout (fork)' uses: 'actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955' # ratchet:actions/checkout@v5 if: "github.event_name == 'pull_request_target'" with: ref: '${{ github.event.pull_request.head.sha }}' repository: '${{ github.event.pull_request.head.repo.full_name }}' - name: 'Checkout (internal)' uses: 'actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955' # ratchet:actions/checkout@v5 if: "github.event_name != 'pull_request_target'" with: ref: '${{ github.event.inputs.branch_ref || github.ref }}' - name: 'Set up Node.js 20.x' uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions-node@v4 with: node-version: '20.x' cache: 'npm' - name: 'Configure Windows Defender exclusions' run: | Add-MpPreference -ExclusionPath $env:GITHUB_WORKSPACE -Force Add-MpPreference -ExclusionPath "$env:GITHUB_WORKSPACE\node_modules" -Force Add-MpPreference -ExclusionPath "$env:GITHUB_WORKSPACE\packages" -Force Add-MpPreference -ExclusionPath "$env:TEMP" -Force shell: 'pwsh' - name: 'Configure npm for Windows performance' run: | npm config set progress false npm config set audit false npm config set fund false npm config set loglevel error npm config set maxsockets 32 npm config set registry https://registry.npmjs.org/ shell: 'pwsh' - name: 'Setup NPMRC' uses: './.github/actions/setup-npmrc' with: github-token: '${{ secrets.GITHUB_TOKEN }}' - name: 'Install dependencies' run: 'npm install ${{ inputs.cli-package-name }}@${{ inputs.version }}' shell: 'pwsh' - name: 'Run E2E tests' env: GEMINI_API_KEY: '${{ secrets.GEMINI_API_KEY }}' KEEP_OUTPUT: 'true' SANDBOX: 'sandbox:none' VERBOSE: 'true' NODE_OPTIONS: '--max-old-space-size=32768 --max-semi-space-size=256' UV_THREADPOOL_SIZE: '32' NODE_ENV: 'test' INTEGRATION_TEST_USE_INSTALLED_GEMINI: 'true' shell: 'pwsh' run: 'npm run test:integration:sandbox:none' e2e: name: 'E2E' if: | always() && ( github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' || (github.event.pull_request.head.repo.full_name == github.repository) || (github.event.label.name == 'maintainer:e2e:ok') ) needs: - 'e2e_linux' - 'e2e_mac' runs-on: 'ubuntu-latest' steps: - name: 'Check E2E test results' run: | if [[ (${{ needs.e2e_linux.result }} != 'success' && ${{ needs.e2e_linux.result }} != 'skipped') || \ (${{ needs.e2e_mac.result }} != 'success' && ${{ needs.e2e_mac.result }} != 'skipped') ]]; then echo "One or more E2E jobs failed." exit 1 fi echo "All required E2E jobs passed!"