mirror of
https://github.com/Fission-AI/OpenSpec.git
synced 2026-09-14 20:16:53 +08:00
4867bfade5
* feat: implement Phase 1 E2E testing with cross-platform CI matrix - Add shared runCLI helper in test/helpers/run-cli.ts for spawn testing - Create test/cli-e2e/basic.test.ts covering help, version, validate flows - Migrate existing CLI exec tests to use runCLI helper - Extend CI matrix to bash (Linux/macOS) and pwsh (Windows) - Update Phase 1 tasks and proposal with implementation status * fix: correct YAML syntax in CI workflow diagnostics command * fix: use multiline YAML for diagnostics command * fix ci * fix: ci * fix: update core validation and json converter * chore(ci): split pr and main workflows * refactor: simplify CI workflow with unified matrix strategy - Consolidate test_pr and test_matrix into single test job - Add proper shell configuration with defaults - Add timeout protection (15 minutes) - Simplify required-checks to single job - Maintain cross-platform testing (bash on Linux/macOS, pwsh on Windows) * fix: restore lean PR workflow with async main branch matrix - PRs run only essential tests on ubuntu-latest (fast feedback) - Main branch runs full cross-platform matrix asynchronously - Separate required-checks for each workflow type - Different timeouts: 10min for PR, 15min for matrix
223 lines
5.2 KiB
YAML
223 lines
5.2 KiB
YAML
name: CI
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
test_pr:
|
|
name: Test
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
if: github.event_name == 'pull_request'
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Build project
|
|
run: pnpm run build
|
|
|
|
- name: Run tests
|
|
run: pnpm test
|
|
|
|
- name: Upload test coverage
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: coverage-report-pr
|
|
path: coverage/
|
|
retention-days: 7
|
|
|
|
test_matrix:
|
|
name: Test (${{ matrix.label }})
|
|
runs-on: ${{ matrix.os }}
|
|
timeout-minutes: 15
|
|
if: github.event_name != 'pull_request'
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
shell: bash
|
|
label: linux-bash
|
|
- os: macos-latest
|
|
shell: bash
|
|
label: macos-bash
|
|
- os: windows-latest
|
|
shell: pwsh
|
|
label: windows-pwsh
|
|
|
|
defaults:
|
|
run:
|
|
shell: ${{ matrix.shell }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'pnpm'
|
|
|
|
- name: Print environment diagnostics
|
|
run: |
|
|
node -p "JSON.stringify({ platform: process.platform, arch: process.arch, shell: process.env.SHELL || process.env.ComSpec || '' })"
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Build project
|
|
run: pnpm run build
|
|
|
|
- name: Run tests
|
|
run: pnpm test
|
|
|
|
- name: Upload test coverage
|
|
if: matrix.os == 'ubuntu-latest'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: coverage-report-main
|
|
path: coverage/
|
|
retention-days: 7
|
|
|
|
lint:
|
|
name: Lint & Type Check
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Build project
|
|
run: pnpm run build
|
|
|
|
- name: Type check
|
|
run: pnpm exec tsc --noEmit
|
|
|
|
- name: Check for build artifacts
|
|
run: |
|
|
if [ ! -d "dist" ]; then
|
|
echo "Error: dist directory not found after build"
|
|
exit 1
|
|
fi
|
|
if [ ! -f "dist/cli/index.js" ]; then
|
|
echo "Error: CLI entry point not found"
|
|
exit 1
|
|
fi
|
|
|
|
validate-changesets:
|
|
name: Validate Changesets
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'pull_request'
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Validate changesets
|
|
run: |
|
|
if command -v changeset &> /dev/null; then
|
|
pnpm exec changeset status --since=origin/main
|
|
else
|
|
echo "Changesets not configured, skipping validation"
|
|
fi
|
|
|
|
required-checks-pr:
|
|
name: All checks passed
|
|
runs-on: ubuntu-latest
|
|
needs: [test_pr, lint]
|
|
if: always() && github.event_name == 'pull_request'
|
|
steps:
|
|
- name: Verify all checks passed
|
|
run: |
|
|
if [[ "${{ needs.test_pr.result }}" != "success" ]]; then
|
|
echo "Test job failed"
|
|
exit 1
|
|
fi
|
|
if [[ "${{ needs.lint.result }}" != "success" ]]; then
|
|
echo "Lint job failed"
|
|
exit 1
|
|
fi
|
|
echo "All required checks passed!"
|
|
|
|
required-checks-main:
|
|
name: All checks passed
|
|
runs-on: ubuntu-latest
|
|
needs: [test_matrix, lint]
|
|
if: always() && github.event_name != 'pull_request'
|
|
steps:
|
|
- name: Verify all checks passed
|
|
run: |
|
|
if [[ "${{ needs.test_matrix.result }}" != "success" ]]; then
|
|
echo "Matrix test job failed"
|
|
exit 1
|
|
fi
|
|
if [[ "${{ needs.lint.result }}" != "success" ]]; then
|
|
echo "Lint job failed"
|
|
exit 1
|
|
fi
|
|
echo "All required checks passed!"
|