diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b2c0de..785d39b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,45 +19,33 @@ on: permissions: contents: read +# All jobs share one Gemini API project, so they run sequentially (via `needs`) +# to avoid hitting per-minute token/request quotas concurrently. jobs: - test-go: + test-python: runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ github.event.inputs.ref || '' }} - # Persist credentials is false to prevent the PR code from using the GITHUB_TOKEN persist-credentials: false - - name: Set up Go - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 + - name: Set up Python + uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0 with: - go-version: '1.22' - - name: Run Go tests - working-directory: ./go + python-version: '3.11' + - name: Install dependencies + working-directory: ./python + run: pip install absl-py google-genai Pillow pyink pytest + - name: Run Python tests + working-directory: ./python env: GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} - run: go test -timeout 20m ./... - - test-java: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - ref: ${{ github.event.inputs.ref || '' }} - persist-credentials: false - - name: Set up JDK 24 - uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0 - with: - java-version: '24' - distribution: 'temurin' - cache: maven - - name: Run Java tests - working-directory: ./java - env: - GOOGLE_API_KEY: ${{ secrets.GEMINI_API_KEY }} - run: mvn -B test + # Discover and run all .py files as tests + run: python -m unittest discover -p "*.py" test-javascript: + needs: test-python + if: ${{ !cancelled() }} runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -73,29 +61,70 @@ jobs: - name: Install dependencies working-directory: ./javascript run: npm ci - - name: Run JavaScript tests + # Cache/token tests send ~322k-token prompts; run them first, in isolation. + - name: Run token-heavy JavaScript tests + working-directory: ./javascript + env: + GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} + run: node --test --test-concurrency=1 cache.test.js count_tokens.test.js + - name: Wait for per-minute quota to reset + if: ${{ !cancelled() }} + run: sleep 65 + - name: Run remaining JavaScript tests + if: ${{ !cancelled() }} working-directory: ./javascript env: GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} - run: node --test *.test.js + run: | + node --test --test-concurrency=1 $(ls *.test.js | grep -vE '^(cache|count_tokens)\.test\.js$') - test-python: + test-go: + needs: test-javascript + if: ${{ !cancelled() }} runs-on: ubuntu-latest steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ github.event.inputs.ref || '' }} + # Persist credentials is false to prevent the PR code from using the GITHUB_TOKEN persist-credentials: false - - name: Set up Python - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0 + - name: Set up Go + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 with: - python-version: '3.11' - - name: Install dependencies - working-directory: ./python - run: pip install absl-py google-genai Pillow pyink pytest - - name: Run Python tests - working-directory: ./python + go-version: '1.22' + # Cache/token tests send ~322k-token prompts; run them first, in isolation. + - name: Run token-heavy Go tests + working-directory: ./go env: GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} - # Discover and run all .py files as tests - run: python -m unittest discover -p "*.py" + run: go test -timeout 20m -v -run '^Test(Cache|Tokens)' ./... + - name: Wait for per-minute quota to reset + if: ${{ !cancelled() }} + run: sleep 65 + - name: Run remaining Go tests + if: ${{ !cancelled() }} + working-directory: ./go + env: + GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} + run: go test -timeout 20m -v -skip '^Test(Cache|Tokens)' ./... + + test-java: + needs: test-go + if: ${{ !cancelled() }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + ref: ${{ github.event.inputs.ref || '' }} + persist-credentials: false + - name: Set up JDK 24 + uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0 + with: + java-version: '24' + distribution: 'temurin' + cache: maven + - name: Run Java tests + working-directory: ./java + env: + GOOGLE_API_KEY: ${{ secrets.GEMINI_API_KEY }} + run: mvn -B test