diff --git a/.github/workflows/check-openapi.yml b/.github/workflows/check-openapi.yml new file mode 100644 index 0000000..94a5833 --- /dev/null +++ b/.github/workflows/check-openapi.yml @@ -0,0 +1,37 @@ +name: Check OpenAPI Schema + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + check-openapi: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 'stable' + + - name: Generate OpenAPI schema + run: go run main.go server --print-openapi dummy > generated-openapi.json + + - name: Check OpenAPI schema + run: | + if [ ! -f "openapi.json" ]; then + echo "::warning::openapi.json does not exist" + exit 1 + fi + + # Compare schemas + if ! cmp -s openapi.json generated-openapi.json; then + echo "::error::The openapi.json file is out of sync with the generated schema" + echo "Diff:" + diff -u openapi.json generated-openapi.json || true + exit 1 + fi + echo "OpenAPI schema is up to date" \ No newline at end of file diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index cff7839..e22a70a 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -1,44 +1,21 @@ name: Go Tests on: - push: - branches: [main] - pull_request: + push: + branches: [ main ] + pull_request: + branches: [ main ] jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: "stable" - - - name: Test - run: CGO_ENABLED=0 go test -count=1 -v ./... - - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: "stable" - - - name: Set up Bun - uses: oven-sh/setup-bun@v2 - - - name: Install Chat Dependencies - run: cd chat && bun install - - - name: run linters - run: make lint - - - name: Check for unstaged changes - run: | - make gen - ./check_unstaged.sh + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 'stable' + + - name: Test + run: go test -count=1 -v ./... \ No newline at end of file diff --git a/.github/workflows/pr-preview-build.yml b/.github/workflows/pr-preview-build.yml deleted file mode 100644 index e3eb92d..0000000 --- a/.github/workflows/pr-preview-build.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: PR Preview Build - -on: - pull_request: - -jobs: - build: - name: Build Release Binaries - runs-on: depot-ubuntu-22.04-4 - permissions: - contents: write - - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 'stable' - - - name: Set up Bun - uses: oven-sh/setup-bun@v2 - - - name: Install Chat Dependencies - run: cd chat && bun install - - - name: Run make gen and check for unstaged changes - run: | - make gen - ./check_unstaged.sh - - - name: Build - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - shell: bash - run: | - build_variants=( - "linux amd64 agentapi-linux-amd64" - "linux arm64 agentapi-linux-arm64" - "darwin amd64 agentapi-darwin-amd64" - "darwin arm64 agentapi-darwin-arm64" - "windows amd64 agentapi-windows-amd64.exe" - ) - - for variant in "${build_variants[@]}"; do - read -r goos goarch artifact_name <<< "$variant" - - echo "Building for GOOS=$goos GOARCH=$goarch..." - CGO_ENABLED=0 GOOS=$goos GOARCH=$goarch BINPATH="out/$artifact_name" make build - done - - - name: Upload Build Artifact - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: agentapi-build-${{ github.event.pull_request.number }} - path: ${{ github.workspace }}/out - retention-days: 7 - - - name: Save PR number - run: | - mkdir -p ./pr - echo ${{ github.event.pull_request.number }} > ./pr/number - - - name: Upload PR number - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 - with: - name: pr-number - path: pr/ \ No newline at end of file diff --git a/.github/workflows/pr-preview-cleanup.yml b/.github/workflows/pr-preview-cleanup.yml deleted file mode 100644 index ba7ced5..0000000 --- a/.github/workflows/pr-preview-cleanup.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: PR Preview Cleanup - -on: - pull_request: - types: [closed] - -permissions: - contents: write - -jobs: - cleanup: - name: Delete PR Release - runs-on: ubuntu-latest - - steps: - - name: Delete PR Release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_TAG: 'agentapi_${{ github.event.pull_request.number }}' - run: | - gh release delete "$RELEASE_TAG" --cleanup-tag --yes --repo ${{ github.repository }} || true \ No newline at end of file diff --git a/.github/workflows/pr-preview-release.yml b/.github/workflows/pr-preview-release.yml deleted file mode 100644 index 898e913..0000000 --- a/.github/workflows/pr-preview-release.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: PR Preview Release - -on: - workflow_run: - workflows: ["PR Preview Build"] - types: - - completed - -permissions: - contents: write - pull-requests: write - -jobs: - release: - name: Create Release - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - - steps: - - name: Download PR number - uses: actions/download-artifact@v4 - with: - name: pr-number - github-token: ${{ secrets.GITHUB_TOKEN }} - run-id: ${{ github.event.workflow_run.id }} - - - name: Read PR number - id: pr - run: echo "number=$(cat number)" >> "${GITHUB_OUTPUT}" - - - name: Download Build Artifacts - uses: actions/download-artifact@v4 - with: - name: agentapi-build-${{ steps.pr.outputs.number }} - path: ./out - github-token: ${{ secrets.GITHUB_TOKEN }} - run-id: ${{ github.event.workflow_run.id }} - - - name: Create or Update PR Release - id: release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_TAG: "agentapi_${{ steps.pr.outputs.number }}" - PR_NUMBER: ${{ steps.pr.outputs.number }} - run: | - # Check if release exists - if gh release view "$RELEASE_TAG" --repo ${{ github.repository }} &>/dev/null; then - echo "Updating release $RELEASE_TAG" - gh release upload "$RELEASE_TAG" ./out/* --clobber --repo ${{ github.repository }} - echo "should_comment=false" >> "${GITHUB_OUTPUT}" - else - echo "Creating release $RELEASE_TAG" - gh release create "$RELEASE_TAG" ./out/* \ - --title "$RELEASE_TAG" \ - --notes "Preview release for PR #${PR_NUMBER}" \ - --repo ${{ github.repository }} \ - --latest=false \ - --prerelease - echo "should_comment=true" >> "${GITHUB_OUTPUT}" - fi - - - name: Comment on PR - if: steps.release.outputs.should_comment == 'true' - uses: actions/github-script@v7 - with: - script: | - const prNumber = ${{ steps.pr.outputs.number }}; - const releaseTag = `agentapi_${prNumber}`; - const repoUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}`; - github.rest.issues.createComment({ - issue_number: prNumber, - owner: context.repo.owner, - repo: context.repo.repo, - body: `✅ Preview binaries are ready!\n\nTo test with modules: \`\`\`agentapi_version = "agentapi_${prNumber}"\`\`\` or download from: ${repoUrl}/releases/tag/${releaseTag}` - }); diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 10e2ba2..2a8a9e8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,22 +2,35 @@ name: Build Release Binaries on: release: - types: [published] - push: - branches: [ main ] - workflow_dispatch: - inputs: - create-artifact: - description: 'Create build artifact' - required: true - type: boolean - default: false + types: [created, published, edited] jobs: build: - name: Build Release Binaries - runs-on: depot-ubuntu-22.04-4 - if: ${{ github.repository_owner == 'coder' }} + name: Build for ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + artifact_name: agentapi + asset_name: agentapi-linux-amd64 + goarch: amd64 + goos: linux + - os: macos-latest + artifact_name: agentapi + asset_name: agentapi-darwin-amd64 + goarch: amd64 + goos: darwin + - os: macos-latest + artifact_name: agentapi + asset_name: agentapi-darwin-arm64 + goarch: arm64 + goos: darwin + - os: windows-latest + artifact_name: agentapi.exe + asset_name: agentapi-windows-amd64.exe + goarch: amd64 + goos: windows steps: - uses: actions/checkout@v4 @@ -27,48 +40,18 @@ jobs: with: go-version: 'stable' - - name: Set up Bun - uses: oven-sh/setup-bun@v2 - - - name: Install Chat Dependencies - run: cd chat && bun install - - - name: Run make gen and check for unstaged changes - run: | - make gen - ./check_unstaged.sh + - name: Build + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + run: go build -v -o ${{ matrix.artifact_name }} . - - name: Build and Upload + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - shell: bash - run: | - build_variants=( - "linux amd64 agentapi-linux-amd64" - "linux arm64 agentapi-linux-arm64" - "darwin amd64 agentapi-darwin-amd64" - "darwin arm64 agentapi-darwin-arm64" - "windows amd64 agentapi-windows-amd64.exe" - ) - - for variant in "${build_variants[@]}"; do - read -r goos goarch artifact_name <<< "$variant" - - echo "Building for GOOS=$goos GOARCH=$goarch..." - CGO_ENABLED=0 GOOS=$goos GOARCH=$goarch BINPATH="out/$artifact_name" make build - done - - - name: Upload Build Artifact - if: ${{ inputs.create-artifact }} - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: - name: agentapi-build - path: ${{ github.workspace }}/out - retention-days: 7 - - - name: Upload Release Assets - if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/main' }} - run: gh release upload "$RELEASE_TAG" "$GITHUB_WORKSPACE"/out/* --clobber - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || 'preview' }} + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./${{ matrix.artifact_name }} + asset_name: ${{ matrix.asset_name }} + asset_content_type: application/octet-stream \ No newline at end of file diff --git a/.gitignore b/.gitignore index dee2827..566bb3b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,4 @@ output-*.log snapshot-*.log snapshot2-*.log .aider* -schema.yaml -**/.claude/settings.local.json -out - - -#IDEs -.idea \ No newline at end of file +schema.yaml \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml deleted file mode 100644 index b89afc4..0000000 --- a/.golangci.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: "2" -linters: - enable: - - exhaustive - settings: - exhaustive: - check: - - "switch" - - "map" - staticcheck: - checks: - - "-QF1001" # disable "could apply De Morgan's law" diff --git a/lib/httpapi/chat/marker b/.nojekyll similarity index 100% rename from lib/httpapi/chat/marker rename to .nojekyll diff --git a/.vscode/settings.json b/.vscode/settings.json index 14cb7f6..ebfde9a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,3 @@ { "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode", - "[go]": { - "editor.defaultFormatter": "golang.go" - } } \ No newline at end of file diff --git a/404.html b/404.html new file mode 100644 index 0000000..d2b9ee6 --- /dev/null +++ b/404.html @@ -0,0 +1 @@ +