feat: Enable CI test reporting and artifact management (#367)
This commit is contained in:
parent
9c46acc793
commit
7d818b46bc
|
@ -4,58 +4,97 @@ name: Gemini CLI CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main] # Run on pushes to the main branch
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main] # Run on pull requests targeting the main branch
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_and_test:
|
build:
|
||||||
name: Build and Test
|
name: Build and Lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read # For checkout
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
# Specify the Node.js versions you want to test against
|
node-version: [20.x]
|
||||||
node-version: [20.x] # You can add more like [18.x, 20.x]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# 1. Checkout Code
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# 2. Setup Node.js Environment
|
|
||||||
- name: Set up Node.js ${{ matrix.node-version }}
|
- name: Set up Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'npm' # Enable caching for npm dependencies (speeds up subsequent runs)
|
cache: 'npm'
|
||||||
|
|
||||||
# 3. Install Dependencies
|
|
||||||
# Use 'ci' for cleaner, faster, deterministic installs based on lockfile
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
# 4. Check Formatting
|
|
||||||
- name: Run formatter check
|
- name: Run formatter check
|
||||||
run: |
|
run: |
|
||||||
npm run format
|
npm run format
|
||||||
git diff --exit-code
|
git diff --exit-code
|
||||||
|
|
||||||
# 5. Linting
|
|
||||||
- name: Run linter
|
- name: Run linter
|
||||||
run: npm run lint
|
run: npm run lint
|
||||||
|
|
||||||
# 6. Type Checking
|
|
||||||
- name: Run type check
|
- name: Run type check
|
||||||
run: npm run typecheck
|
run: npm run typecheck
|
||||||
|
|
||||||
# 7. Build
|
|
||||||
# Optional if your tests run directly on TS files (e.g., using ts-jest, ts-node)
|
|
||||||
# But usually good practice to ensure the build itself works.
|
|
||||||
- name: Build project
|
- name: Build project
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
# 8. Testing
|
- name: Upload build artifacts
|
||||||
# Uncomment when we have tests.
|
uses: actions/upload-artifact@v4
|
||||||
#- name: Run tests
|
with:
|
||||||
# run: npm test
|
name: build-artifacts-${{ matrix.node-version }}
|
||||||
|
path: |
|
||||||
|
packages/*/dist
|
||||||
|
package-lock.json # Only upload dist and lockfile
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build # This job depends on the 'build' job
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
checks: write
|
||||||
|
pull-requests: write
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [20.x] # Should match the build job's matrix
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Node.js ${{ matrix.node-version }}
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
|
- name: Download build artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: build-artifacts-${{ matrix.node-version }}
|
||||||
|
path: . # Download to the root, this will include package-lock.json and packages/*/dist
|
||||||
|
|
||||||
|
# Restore/create package structure for dist folders if necessary.
|
||||||
|
# The download-artifact action with path: . should place them correctly if the
|
||||||
|
# upload paths were relative to the workspace root.
|
||||||
|
# Example: if uploaded `packages/cli/dist`, it will be at `./packages/cli/dist`.
|
||||||
|
|
||||||
|
- name: Install dependencies for testing
|
||||||
|
run: npm ci # Install fresh dependencies using the downloaded package-lock.json
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: npm run test:ci --workspaces --if-present
|
||||||
|
|
||||||
|
- name: Publish Test Report
|
||||||
|
uses: dorny/test-reporter@v1
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: Test Results (Node ${{ matrix.node-version }})
|
||||||
|
path: packages/*/junit.xml
|
||||||
|
reporter: java-junit
|
||||||
|
fail-on-error: 'false'
|
||||||
|
|
|
@ -24,3 +24,6 @@ dist
|
||||||
.docker
|
.docker
|
||||||
|
|
||||||
bundle
|
bundle
|
||||||
|
|
||||||
|
# Test report files
|
||||||
|
junit.xml
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
"lint": "eslint . --ext .ts,.tsx",
|
"lint": "eslint . --ext .ts,.tsx",
|
||||||
"typecheck": "tsc --noEmit --jsx react-jsx",
|
"typecheck": "tsc --noEmit --jsx react-jsx",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"preflight": "npm run format --workspaces --if-present && npm run lint --workspaces --if-present && npm run test --workspaces --if-present",
|
"preflight": "npm run format --workspaces --if-present && npm run lint && npm run test --workspaces --if-present",
|
||||||
"auth:npm": "npx google-artifactregistry-auth",
|
"auth:npm": "npx google-artifactregistry-auth",
|
||||||
"auth:docker": "gcloud auth configure-docker us-west1-docker.pkg.dev",
|
"auth:docker": "gcloud auth configure-docker us-west1-docker.pkg.dev",
|
||||||
"auth": "npm run auth:npm && npm run auth:docker",
|
"auth": "npm run auth:npm && npm run auth:docker",
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
"lint": "eslint . --ext .ts,.tsx",
|
"lint": "eslint . --ext .ts,.tsx",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
|
"test:ci": "vitest run --reporter=junit --outputFile=junit.xml",
|
||||||
"prerelease:version": "node ../../scripts/bind_package_version.js",
|
"prerelease:version": "node ../../scripts/bind_package_version.js",
|
||||||
"prerelease:deps": "node ../../scripts/bind_package_dependencies.js",
|
"prerelease:deps": "node ../../scripts/bind_package_dependencies.js",
|
||||||
"prepublishOnly": "npm publish --workspace=@gemini-code/server",
|
"prepublishOnly": "npm publish --workspace=@gemini-code/server",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"lint": "eslint . --ext .ts,.tsx",
|
"lint": "eslint . --ext .ts,.tsx",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
|
"test:ci": "vitest run --reporter=junit --outputFile=junit.xml",
|
||||||
"prerelease:version": "node ../../scripts/bind_package_version.js",
|
"prerelease:version": "node ../../scripts/bind_package_version.js",
|
||||||
"prerelease:deps": "node ../../scripts/bind_package_dependencies.js",
|
"prerelease:deps": "node ../../scripts/bind_package_dependencies.js",
|
||||||
"prepack": "npm run build"
|
"prepack": "npm run build"
|
||||||
|
|
Loading…
Reference in New Issue