Skip to content

Commit a8ff2c9

Browse files
authored
chore: add make lint target (#108)
1 parent 1d22425 commit a8ff2c9

File tree

4 files changed

+124
-92
lines changed

4 files changed

+124
-92
lines changed

.github/workflows/go-test.yml

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
11
name: Go Tests
22

33
on:
4-
push:
5-
branches: [main]
6-
pull_request:
4+
push:
5+
branches: [main]
6+
pull_request:
77

88
jobs:
9-
test:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: actions/checkout@v4
13-
14-
- name: Set up Go
15-
uses: actions/setup-go@v5
16-
with:
17-
go-version: "stable"
18-
19-
- name: Test
20-
run: CGO_ENABLED=0 go test -count=1 -v ./...
21-
22-
lint:
23-
runs-on: ubuntu-latest
24-
steps:
25-
- uses: actions/checkout@v4
26-
27-
- name: Set up Go
28-
uses: actions/setup-go@v5
29-
with:
30-
go-version: "stable"
31-
32-
- name: golangci-lint
33-
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
34-
with:
35-
version: v2.1
36-
37-
- name: Check for unstaged changes
38-
run: |
39-
make gen
40-
./check_unstaged.sh
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up Go
15+
uses: actions/setup-go@v5
16+
with:
17+
go-version: "stable"
18+
19+
- name: Test
20+
run: CGO_ENABLED=0 go test -count=1 -v ./...
21+
22+
lint:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Set up Go
28+
uses: actions/setup-go@v5
29+
with:
30+
go-version: "stable"
31+
32+
- name: Set up Bun
33+
uses: oven-sh/setup-bun@v2
34+
35+
- name: Install Chat Dependencies
36+
run: cd chat && bun install
37+
38+
- name: run linters
39+
run: make lint
40+
41+
- name: Check for unstaged changes
42+
run: |
43+
make gen
44+
./check_unstaged.sh
Lines changed: 56 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,69 @@
11
name: PR Preview Release
22

33
on:
4-
workflow_run:
5-
workflows: ["PR Preview Build"]
6-
types:
7-
- completed
4+
workflow_run:
5+
workflows: ["PR Preview Build"]
6+
types:
7+
- completed
88

99
permissions:
10-
contents: write
11-
pull-requests: write
10+
contents: write
11+
pull-requests: write
1212

1313
jobs:
14-
release:
15-
name: Create Release
16-
runs-on: ubuntu-latest
17-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
14+
release:
15+
name: Create Release
16+
runs-on: ubuntu-latest
17+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1818

19-
steps:
20-
- name: Download PR number
21-
uses: actions/download-artifact@v4
22-
with:
23-
name: pr-number
24-
github-token: ${{ secrets.GITHUB_TOKEN }}
25-
run-id: ${{ github.event.workflow_run.id }}
19+
steps:
20+
- name: Download PR number
21+
uses: actions/download-artifact@v4
22+
with:
23+
name: pr-number
24+
github-token: ${{ secrets.GITHUB_TOKEN }}
25+
run-id: ${{ github.event.workflow_run.id }}
2626

27-
- name: Read PR number
28-
id: pr
29-
run: echo "number=$(cat number)" >> $GITHUB_OUTPUT
27+
- name: Read PR number
28+
id: pr
29+
run: echo "number=$(cat number)" >> "${GITHUB_OUTPUT}"
3030

31-
- name: Download Build Artifacts
32-
uses: actions/download-artifact@v4
33-
with:
34-
name: agentapi-build-${{ steps.pr.outputs.number }}
35-
path: ./out
36-
github-token: ${{ secrets.GITHUB_TOKEN }}
37-
run-id: ${{ github.event.workflow_run.id }}
31+
- name: Download Build Artifacts
32+
uses: actions/download-artifact@v4
33+
with:
34+
name: agentapi-build-${{ steps.pr.outputs.number }}
35+
path: ./out
36+
github-token: ${{ secrets.GITHUB_TOKEN }}
37+
run-id: ${{ github.event.workflow_run.id }}
3838

39+
- name: Create or Update PR Release
40+
env:
41+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
RELEASE_TAG: "agentapi_${{ steps.pr.outputs.number }}"
43+
PR_NUMBER: ${{ steps.pr.outputs.number }}
3944

40-
- name: Create or Update PR Release
41-
env:
42-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43-
RELEASE_TAG: 'agentapi_${{ steps.pr.outputs.number }}'
44-
PR_NUMBER: ${{ steps.pr.outputs.number }}
45+
run: |
46+
# Check if release exists
47+
if gh release view "$RELEASE_TAG" --repo ${{ github.repository }} &>/dev/null; then
48+
echo "Updating release $RELEASE_TAG"
49+
gh release upload "$RELEASE_TAG" ./out/* --clobber --repo ${{ github.repository }}
50+
else
51+
echo "Creating release $RELEASE_TAG"
52+
gh release create "$RELEASE_TAG" ./out/* \
53+
--title "$RELEASE_TAG" \
54+
--notes "Preview release for PR #${PR_NUMBER}" \
55+
--repo ${{ github.repository }}
56+
fi
4557
46-
run: |
47-
# Check if release exists
48-
if gh release view "$RELEASE_TAG" --repo ${{ github.repository }} &>/dev/null; then
49-
echo "Updating release $RELEASE_TAG"
50-
gh release upload "$RELEASE_TAG" ./out/* --clobber --repo ${{ github.repository }}
51-
else
52-
echo "Creating release $RELEASE_TAG"
53-
gh release create "$RELEASE_TAG" ./out/* \
54-
--title "$RELEASE_TAG" \
55-
--notes "Preview release for PR #${PR_NUMBER}" \
56-
--repo ${{ github.repository }}
57-
fi
58-
59-
- name: Comment on PR
60-
uses: actions/github-script@v7
61-
with:
62-
script: |
63-
const prNumber = ${{ steps.pr.outputs.number }};
64-
const releaseTag = `agentapi_${prNumber}`;
65-
github.rest.issues.createComment({
66-
issue_number: prNumber,
67-
owner: context.repo.owner,
68-
repo: context.repo.repo,
69-
body: `✅ Preview binaries are ready!\n\nTo test with modules: \`\`\`agentapi: ${prNumber}\`\`\` or download from: ${repoUrl}/releases/tag/${releaseTag}`
70-
});
58+
- name: Comment on PR
59+
uses: actions/github-script@v7
60+
with:
61+
script: |
62+
const prNumber = ${{ steps.pr.outputs.number }};
63+
const releaseTag = `agentapi_${prNumber}`;
64+
github.rest.issues.createComment({
65+
issue_number: prNumber,
66+
owner: context.repo.owner,
67+
repo: context.repo.repo,
68+
body: `✅ Preview binaries are ready!\n\nTo test with modules: \`\`\`agentapi: ${prNumber}\`\`\` or download from: ${repoUrl}/releases/tag/${releaseTag}`
69+
});

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ CHAT_SOURCES = $(shell find chat \( -path chat/node_modules -o -path chat/out -o
33
BINPATH ?= out/agentapi
44
# This must be kept in sync with the magicBasePath in lib/httpapi/embed.go.
55
BASE_PATH ?= /magic-base-path-placeholder
6+
FIND_EXCLUSIONS= \
7+
-not \( \( -path '*/.git/*' -o -path './out/*' -o -path '*/node_modules/*' -o -path '*/.terraform/*' \) -prune \)
8+
SHELL_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS) -type f -name '*.sh')
69

710
$(CHAT_SOURCES_STAMP): $(CHAT_SOURCES)
811
@echo "Chat sources changed. Running build steps..."
@@ -22,3 +25,24 @@ build: embed
2225
.PHONY: gen
2326
gen:
2427
go generate ./...
28+
29+
lint: lint/shellcheck lint/go lint/ts lint/actions/actionlint
30+
.PHONY: lint
31+
32+
lint/go:
33+
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.5.0 run
34+
go run github.com/coder/paralleltestctx/cmd/paralleltestctx@v0.0.1 ./...
35+
.PHONY: lint/go
36+
37+
lint/shellcheck: $(SHELL_SRC_FILES)
38+
echo "--- shellcheck"
39+
shellcheck --external-sources $(SHELL_SRC_FILES)
40+
.PHONY: lint/shellcheck
41+
42+
lint/ts:
43+
cd ./chat && bun lint
44+
.PHONY: lint/ts
45+
46+
lint/actions/actionlint:
47+
go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.7 --config-file actionlint.yaml
48+
.PHONY: lint/actions/actionlint

actionlint.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Configuration related to self-hosted runner.
2+
self-hosted-runner:
3+
# Labels of self-hosted runner in array of strings.
4+
labels:
5+
- depot-ubuntu-22.04-4

0 commit comments

Comments
 (0)