Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump docker/login-action from 1 to 3 #8

Closed
Closed
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
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
40 changes: 40 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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 to GHCR
run: |
docker buildx build -t ghcr.io/sozercan/aikit:${TAG} --push .
docker tag ghcr.io/sozercan/aikit:${TAG} ghcr.io/sozercan/aikit:latest
docker push ghcr.io/sozercan/aikit:latest

- 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:latest --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:latest -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:latest

- 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:latest --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:latest -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: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
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"]
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
REGISTRY ?= docker.io/sozercan
BATS_TESTS_FILE ?= test/bats/test.bats
BATS_VERSION ?= 1.10.0
KIND_VERSION ?= 0.20.0
KUBERNETES_VERSION ?= 1.28.0

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

.PHONY: build-aikit
build-aikit:
docker buildx build . -t ${REGISTRY}/aikit:latest --load

.PHONY: build-test-model
build-test-model:
docker buildx build . -t ${REGISTRY}/testmodel:latest -f test/aikitfile.yaml --load

.PHONY: run-test-model
run-test-model:
docker run -p 8080:8080 ${REGISTRY}/testmodel:latest

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

.PHONY: test-e2e-dependencies
test-e2e-dependencies:
mkdir -p ${GITHUB_WORKSPACE}/bin
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH

curl -sSL https://dl.k8s.io/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl -o ${GITHUB_WORKSPACE}/bin/kubectl && chmod +x ${GITHUB_WORKSPACE}/bin/kubectl

curl -sSL https://github.com/kubernetes-sigs/kind/releases/download/v${KIND_VERSION}/kind-linux-amd64 -o ${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:
/home/runner/work/aikit/aikit/bin/bats --verbose-run --trace ${BATS_TESTS_FILE}
Loading
Loading