Skip to content

feat: add scripts for bumping and publishing dev versions, update CI/… #2

feat: add scripts for bumping and publishing dev versions, update CI/…

feat: add scripts for bumping and publishing dev versions, update CI/… #2

name: VSCode Automation Pipeline
on:
push:
branches: [ main, develop ]
paths:
- 'packages/ai/**'
- 'docker/vscode-automation/**'
- 'Dockerfile.vscode-automation'
- '.github/workflows/vscode-automation.yml'
- '.github/scripts/build-vscode-automation.sh'
pull_request:
branches: [ main ]
paths:
- 'packages/ai/**'
- 'docker/vscode-automation/**'
- 'Dockerfile.vscode-automation'
- '.github/workflows/vscode-automation.yml'
- '.github/scripts/build-vscode-automation.sh'
workflow_dispatch:
inputs:
automation_mode:
description: 'Automation test mode'
required: false
default: 'automated'
type: choice
options:
- automated
- interactive
test_scenarios:
description: 'Test scenarios to run (comma-separated: python,javascript,typescript or leave empty for all)'
required: false
type: string
log_level:
description: 'Log level for automation tests'
required: false
default: 'info'
type: choice
options:
- debug
- info
- warn
- error
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-vscode-automation
jobs:
# Phase 1: Build AI Package and Dependencies
build-ai-package:
name: Build AI Package
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-key.outputs.key }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.13.1
run_install: false
- name: Generate cache key
id: cache-key
run: |
echo "key=${{ runner.os }}-pnpm-ai-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.sha }}" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ steps.cache-key.outputs.key }}
restore-keys: |
${{ runner.os }}-pnpm-ai-${{ hashFiles('**/pnpm-lock.yaml') }}-
${{ runner.os }}-pnpm-ai-
- name: Install dependencies
run: |
pnpm install --frozen-lockfile
- name: Build core package (dependency)
run: |
echo "🔨 Building @codervisor/devlog-core..."
pnpm --filter @codervisor/devlog-core build
- name: Build AI package
run: |
echo "🔨 Building @codervisor/devlog-ai..."
pnpm --filter @codervisor/devlog-ai build
- name: Cache build artifacts
uses: actions/cache@v4
with:
path: |
packages/core/build
packages/ai/build
key: ai-build-${{ github.sha }}
- name: Verify AI package build
run: |
echo "✅ Verifying AI package build artifacts..."
ls -la packages/ai/build/
ls -la packages/ai/build/automation/
if [ ! -f "packages/ai/build/automation/index.js" ]; then
echo "❌ Missing automation build artifacts"
exit 1
fi
echo "✅ AI package build verification passed"
# Phase 2: Build VSCode Automation Docker Image
build-vscode-automation:
name: Build VSCode Automation Image
runs-on: ubuntu-latest
needs: build-ai-package
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Restore build artifacts
uses: actions/cache@v4
with:
path: |
packages/core/build
packages/ai/build
key: ai-build-${{ github.sha }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.vscode-automation
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=vscode-automation
cache-to: type=gha,mode=max,scope=vscode-automation
platforms: linux/amd64,linux/arm64
build-args: |
BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
VCS_REF=${{ github.sha }}
- name: Basic image test
if: github.event_name != 'pull_request'
run: |
# Get the first tag for testing
IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1)
echo "🧪 Testing VSCode automation container: $IMAGE_TAG"
# Basic container startup test
docker run --rm \
-e AUTOMATION_MODE=test \
-e LOG_LEVEL=debug \
"$IMAGE_TAG" shell -c "echo 'Container startup test passed'"
# Phase 3: Run Automation Tests
run-automation-tests:
name: VSCode Automation Tests
runs-on: ubuntu-latest
needs: build-vscode-automation
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: read
strategy:
matrix:
scenario: [python-algorithms, javascript-api, typescript-utils]
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup test environment
run: |
# Create results directory
mkdir -p automation-results/${{ matrix.scenario }}
# Set test parameters
AUTOMATION_MODE="${{ github.event.inputs.automation_mode || 'automated' }}"
LOG_LEVEL="${{ github.event.inputs.log_level || 'info' }}"
TEST_SCENARIOS="${{ github.event.inputs.test_scenarios || matrix.scenario }}"
echo "AUTOMATION_MODE=$AUTOMATION_MODE" >> $GITHUB_ENV
echo "LOG_LEVEL=$LOG_LEVEL" >> $GITHUB_ENV
echo "TEST_SCENARIOS=$TEST_SCENARIOS" >> $GITHUB_ENV
- name: Run automation test for ${{ matrix.scenario }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Pull the VSCode automation image
IMAGE_NAME="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}"
docker pull "$IMAGE_NAME"
echo "🤖 Running automation test for scenario: ${{ matrix.scenario }}"
# Run automation tests with timeout
timeout 1800 docker run --rm \
-v "$(pwd)/automation-results/${{ matrix.scenario }}:/logs" \
-e GITHUB_TOKEN="$GITHUB_TOKEN" \
-e AUTOMATION_MODE="$AUTOMATION_MODE" \
-e LOG_LEVEL="$LOG_LEVEL" \
-e TEST_SCENARIO="${{ matrix.scenario }}" \
-e TIMEOUT=1500 \
--name "automation-${{ matrix.scenario }}-${{ github.run_id }}" \
"$IMAGE_NAME" test || echo "Test completed with timeout or error"
echo "✅ Automation test for ${{ matrix.scenario }} completed"
- name: Process test results for ${{ matrix.scenario }}
if: always()
run: |
RESULTS_DIR="automation-results/${{ matrix.scenario }}"
# Check if results exist
if [ -f "$RESULTS_DIR/automation-results.json" ]; then
echo "📊 Processing results for ${{ matrix.scenario }}"
# Extract key metrics
SUCCESS_RATE=$(jq -r '.summary.overallSuccessRate // 0' "$RESULTS_DIR/automation-results.json")
TOTAL_INTERACTIONS=$(jq -r '.summary.totalInteractions // 0' "$RESULTS_DIR/automation-results.json")
echo "SUCCESS_RATE_${{ matrix.scenario }}=$SUCCESS_RATE" >> $GITHUB_ENV
echo "TOTAL_INTERACTIONS_${{ matrix.scenario }}=$TOTAL_INTERACTIONS" >> $GITHUB_ENV
# Create summary for this scenario
echo "## 🤖 Automation Results: ${{ matrix.scenario }}" >> automation-results/${{ matrix.scenario }}/summary.md
echo "- **Success Rate**: ${SUCCESS_RATE}%" >> automation-results/${{ matrix.scenario }}/summary.md
echo "- **Total Interactions**: $TOTAL_INTERACTIONS" >> automation-results/${{ matrix.scenario }}/summary.md
echo "- **Timestamp**: $(date -u)" >> automation-results/${{ matrix.scenario }}/summary.md
else
echo "⚠️ No results file found for ${{ matrix.scenario }}"
echo "SUCCESS_RATE_${{ matrix.scenario }}=0" >> $GITHUB_ENV
echo "TOTAL_INTERACTIONS_${{ matrix.scenario }}=0" >> $GITHUB_ENV
fi
- name: Upload automation results for ${{ matrix.scenario }}
uses: actions/upload-artifact@v4
if: always()
with:
name: vscode-automation-results-${{ matrix.scenario }}
path: automation-results/${{ matrix.scenario }}/
retention-days: 30
# Phase 4: Aggregate Results and Summary
automation-summary:
name: Automation Test Summary
runs-on: ubuntu-latest
needs: run-automation-tests
if: always() && github.event_name != 'pull_request'
steps:
- name: Download all automation results
uses: actions/download-artifact@v4
with:
pattern: vscode-automation-results-*
path: all-results/
- name: Generate comprehensive summary
run: |
echo "## 🤖 VSCode Automation Pipeline Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Pipeline Trigger:** ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
echo "**Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "**Timestamp:** $(date -u)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Check if we have results
if [ -d "all-results" ]; then
echo "### 📊 Test Scenarios Results:" >> $GITHUB_STEP_SUMMARY
for scenario_dir in all-results/vscode-automation-results-*/; do
if [ -d "$scenario_dir" ]; then
scenario_name=$(basename "$scenario_dir" | sed 's/vscode-automation-results-//')
echo "#### $scenario_name" >> $GITHUB_STEP_SUMMARY
if [ -f "$scenario_dir/summary.md" ]; then
cat "$scenario_dir/summary.md" >> $GITHUB_STEP_SUMMARY
else
echo "- ⚠️ No summary available" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
fi
done
echo "### 📋 Detailed Results" >> $GITHUB_STEP_SUMMARY
echo "Detailed results are available in the uploaded artifacts." >> $GITHUB_STEP_SUMMARY
else
echo "### ⚠️ No Results Available" >> $GITHUB_STEP_SUMMARY
echo "No automation test results were generated." >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "---" >> $GITHUB_STEP_SUMMARY
echo "**Image:** \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
# Phase 5: Security Scan
security-scan:
name: Security Scan VSCode Automation
runs-on: ubuntu-latest
needs: build-vscode-automation
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: read
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
format: 'sarif'
output: 'trivy-results-vscode-automation.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-results-vscode-automation.sarif'