Skip to content

Commit 0b8febc

Browse files
committed
feat: bootstrap Go module, storage interface, and markdown adapter
Pitch 01-01: initialize the brain Go module with storage interface, conformance test suite, markdown adapter, build scaffolding, and CI.
2 parents a9ebef4 + 3282ecf commit 0b8febc

15 files changed

Lines changed: 1211 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v5
17+
18+
- uses: actions/setup-go@v6
19+
with:
20+
go-version-file: go.mod
21+
22+
- name: Build
23+
run: go build -v ./...
24+
25+
- name: Test
26+
run: go test -v ./...
27+
28+
lint:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v5
32+
33+
- uses: actions/setup-go@v6
34+
with:
35+
go-version-file: go.mod
36+
37+
- name: golangci-lint
38+
uses: golangci/golangci-lint-action@v9
39+
with:
40+
version: latest

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
env:
12+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v5
19+
with:
20+
fetch-depth: 0
21+
22+
- uses: actions/setup-go@v6
23+
with:
24+
go-version-file: go.mod
25+
26+
- uses: goreleaser/goreleaser-action@v7
27+
with:
28+
version: '~> v2'
29+
args: release --clean
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Thumbs.db
3737
# Build artifacts
3838
/brain
3939
/bin/
40+
/dist/
4041
/cmd/brain/brain
4142
*.exe
4243
*.test

.golangci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: "2"
2+
3+
linters:
4+
enable:
5+
- errcheck
6+
- staticcheck

.goreleaser.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version: 2
2+
3+
builds:
4+
- id: brain
5+
main: ./cmd/brain
6+
binary: brain
7+
flags:
8+
- -trimpath
9+
env:
10+
- CGO_ENABLED=0
11+
ldflags:
12+
- -s -w
13+
- -X github.com/luuuc/brain/internal/version.Version={{.Version}}
14+
goos:
15+
- darwin
16+
- linux
17+
goarch:
18+
- amd64
19+
- arm64
20+
21+
archives:
22+
- id: brain
23+
ids: [brain]
24+
formats: [tar.gz]
25+
name_template: "brain_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
26+
27+
checksum:
28+
name_template: "brain_{{ .Version }}_checksums.txt"
29+
30+
changelog:
31+
use: github
32+
sort: asc
33+
filters:
34+
exclude:
35+
- "^docs:"
36+
- "^chore:"
37+
- "^ci:"
38+
- "^test:"
39+
- "^refactor:"
40+
41+
release:
42+
github:
43+
owner: luuuc
44+
name: brain
45+
prerelease: auto
46+
make_latest: true

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.PHONY: build test clean install lint ci run
2+
3+
VERSION ?= dev
4+
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
5+
LDFLAGS := -ldflags="-s -w -X 'github.com/luuuc/brain/internal/version.Version=$(VERSION)'"
6+
7+
build:
8+
go build $(LDFLAGS) -trimpath -o bin/brain ./cmd/brain
9+
10+
test:
11+
go test -v ./...
12+
13+
clean:
14+
rm -rf bin/ dist/
15+
16+
install: build
17+
cp bin/brain /usr/local/bin/brain
18+
19+
lint:
20+
@command -v golangci-lint >/dev/null 2>&1 || \
21+
(echo "Installing golangci-lint..." && go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest)
22+
@PATH="$$PATH:$$(go env GOPATH)/bin" golangci-lint run
23+
24+
ci: build test lint
25+
@echo "All CI checks passed!"
26+
27+
run:
28+
go run ./cmd/brain $(ARGS)

cmd/brain/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/luuuc/brain/internal/version"
7+
)
8+
9+
func main() {
10+
fmt.Printf("brain %s\n", version.Version)
11+
}

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/luuuc/brain
2+
3+
go 1.25.5
4+
5+
require gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
3+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)