Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 39 additions & 35 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
name: Go Tests

on:
push:
branches: [main]
pull_request:
push:
branches: [main]
pull_request:

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: golangci-lint
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
with:
version: v2.1

- 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: 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
113 changes: 56 additions & 57 deletions .github/workflows/pr-preview-release.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,69 @@
name: PR Preview Release

on:
workflow_run:
workflows: ["PR Preview Build"]
types:
- completed
workflow_run:
workflows: ["PR Preview Build"]
types:
- completed

permissions:
contents: write
pull-requests: write
contents: write
pull-requests: write

jobs:
release:
name: Create Release
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
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 }}
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: 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: 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
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: "agentapi_${{ steps.pr.outputs.number }}"
PR_NUMBER: ${{ steps.pr.outputs.number }}

- name: Create or Update PR 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 }}
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 }}
fi

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 }}
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 }}
fi

- name: Comment on PR
uses: actions/github-script@v7
with:
script: |
const prNumber = ${{ steps.pr.outputs.number }};
const releaseTag = `agentapi_${prNumber}`;
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: ${prNumber}\`\`\` or download from: ${repoUrl}/releases/tag/${releaseTag}`
});
- name: Comment on PR
uses: actions/github-script@v7
with:
script: |
const prNumber = ${{ steps.pr.outputs.number }};
const releaseTag = `agentapi_${prNumber}`;
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: ${prNumber}\`\`\` or download from: ${repoUrl}/releases/tag/${releaseTag}`
});
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ CHAT_SOURCES = $(shell find chat \( -path chat/node_modules -o -path chat/out -o
BINPATH ?= out/agentapi
# This must be kept in sync with the magicBasePath in lib/httpapi/embed.go.
BASE_PATH ?= /magic-base-path-placeholder
FIND_EXCLUSIONS= \
-not \( \( -path '*/.git/*' -o -path './out/*' -o -path '*/node_modules/*' -o -path '*/.terraform/*' \) -prune \)
SHELL_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.sh')

$(CHAT_SOURCES_STAMP): $(CHAT_SOURCES)
@echo "Chat sources changed. Running build steps..."
Expand All @@ -22,3 +25,24 @@ build: embed
.PHONY: gen
gen:
go generate ./...

lint: lint/shellcheck lint/go lint/ts lint/actions/actionlint
.PHONY: lint

lint/go:
go run github.com/golangci/golangci-lint/v2/cmd/[email protected] run
go run github.com/coder/paralleltestctx/cmd/[email protected] ./...
.PHONY: lint/go

lint/shellcheck: $(SHELL_SRC_FILES)
echo "--- shellcheck"
shellcheck --external-sources $(SHELL_SRC_FILES)
.PHONY: lint/shellcheck

lint/ts:
cd ./chat && bun lint
.PHONY: lint/ts

lint/actions/actionlint:
go run github.com/rhysd/actionlint/cmd/[email protected] --config-file actionlint.yaml
.PHONY: lint/actions/actionlint
5 changes: 5 additions & 0 deletions actionlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Configuration related to self-hosted runner.
self-hosted-runner:
# Labels of self-hosted runner in array of strings.
labels:
- depot-ubuntu-22.04-4