mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-29 03:44:06 +08:00
239 lines
8.7 KiB
YAML
239 lines
8.7 KiB
YAML
name: test
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
# Keep every run on main so cancelled checks do not pollute the default branch
|
|
# commit history. PRs and other branches still share a group and cancel stale runs.
|
|
group: ${{ case(github.ref == 'refs/heads/main', format('{0}-{1}', github.workflow, github.run_id), format('{0}-{1}', github.workflow, github.event.pull_request.number || github.ref)) }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
checks: write
|
|
|
|
env:
|
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
|
|
jobs:
|
|
# kilocode_change start
|
|
changes:
|
|
name: detect general unit test changes
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
permissions:
|
|
contents: read
|
|
pull-requests: read
|
|
outputs:
|
|
settings: ${{ steps.matrix.outputs.settings }}
|
|
general: ${{ steps.matrix.outputs.general }}
|
|
steps:
|
|
- name: Checkout repository
|
|
if: github.event_name != 'workflow_dispatch'
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Detect general unit test changes
|
|
if: github.event_name != 'workflow_dispatch'
|
|
id: filter
|
|
uses: Kilo-Org/paths-filter@668c092af3649c4b664c54e4b704aa46782f6f7c # v3
|
|
with:
|
|
predicate-quantifier: every
|
|
filters: |
|
|
general:
|
|
- '**'
|
|
- '!.changeset/**'
|
|
- '!packages/kilo-jetbrains/**'
|
|
- '!packages/kilo-vscode/**'
|
|
- '!packages/kilo-docs/**'
|
|
- '!packages/extensions/zed/**'
|
|
- '!specs/**'
|
|
- '!perf/**'
|
|
|
|
- name: Configure unit matrix
|
|
id: matrix
|
|
env:
|
|
GENERAL: ${{ github.event_name != 'pull_request' || steps.filter.outputs.general == 'true' }}
|
|
run: |
|
|
if [ "$GENERAL" != "true" ]; then
|
|
echo 'general=false' >> "$GITHUB_OUTPUT"
|
|
echo 'settings=[{"name":"linux","host":"blacksmith-4vcpu-ubuntu-2404","run":false,"shard":"","packages":false}]' >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
echo 'general=true' >> "$GITHUB_OUTPUT"
|
|
echo 'settings=[{"name":"linux-1","host":"blacksmith-4vcpu-ubuntu-2404","run":true,"shard":"1/2","packages":true},{"name":"linux-2","host":"blacksmith-4vcpu-ubuntu-2404","run":true,"shard":"2/2","packages":false},{"name":"macos-1","host":"macos-15","run":true,"shard":"1/3","packages":true},{"name":"macos-2","host":"macos-15","run":true,"shard":"2/3","packages":false},{"name":"macos-3","host":"macos-15","run":true,"shard":"3/3","packages":false},{"name":"windows-1","host":"blacksmith-4vcpu-windows-2025","run":true,"shard":"1/4","packages":true},{"name":"windows-2","host":"blacksmith-4vcpu-windows-2025","run":true,"shard":"2/4","packages":false},{"name":"windows-3","host":"blacksmith-4vcpu-windows-2025","run":true,"shard":"3/4","packages":false},{"name":"windows-4","host":"blacksmith-4vcpu-windows-2025","run":true,"shard":"4/4","packages":false}]' >> "$GITHUB_OUTPUT"
|
|
|
|
unit:
|
|
name: unit (${{ matrix.settings.name }})
|
|
needs: changes
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
settings: ${{ fromJSON(needs.changes.outputs.settings) }}
|
|
runs-on: ${{ matrix.settings.host }}
|
|
timeout-minutes: 45 # kilocode_change
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
steps:
|
|
- name: Skip unchanged general unit tests
|
|
if: ${{ !matrix.settings.run }}
|
|
run: echo "Only isolated product, documentation, or metadata files changed; general unit tests are unchanged."
|
|
|
|
- name: Checkout repository
|
|
if: matrix.settings.run
|
|
uses: actions/checkout@v6 # kilocode_change
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
# kilocode_change start
|
|
- name: Setup Node
|
|
if: matrix.settings.run
|
|
id: setup-node
|
|
continue-on-error: ${{ runner.os == 'Windows' }}
|
|
uses: actions/setup-node@v6 # kilocode_change
|
|
with:
|
|
node-version: "24"
|
|
|
|
- name: Retry Setup Node on Windows
|
|
if: matrix.settings.run && runner.os == 'Windows' && steps.setup-node.outcome == 'failure'
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: "24"
|
|
# kilocode_change end
|
|
|
|
- name: Setup Bun
|
|
if: matrix.settings.run
|
|
uses: ./.github/actions/setup-bun
|
|
|
|
# kilocode_change start
|
|
- name: Setup Linux sandbox helper
|
|
if: matrix.settings.run && runner.os == 'Linux'
|
|
uses: ./.github/actions/setup-linux-sandbox
|
|
# kilocode_change end
|
|
- name: Configure git identity
|
|
if: matrix.settings.run
|
|
run: |
|
|
git config --global user.email "kilo-maintainer[bot]@users.noreply.github.com"
|
|
git config --global user.name "kilo-maintainer[bot]"
|
|
|
|
- name: Cache Turbo
|
|
if: matrix.settings.run
|
|
uses: actions/cache@v5 # kilocode_change
|
|
with:
|
|
path: .turbo/cache # kilocode_change
|
|
key: turbo-${{ runner.os }}-${{ hashFiles('turbo.json', 'bun.lock') }}-${{ matrix.settings.name }}-${{ github.sha }}
|
|
restore-keys: |
|
|
turbo-${{ runner.os }}-${{ hashFiles('turbo.json', 'bun.lock') }}-${{ matrix.settings.name }}-
|
|
turbo-${{ runner.os }}-${{ hashFiles('turbo.json', 'bun.lock') }}-
|
|
turbo-${{ runner.os }}-
|
|
|
|
- name: Run non-CLI unit tests
|
|
if: matrix.settings.run && matrix.settings.packages
|
|
run: bun turbo test:ci --filter='!@kilocode/cli' --filter='!@kilocode/kilo-jetbrains'
|
|
|
|
- name: Run CLI unit tests
|
|
if: matrix.settings.run
|
|
run: bun turbo test:ci --filter='@kilocode/cli'
|
|
env:
|
|
KILO_EXPERIMENTAL_DISABLE_FILEWATCHER: ${{ runner.os == 'Windows' && 'true' || 'false' }}
|
|
KILO_TEST_SHARD: ${{ matrix.settings.shard }}
|
|
|
|
- name: Publish unit reports # kilocode_change
|
|
if: always() && matrix.settings.run
|
|
uses: mikepenz/action-junit-report@bccf2e31636835cf0874589931c4116687171386 # v6.4.0
|
|
with:
|
|
report_paths: packages/*/.artifacts/unit/junit.xml
|
|
check_name: "unit results (${{ matrix.settings.name }})"
|
|
detailed_summary: true
|
|
include_time_in_summary: true
|
|
fail_on_failure: false
|
|
|
|
- name: Upload unit artifacts
|
|
if: always() && matrix.settings.run
|
|
uses: actions/upload-artifact@v7 # kilocode_change
|
|
with:
|
|
name: unit-${{ matrix.settings.name }}-${{ github.run_attempt }}
|
|
include-hidden-files: true
|
|
if-no-files-found: ignore
|
|
retention-days: 7
|
|
path: packages/*/.artifacts/unit/junit.xml
|
|
# kilocode_change end
|
|
|
|
# kilocode_change start
|
|
httpapi:
|
|
name: HttpApi exerciser
|
|
needs: changes
|
|
if: needs.changes.outputs.general == 'true'
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
timeout-minutes: 15
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Setup Bun
|
|
uses: ./.github/actions/setup-bun
|
|
|
|
- name: Setup Linux sandbox helper
|
|
uses: ./.github/actions/setup-linux-sandbox
|
|
|
|
- name: Configure git identity
|
|
run: |
|
|
git config --global user.email "kilo-maintainer[bot]@users.noreply.github.com"
|
|
git config --global user.name "kilo-maintainer[bot]"
|
|
|
|
- name: Cache Turbo
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: .turbo/cache
|
|
key: turbo-${{ runner.os }}-${{ hashFiles('turbo.json', 'bun.lock') }}-httpapi-${{ github.sha }}
|
|
restore-keys: |
|
|
turbo-${{ runner.os }}-${{ hashFiles('turbo.json', 'bun.lock') }}-httpapi-
|
|
turbo-${{ runner.os }}-${{ hashFiles('turbo.json', 'bun.lock') }}-
|
|
turbo-${{ runner.os }}-
|
|
|
|
- name: Run HttpApi exerciser gates
|
|
run: bun turbo test:httpapi --filter='@kilocode/cli'
|
|
# kilocode_change end
|
|
|
|
# kilocode_change start
|
|
jetbrains:
|
|
name: jetbrains
|
|
permissions:
|
|
contents: read
|
|
checks: write
|
|
pull-requests: read
|
|
uses: ./.github/workflows/test-jetbrains.yml
|
|
# kilocode_change end
|
|
|
|
# kilocode_change start
|
|
required:
|
|
name: test (linux)
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
needs:
|
|
- changes
|
|
- unit
|
|
- httpapi
|
|
- jetbrains
|
|
if: always()
|
|
steps:
|
|
- name: Verify upstream test jobs passed
|
|
run: |
|
|
echo "unit=${{ needs.unit.result }}"
|
|
echo "httpapi=${{ needs.httpapi.result }}"
|
|
echo "jetbrains=${{ needs.jetbrains.result }}"
|
|
test "${{ needs.unit.result }}" = "success"
|
|
if [ "${{ needs.changes.outputs.general }}" = "true" ]; then
|
|
test "${{ needs.httpapi.result }}" = "success"
|
|
else
|
|
test "${{ needs.httpapi.result }}" = "skipped"
|
|
fi
|
|
test "${{ needs.jetbrains.result }}" = "success"
|
|
# kilocode_change end
|