mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-14 13:27:38 -07:00
e03570f99e
Prefixes the concurrency group names in 'ci.yml' and 'e2e.yml' with 'ci-' and 'e2e-' respectively. This prevents the workflows from canceling each other out when they are triggered by the same orchestrator workflow, as the 'github.workflow' context variable was resolving to the same value for both.
278 lines
9.7 KiB
YAML
278 lines
9.7 KiB
YAML
name: 'Testing: CI'
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
version:
|
|
description: 'The version of the published package'
|
|
required: true
|
|
type: 'string'
|
|
|
|
concurrency:
|
|
group: 'ci-${{ github.workflow }}-${{ github.head_ref || github.ref }}'
|
|
cancel-in-progress: |-
|
|
${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/heads/release/') }}
|
|
|
|
permissions:
|
|
checks: 'write'
|
|
contents: 'read'
|
|
statuses: 'write'
|
|
packages: 'read'
|
|
pull-requests: 'write'
|
|
actions: 'read'
|
|
security-events: 'write'
|
|
|
|
defaults:
|
|
run:
|
|
shell: 'bash'
|
|
|
|
jobs:
|
|
test_linux:
|
|
name: 'Test (Linux)'
|
|
runs-on: 'gemini-cli-ubuntu-16-core'
|
|
strategy:
|
|
matrix:
|
|
node-version:
|
|
- '20.x'
|
|
- '22.x'
|
|
- '24.x'
|
|
steps:
|
|
- name: 'Checkout'
|
|
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
|
|
|
|
- name: 'Set up Node.js ${{ matrix.node-version }}'
|
|
uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions/setup-node@v4
|
|
with:
|
|
node-version: '${{ matrix.node-version }}'
|
|
cache: 'npm'
|
|
|
|
- name: 'Configure npm for GitHub Packages'
|
|
run: |
|
|
echo "@google-gemini:registry=https://npm.pkg.github.com/" > .npmrc
|
|
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
|
|
|
|
- name: 'Install dependencies for testing'
|
|
run: 'npm install @google-gemini/gemini-cli@${{ inputs.version }}'
|
|
|
|
- name: 'Run tests and generate reports'
|
|
env:
|
|
NO_COLOR: true
|
|
run: 'npm run test:ci'
|
|
|
|
- name: 'Smoke test bundle'
|
|
run: 'gemini --version'
|
|
|
|
- name: 'Wait for file system sync'
|
|
run: 'sleep 2'
|
|
|
|
- name: 'Publish Test Report (for non-forks)'
|
|
if: |-
|
|
${{ always() && (github.event.pull_request.head.repo.full_name == github.repository) }}
|
|
uses: 'dorny/test-reporter@dc3a92680fcc15842eef52e8c4606ea7ce6bd3f3' # ratchet:dorny/test-reporter@v2
|
|
with:
|
|
name: 'Test Results (Node ${{ matrix.node-version }})'
|
|
path: 'packages/*/junit.xml'
|
|
reporter: 'java-junit'
|
|
fail-on-error: 'false'
|
|
|
|
- name: 'Upload Test Results Artifact (for forks)'
|
|
if: |-
|
|
${{ always() && (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
|
|
uses: 'actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02' # ratchet:actions/upload-artifact@v4
|
|
with:
|
|
name: 'test-results-fork-${{ matrix.node-version }}-${{ runner.os }}'
|
|
path: 'packages/*/junit.xml'
|
|
|
|
test_mac:
|
|
name: 'Test (Mac)'
|
|
runs-on: '${{ matrix.os }}'
|
|
continue-on-error: true
|
|
strategy:
|
|
matrix:
|
|
os:
|
|
- 'macos-latest'
|
|
node-version:
|
|
- '20.x'
|
|
- '22.x'
|
|
- '24.x'
|
|
steps:
|
|
- name: 'Checkout'
|
|
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
|
|
|
|
- name: 'Set up Node.js ${{ matrix.node-version }}'
|
|
uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions/setup-node@v4
|
|
with:
|
|
node-version: '${{ matrix.node-version }}'
|
|
cache: 'npm'
|
|
|
|
- name: 'Configure npm for GitHub Packages'
|
|
run: |
|
|
echo "@google-gemini:registry=https://npm.pkg.github.com/" > .npmrc
|
|
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
|
|
|
|
- name: 'Install dependencies for testing'
|
|
run: 'npm install @google-gemini/gemini-cli@${{ inputs.version }}'
|
|
|
|
- name: 'Run tests and generate reports'
|
|
env:
|
|
NO_COLOR: true
|
|
run: 'npm run test:ci -- --coverage.enabled=false'
|
|
|
|
- name: 'Smoke test bundle'
|
|
run: 'gemini --version'
|
|
|
|
- name: 'Wait for file system sync'
|
|
run: 'sleep 2'
|
|
|
|
- name: 'Publish Test Report (for non-forks)'
|
|
if: |-
|
|
${{ always() && (github.event.pull_request.head.repo.full_name == github.repository) }}
|
|
uses: 'dorny/test-reporter@dc3a92680fcc15842eef52e8c4606ea7ce6bd3f3' # ratchet:dorny/test-reporter@v2
|
|
with:
|
|
name: 'Test Results (Node ${{ matrix.node-version }})'
|
|
path: 'packages/*/junit.xml'
|
|
reporter: 'java-junit'
|
|
fail-on-error: 'false'
|
|
|
|
- name: 'Upload Test Results Artifact (for forks)'
|
|
if: |-
|
|
${{ always() && (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
|
|
uses: 'actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02' # ratchet:actions/upload-artifact@v4
|
|
with:
|
|
name: 'test-results-fork-${{ matrix.node-version }}-${{ runner.os }}'
|
|
path: 'packages/*/junit.xml'
|
|
|
|
- name: 'Upload coverage reports'
|
|
if: |-
|
|
${{ always() }}
|
|
uses: 'actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02' # ratchet:actions/upload-artifact@v4
|
|
with:
|
|
name: 'coverage-reports-${{ matrix.node-version }}-${{ matrix.os }}'
|
|
path: 'packages/*/coverage'
|
|
|
|
codeql:
|
|
name: 'CodeQL'
|
|
runs-on: 'gemini-cli-ubuntu-16-core'
|
|
steps:
|
|
- name: 'Checkout'
|
|
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
|
|
with:
|
|
ref: '${{ github.event.inputs.branch_ref || github.ref }}'
|
|
|
|
- name: 'Initialize CodeQL'
|
|
uses: 'github/codeql-action/init@df559355d593797519d70b90fc8edd5db049e7a2' # ratchet:github/codeql-action/init@v3
|
|
with:
|
|
languages: 'javascript'
|
|
|
|
- name: 'Perform CodeQL Analysis'
|
|
uses: 'github/codeql-action/analyze@df559355d593797519d70b90fc8edd5db049e7a2' # ratchet:github/codeql-action/analyze@v3
|
|
|
|
# Check for changes in bundle size.
|
|
bundle_size:
|
|
name: 'Check Bundle Size'
|
|
if: "${{github.event_name == 'pull_request'}}"
|
|
runs-on: 'gemini-cli-ubuntu-16-core'
|
|
|
|
steps:
|
|
- name: 'Checkout'
|
|
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
|
|
with:
|
|
ref: '${{ github.event.inputs.branch_ref || github.ref }}'
|
|
fetch-depth: 1
|
|
|
|
- name: 'Configure npm for GitHub Packages'
|
|
run: |
|
|
echo "@google-gemini:registry=https://npm.pkg.github.com/" > .npmrc
|
|
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
|
|
|
|
- name: 'Install bundle'
|
|
run: 'npm install @google-gemini/gemini-cli@${{ inputs.version }}'
|
|
|
|
- uses: 'preactjs/compressed-size-action@946a292cd35bd1088e0d7eb92b69d1a8d5b5d76a'
|
|
with:
|
|
repo-token: '${{ secrets.GITHUB_TOKEN }}'
|
|
pattern: './bundle/**/*.{js,sb}'
|
|
minimum-change-threshold: '1000'
|
|
compression: 'none'
|
|
clean-script: 'clean'
|
|
|
|
test_windows:
|
|
name: 'Slow Test - Win'
|
|
runs-on: 'gemini-cli-windows-16-core'
|
|
continue-on-error: true
|
|
|
|
steps:
|
|
- name: 'Checkout'
|
|
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
|
|
with:
|
|
ref: '${{ github.event.inputs.branch_ref || github.ref }}'
|
|
|
|
- name: 'Set up Node.js 20.x'
|
|
uses: 'actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020' # ratchet:actions/setup-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: 'Configure npm for GitHub Packages'
|
|
run: |
|
|
echo "@google-gemini:registry=https://npm.pkg.github.com/" > .npmrc
|
|
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> .npmrc
|
|
shell: 'pwsh'
|
|
|
|
- name: 'Install dependencies'
|
|
run: 'npm install @google-gemini/gemini-cli@${{ inputs.version }}'
|
|
shell: 'pwsh'
|
|
|
|
- name: 'Run tests and generate reports'
|
|
env:
|
|
GEMINI_API_KEY: '${{ secrets.GEMINI_API_KEY }}'
|
|
NO_COLOR: true
|
|
NODE_OPTIONS: '--max-old-space-size=32768 --max-semi-space-size=256'
|
|
UV_THREADPOOL_SIZE: '32'
|
|
NODE_ENV: 'test'
|
|
run: 'npm run test:ci -- --coverage.enabled=false'
|
|
shell: 'pwsh'
|
|
|
|
- name: 'Smoke test bundle'
|
|
run: 'gemini --version'
|
|
shell: 'pwsh'
|
|
|
|
ci:
|
|
name: 'CI'
|
|
if: 'always()'
|
|
needs:
|
|
- 'test_linux'
|
|
- 'test_mac'
|
|
- 'codeql'
|
|
- 'bundle_size'
|
|
runs-on: 'gemini-cli-ubuntu-16-core'
|
|
steps:
|
|
- name: 'Check all job results'
|
|
run: |
|
|
if [[ (${{ needs.test_linux.result }} != 'success' && ${{ needs.test_linux.result }} != 'skipped') || \
|
|
(${{ needs.test_mac.result }} != 'success' && ${{ needs.test_mac.result }} != 'skipped') || \
|
|
(${{ needs.codeql.result }} != 'success' && ${{ needs.codeql.result }} != 'skipped') || \
|
|
(${{ needs.bundle_size.result }} != 'success' && ${{ needs.bundle_size.result }} != 'skipped') ]]; then
|
|
echo "One or more CI jobs failed."
|
|
exit 1
|
|
fi
|
|
echo "All CI jobs passed!"
|