Fix --clone flag not working when starting workspace (#34) #150
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Cache bun dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| web/node_modules | |
| key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock', '**/package.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-bun- | |
| - name: Install dependencies | |
| run: | | |
| bun install | |
| cd web && bun install | |
| - name: Lint | |
| run: bun run lint | |
| - name: Format check | |
| run: bun run format:check | |
| - name: Typecheck | |
| run: bun x tsc --noEmit | |
| - name: Lint web | |
| run: bun run lint:web | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Cache bun dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| web/node_modules | |
| key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock', '**/package.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-bun- | |
| - name: Install dependencies | |
| run: | | |
| bun install | |
| cd web && bun install | |
| - name: Build | |
| run: bun run build | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| retention-days: 1 | |
| binary: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Set up Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Compile binary | |
| run: | | |
| bun build ./src/index.ts --compile --minify --outfile=perry-test | |
| - name: Test binary runs | |
| run: | | |
| ./perry-test --version | |
| ./perry-test --help | |
| - name: Test binary with web assets | |
| run: | | |
| mkdir -p test-install/bin | |
| cp perry-test test-install/bin/perry | |
| cp -r dist/agent/web test-install/ | |
| ./test-install/bin/perry --version | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Set up Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Cache bun dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| web/node_modules | |
| key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock', '**/package.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-bun- | |
| - name: Install dependencies | |
| run: | | |
| bun install | |
| cd web && bun install | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check for Dockerfile changes | |
| id: docker-changes | |
| run: | | |
| # For PRs, compare against base branch | |
| # For pushes, compare against previous commit | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| BASE_SHA="${{ github.event.pull_request.base.sha }}" | |
| else | |
| BASE_SHA="${{ github.event.before }}" | |
| fi | |
| # Check if any files in perry/ directory changed | |
| if git diff --name-only "$BASE_SHA" HEAD 2>/dev/null | grep -q "^perry/"; then | |
| echo "Dockerfile or related files changed - will rebuild and update cache" | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "No Dockerfile changes detected - using cached layers" | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Build workspace image (with cache) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./perry | |
| load: true | |
| tags: perry:latest | |
| cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-test | |
| cache-to: ${{ steps.docker-changes.outputs.changed == 'true' && format('type=registry,ref={0}/{1}:buildcache-test,mode=max', env.REGISTRY, env.IMAGE_NAME) || '' }} | |
| - name: Run tests | |
| run: | | |
| # Skip Docker build in test setup since we already have the image | |
| export SKIP_DOCKER_BUILD=true | |
| bun run test | |
| e2e: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Set up Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Cache bun dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.bun/install/cache | |
| node_modules | |
| web/node_modules | |
| key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock', '**/package.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-bun- | |
| - name: Install dependencies | |
| run: | | |
| bun install | |
| cd web && bun install | |
| - name: Install Playwright browsers | |
| run: cd web && bun x playwright install chromium --with-deps | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check for Dockerfile changes | |
| id: docker-changes | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| BASE_SHA="${{ github.event.pull_request.base.sha }}" | |
| else | |
| BASE_SHA="${{ github.event.before }}" | |
| fi | |
| if git diff --name-only "$BASE_SHA" HEAD 2>/dev/null | grep -q "^perry/"; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Build workspace image (with cache) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./perry | |
| load: true | |
| tags: perry:latest | |
| cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-test | |
| cache-to: ${{ steps.docker-changes.outputs.changed == 'true' && format('type=registry,ref={0}/{1}:buildcache-test,mode=max', env.REGISTRY, env.IMAGE_NAME) || '' }} | |
| - name: Start agent | |
| run: | | |
| bun run src/index.ts agent run --port 7391 & | |
| sleep 5 | |
| curl -s http://localhost:7391/health || (echo "Agent failed to start" && exit 1) | |
| - name: Create test workspace | |
| run: | | |
| bun run src/index.ts start test | |
| bun run src/index.ts list | |
| - name: Run Playwright tests | |
| run: | | |
| cd web && bun run test:e2e --grep-invert "OpenCode" | |
| env: | |
| CI: true | |
| - name: Upload Playwright report | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ !cancelled() }} | |
| with: | |
| name: playwright-report | |
| path: web/playwright-report/ | |
| retention-days: 7 |