Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: Sertac Ozercan <[email protected]>
  • Loading branch information
sozercan committed Nov 22, 2023
1 parent 58a700f commit cf61e43
Show file tree
Hide file tree
Showing 25 changed files with 1,253 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
30 changes: 30 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: lint

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
branches:
- main
paths-ignore:
- '**.md'

permissions: read-all

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.55.2
30 changes: 30 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: release

on:
push:
tags:
- v*

permissions:
contents: write
pull-requests: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Run goreleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean --config .goreleaser.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51 changes: 51 additions & 0 deletions .github/workflows/test-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: docker-test

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
branches:
- main
paths-ignore:
- '**.md'

permissions: read-all

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: cleanup disk space
run: |
df -H
docker system prune -a -f
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
df -H
- name: create buildx builder
run: docker buildx create --use --name builder --bootstrap

- name: build aikit
run: docker buildx build . -t sozercan/aikit:latest --load

# TODO: cache stuff

- name: build test model
run: docker buildx build . -t sozercan/testmodel:latest -f test/aikitfile.yaml --load

- name: list images
run: docker images

- name: run test model
run: docker run -d -p 8080:8080 sozercan/testmodel:latest

- name: run bats tests
run: make test-e2e-dependencies test-e2e
60 changes: 60 additions & 0 deletions .github/workflows/test-kubernetes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: kubernetes-test

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
branches:
- main
paths-ignore:
- '**.md'

permissions: read-all

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: cleanup disk space
run: |
df -H
docker system prune -a -f
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
df -H
- name: create buildx builder
run: docker buildx create --use --name builder --bootstrap

- name: build aikit
run: docker buildx build . -t sozercan/aikit:latest --load

# TODO: cache stuff

- name: build test model
run: docker buildx build . -t sozercan/testmodel:latest -f test/aikitfile.yaml --load

- name: install e2e dependencies
run: make test-e2e-dependencies

- name: create kind cluster
run: kind create cluster

- name: load test model image into kind cluster
run: kind load docker-image sozercan/testmodel:latest

- name: deploy test model
run: |
kubectl create deployment test-model-deployment --image=sozercan/testmodel:latest --replicas 1
kubectl expose deployment test-model-deployment --port=8080 --target-port=8008 --name=test-model-service
kubectl port-forward service/test-model-service 8080:8080 &
- name: run bats test
run: make test-e2e
33 changes: 33 additions & 0 deletions .github/workflows/unit-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: unit-test

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
branches:
- main
paths-ignore:
- '**.md'

permissions: read-all

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: go mod tidy
run: |
go mod tidy
git diff --exit-code
- name: test
run: make test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@

# Go workspace file
go.work

bin
coverage.txt
40 changes: 40 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
run:
timeout: 5m

linters-settings:
# gocritic:
# enabled-tags:
# - performance
lll:
line-length: 200

misspell:
locale: US
staticcheck:
go: "1.21"

linters:
disable-all: true
enable:
- errcheck
- errorlint
- exportloopref
- forcetypeassert
- gci
- gocritic
- goconst
- godot
- gofmt
- gofumpt
- goimports
- gosec
- gosimple
- govet
- ineffassign
- misspell
- revive
- staticcheck
- typecheck
- unconvert
- unused
- whitespace
1 change: 1 addition & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM golang:1.21-bullseye AS builder
COPY . /go/src/github.com/sozercan/aikit
WORKDIR /go/src/github.com/sozercan/aikit
RUN CGO_ENABLED=0 go build -o /aikit --ldflags '-extldflags "-static"' ./cmd/frontend

FROM scratch
COPY --from=builder /aikit /bin/aikit
ENTRYPOINT ["/bin/aikit"]
45 changes: 45 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# build-aikit:
# docker buildx build . -t sozercan/aikit:latest --push

# build-llm:
# docker buildx build . -t sozercan/myllm:latest -f test/aikitfile.yaml --push

# run:
# docker run -p 8080:8080 sozercan/myllm:latest

# test:
# go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic

BATS_VERSION ?= 1.10.0
BATS_TESTS_FILE ?= test/bats/test.bats
KIND_VERSION ?= 0.20.0

.PHONY: lint
lint:
golangci-lint run -v ./... --timeout 5m

.PHONY: build-aikit
build-aikit:
docker buildx build . -t sozercan/aikit:latest --push --pull --no-cache

.PHONY: build-test-model
build-test-model:
docker buildx build . -t sozercan/testmodel:latest -f test/aikitfile.yaml --push --pull --no-cache

.PHONY: run-test-model
run-test-model:
docker run -p 8080:8080 --pull always sozercan/testmodel:latest

.PHONY: test
test:
go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic

.PHONY: test-e2e-dependencies
test-e2e-dependencies:
curl -L https://github.com/kubernetes-sigs/kind/releases/download/v${KIND_VERSION}/kind-linux-amd64 --output ${GITHUB_WORKSPACE}/bin/kind && chmod +x ${GITHUB_WORKSPACE}/bin/kind

curl -sSLO https://github.com/bats-core/bats-core/archive/v${BATS_VERSION}.tar.gz && tar -zxvf v${BATS_VERSION}.tar.gz && bash bats-core-${BATS_VERSION}/install.sh ${GITHUB_WORKSPACE}

.PHONY: test-e2e
test-e2e:
bats -t ${BATS_TESTS_FILE}
Loading

0 comments on commit cf61e43

Please sign in to comment.