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 Dec 1, 2023
1 parent 58a700f commit 3943d05
Show file tree
Hide file tree
Showing 35 changed files with 1,622 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
42 changes: 42 additions & 0 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: pre-release

on:
push:
branches:
- main

permissions:
contents: write
packages: write

jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 360
steps:
- uses: actions/checkout@v4

- name: cleanup disk space
run: |
df -H
docker system prune -f -a --volumes
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: Login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: create buildx builder
run: docker buildx create --use --name builder --bootstrap
- uses: crazy-max/ghaction-github-runtime@v3

- name: Push aikit:dev to GHCR
run: |
docker buildx build -t ghcr.io/sozercan/aikit:dev --push .
38 changes: 38 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: release

on:
push:
tags:
- v*

permissions:
contents: write
packages: write

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

- name: Login to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get tag
run: |
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Push aikit:latest to GHCR
run: |
docker buildx build . -t ghcr.io/sozercan/aikit:${TAG} -t ghcr.io/sozercan/aikit:latest --push --cache-from=type=gha,scope=aikit --cache-to=type=gha,scope=aikit,mode=max
# - name: release llama 2 image
# run: |
# docker buildx build -t ghcr.io/sozercan/llama2:7b -t ghcr.io/sozercan/llama2:7b-chat -t ghcr.io/sozercan/llama2:chat -t ghcr.io/sozercan/llama2:latest -f models/llama-2-chat-7b.yaml --push --cache-from=type=gha,scope=llama-2-7b-chat --cache-to=type=gha,scope=llama-2-7b-chat,mode=max
54 changes: 54 additions & 0 deletions .github/workflows/test-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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
timeout-minutes: 240
steps:
- uses: actions/checkout@v4

- name: cleanup disk space
run: |
df -H
docker system prune -f -a --volumes
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
- uses: crazy-max/ghaction-github-runtime@v3

- name: build aikit
run: docker buildx build . -t sozercan/aikit:test --load --cache-from=type=gha,scope=aikit --cache-to=type=gha,scope=aikit,mode=max

- name: build test model
run: docker buildx build . -t sozercan/testmodel:test -f test/aikitfile.yaml --load --cache-from=type=gha,scope=testmodel --cache-to=type=gha,scope=testmodel,mode=max

- name: list images
run: docker images

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

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

- name: run bats test
run: make 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
timeout-minutes: 240
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
- uses: crazy-max/ghaction-github-runtime@v3

- name: build aikit
run: docker buildx build . -t sozercan/aikit:test --load --cache-from=type=gha,scope=aikit --cache-to=type=gha,scope=aikit,mode=max

- name: build test model
run: docker buildx build . -t sozercan/testmodel:test -f test/aikitfile.yaml --load --cache-from=type=gha,scope=testmodel --cache-to=type=gha,scope=testmodel,mode=max

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

- name: create kind cluster
run: kind create cluster --wait 5m

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

- name: deploy test model
run: |
kubectl create deployment test-model-deployment --image=sozercan/testmodel:test --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
32 changes: 32 additions & 0 deletions .github/workflows/update-models.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: update-models

on:
workflow_dispatch:

permissions:
contents: write
packages: write

jobs:
update-models:
runs-on: ubuntu-latest
timeout-minutes: 360
steps:
- uses: actions/checkout@v4

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push llama 2 models to GHCR
run: |
docker buildx create --use --name builder --bootstrap
docker buildx build . -t ghcr.io/sozercan/llama2:7b -f models/llama-2-7b-chat.yaml --push
docker buildx build . -t ghcr.io/sozercan/llama2:13b -f models/llama-2-13b-chat.yaml --push
docker buildx build . -t ghcr.io/sozercan/llama2:7b-cuda -f models/cuda/llama-2-7b-chat.yaml --push
docker buildx build . -t ghcr.io/sozercan/llama2:13b-cuda -f models/cuda/llama-2-13b-chat.yaml --push
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
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"]
Loading

0 comments on commit 3943d05

Please sign in to comment.