mirror of
https://github.com/cline/cline.git
synced 2026-09-19 02:05:44 +08:00
225 lines
7.7 KiB
YAML
225 lines
7.7 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
workflow_call:
|
|
|
|
# Set default permissions for all jobs
|
|
permissions:
|
|
contents: read # Needed to check out code
|
|
checks: write # Needed to report test results
|
|
pull-requests: write # Needed to add comments/annotations to PRs
|
|
|
|
jobs:
|
|
quality-checks:
|
|
runs-on: ubuntu-latest
|
|
name: Quality Checks
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js environment
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: 'npm'
|
|
cache-dependency-path: |
|
|
package-lock.json
|
|
webview-ui/package-lock.json
|
|
|
|
- name: Install root dependencies
|
|
run: npm ci
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Install webview-ui dependencies
|
|
run: cd webview-ui && npm ci
|
|
|
|
- name: Run Quality Checks (Parallel)
|
|
run: npm run ci:check-all
|
|
|
|
test:
|
|
needs: quality-checks
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu-latest, windows-latest]
|
|
runs-on: ${{ matrix.os }}
|
|
name: ${{ matrix.os == 'ubuntu-latest' && 'test' || format('test ({0})', matrix.os) }}
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js environment
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: 'npm'
|
|
cache-dependency-path: |
|
|
package-lock.json
|
|
webview-ui/package-lock.json
|
|
|
|
- name: Install root dependencies
|
|
run: npm ci
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Install webview-ui dependencies
|
|
run: cd webview-ui && npm ci
|
|
|
|
- name: Set up NPM on Windows
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe"
|
|
|
|
# Build the extension and tests (without redundant checks)
|
|
- name: Build Tests and Extension
|
|
id: build_step
|
|
run: npm run ci:build
|
|
|
|
- name: Unit Tests with coverage - Linux
|
|
id: unit_tests_linux
|
|
if: ${{ !cancelled() && steps.build_step.outcome == 'success' && runner.os == 'Linux' }}
|
|
run: |
|
|
npx nyc --nycrc-path .nycrc.unit.json --reporter=lcov npm run test:unit
|
|
|
|
- name: Unit Tests - Non-Linux
|
|
id: unit_tests_non_linux
|
|
if: ${{ !cancelled() && steps.build_step.outcome == 'success' && runner.os != 'Linux' }}
|
|
run: |
|
|
npm run test:unit
|
|
|
|
- name: Extension Integration Tests - Linux
|
|
id: integration_tests_linux
|
|
if: ${{ !cancelled() && steps.build_step.outcome == 'success' && runner.os == 'Linux' }}
|
|
run: xvfb-run -a npm run test:coverage
|
|
|
|
- name: Extension Integration Tests - Non-Linux
|
|
id: integration_tests_non_linux
|
|
if: ${{ !cancelled() && steps.build_step.outcome == 'success' && runner.os != 'Linux' }}
|
|
run: npm run test:integration
|
|
|
|
- name: Webview Tests with Coverage
|
|
id: webview_tests
|
|
if: ${{ !cancelled() && steps.build_step.outcome == 'success' }}
|
|
run: |
|
|
cd webview-ui
|
|
npm run test:coverage
|
|
|
|
- name: CLI Tests
|
|
id: cli_tests
|
|
if: ${{ !cancelled() && steps.build_step.outcome == 'success' }}
|
|
run: cd cli && npm run test:run
|
|
|
|
- name: Save Coverage Reports
|
|
uses: actions/upload-artifact@v4
|
|
# Only upload artifacts on Linux - We only need coverage from one OS
|
|
if: runner.os == 'Linux'
|
|
with:
|
|
name: pr-coverage-reports
|
|
path: |
|
|
coverage-unit/lcov.info
|
|
webview-ui/coverage/lcov.info
|
|
|
|
test-platform-integration:
|
|
needs: quality-checks
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js environment
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: 'npm'
|
|
cache-dependency-path: |
|
|
package-lock.json
|
|
webview-ui/package-lock.json
|
|
testing-platform/package-lock.json
|
|
|
|
- name: Install root dependencies
|
|
run: npm ci
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Install webview-ui dependencies
|
|
run: cd webview-ui && npm ci
|
|
|
|
- name: Download ripgrep binaries
|
|
run: npm run download-ripgrep
|
|
|
|
- name: Compile Standalone
|
|
run: npm run compile-standalone
|
|
|
|
- name: Install testing platform dependencies
|
|
run: cd testing-platform && npm ci
|
|
|
|
- name: Running testing platform integration spec tests
|
|
timeout-minutes: 7
|
|
run: npm run test:tp-orchestrator -- tests/specs/ --count=1 --coverage
|
|
|
|
- name: Save Coverage Reports
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: test-platform-integration-core-coverage
|
|
path: coverage/**/lcov.info
|
|
|
|
qlty:
|
|
needs: [test, test-platform-integration]
|
|
runs-on: ubuntu-latest
|
|
# Run on PRs to main, pushes to main, and manual dispatches
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download unit tests coverage reports
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: pr-coverage-reports
|
|
path: .
|
|
|
|
- name: Upload core unit tests coverage to Qlty
|
|
uses: qltysh/qlty-action/coverage@v2
|
|
with:
|
|
token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
|
|
# we can merge multiple files if necessary
|
|
files: |
|
|
coverage-unit/lcov.info
|
|
tag: unit:core
|
|
|
|
- name: Upload webview-ui unit tests coverage to Qlty
|
|
uses: qltysh/qlty-action/coverage@v2
|
|
with:
|
|
token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
|
|
# we can merge multiple files if necessary
|
|
files: |
|
|
webview-ui/coverage/lcov.info
|
|
tag: unit:webview-ui
|
|
add-prefix: webview-ui/
|
|
|
|
- name: Download test platform integration core coverage artifact
|
|
uses: actions/download-artifact@v4
|
|
continue-on-error: true
|
|
id: download-integration-coverage
|
|
with:
|
|
name: test-platform-integration-core-coverage
|
|
path: integration-core-coverage-reports
|
|
|
|
- name: Upload core integration tests coverage to Qlty
|
|
if: steps.download-integration-coverage.outcome == 'success'
|
|
uses: qltysh/qlty-action/coverage@v2
|
|
with:
|
|
token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
|
|
files: integration-core-coverage-reports/**/lcov.info
|
|
tag: integration:core
|