Skip to content

Commit 428f473

Browse files
committed
ci: go ci
1 parent ea9e69c commit 428f473

File tree

18 files changed

+384
-8
lines changed

18 files changed

+384
-8
lines changed

.github/workflows/go_build.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "frontend/**/*.go"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v5
20+
with:
21+
go-version: "1.25"
22+
23+
- name: Build multi-platform packages
24+
working-directory: frontend
25+
run: make build-fe
26+
27+
- name: Clean built packages
28+
working-directory: frontend
29+
run: make clean-build-fe
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Build and Publish Docker Image
2+
3+
on:
4+
push:
5+
tags: [ 'v*.*.*' ]
6+
branches: [ main ]
7+
paths:
8+
- "frontend/**"
9+
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
16+
jobs:
17+
build-and-publish-docker-image:
18+
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
id-token: write
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Install cosign
30+
if: github.event_name != 'pull_request'
31+
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
32+
with:
33+
cosign-release: 'v2.2.4'
34+
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
37+
38+
- name: Log into registry ${{ env.REGISTRY }}
39+
if: github.event_name != 'pull_request'
40+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
41+
with:
42+
registry: ${{ env.REGISTRY }}
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Extract Docker metadata
47+
id: meta
48+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
49+
with:
50+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
51+
52+
- name: Build and push Docker image
53+
id: build-and-push
54+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
55+
with:
56+
context: frontend/
57+
push: ${{ github.event_name != 'pull_request' }}
58+
tags: ${{ steps.meta.outputs.tags }}
59+
labels: ${{ steps.meta.outputs.labels }}
60+
cache-from: type=gha
61+
cache-to: type=gha,mode=max
62+
63+
- name: Sign the published Docker image
64+
if: ${{ github.event_name != 'pull_request' }}
65+
env:
66+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
67+
TAGS: ${{ steps.meta.outputs.tags }}
68+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
69+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
70+
71+
# - name: Dokploy Deployment
72+
# if: github.ref == 'refs/heads/main' && github.event_name == 'push'
73+
# run: |
74+
# response=$(curl -X 'POST' \
75+
# "$DOKPLOY_URL/api/application.deploy" \
76+
# -H 'accept: application/json' \
77+
# -H 'Content-Type: application/json' \
78+
# -H "x-api-key: $DOKPLOY_AUTH_TOKEN" \
79+
# -d "{\"applicationId\": \"$DOKPLOY_APPLICATION_ID\"}" \
80+
# -w "%{http_code}" \
81+
# -o /dev/null \
82+
# -s)
83+
84+
# if [ "$response" -ne 200 ]; then
85+
# echo "Deployment failed with status code: $response"
86+
# exit 1
87+
# fi
88+
# env:
89+
# DOKPLOY_AUTH_TOKEN: ${{ secrets.DOKPLOY_AUTH_TOKEN }}
90+
# DOKPLOY_APPLICATION_ID: ${{ secrets.DOKPLOY_APPLICATION_ID }}
91+
# DOKPLOY_URL: ${{ secrets.DOKPLOY_URL }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Docker Image CI
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "frontend/**"
7+
8+
jobs:
9+
10+
build-docker-image:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Build the Docker image
17+
working-directory: frontend
18+
run: docker build .

.github/workflows/go_lint.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Go Lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "frontend/**/*.go"
8+
pull_request:
9+
paths:
10+
- "frontend/**/*.go"
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: "1.24"
25+
26+
- name: Set up golangci
27+
uses: golangci/golangci-lint-action@v8
28+
with:
29+
version: latest
30+
31+
- name: Format
32+
working-directory: frontend
33+
run: make format-fe
34+
35+
- name: Lint
36+
working-directory: frontend
37+
run: make lint-fe

.github/workflows/go_test.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Go Tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "frontend/**/*.go"
7+
push:
8+
branches: [main]
9+
paths:
10+
- "frontend/**/*.go"
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
go-version: ["1.25"]
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: ${{ matrix.go-version }}
27+
28+
- name: Cache Go modules
29+
uses: actions/cache@v4
30+
with:
31+
path: |
32+
~/.cache/go-build
33+
~/go/pkg/mod
34+
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
35+
restore-keys: |
36+
${{ runner.os }}-go-${{ matrix.go-version }}-
37+
38+
- name: Run tests
39+
working-directory: frontend
40+
run: make test

.github/workflows/py_deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- "pyproject.toml"
1010

1111
jobs:
12-
lint:
12+
llamaagent_deploy:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4

frontend/.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.env
2+
*_test.go
3+
sqlc.yaml
4+
*.db
5+
tmp/

frontend/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
*.db
1+
*.db
2+
tmp/

frontend/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM golang:1.25-bookworm AS builder
2+
3+
WORKDIR /build/
4+
5+
COPY . /build/
6+
7+
RUN go build -tags netgo -ldflags '-s -w' -o server
8+
9+
FROM debian:bookworm-slim
10+
WORKDIR /app/
11+
COPY --from=builder /build/server /app/
12+
RUN apt-get update && apt-get install -y ca-certificates tzdata && rm -rf /var/lib/apt/lists/*
13+
COPY --from=builder /build/static/ /app/static/
14+
15+
EXPOSE 8000
16+
17+
ENTRYPOINT [ "./server" ]

frontend/Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
BIN="./tmp/bin"
2+
BIN_NAME="frontend"
3+
MAIN_PKG="."
4+
SRC=$(shell find . -name "*.go")
5+
6+
ifeq (, $(shell which golangci-lint))
7+
$(warning "could not find golangci-lint in $(PATH), run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh")
8+
endif
9+
10+
.PHONY: test lint format format-check typecheck build format-fe build-fe clean-build-fe test-fe lint-fe install-deps-fe
11+
12+
format-fe:
13+
$(info ******************** checking formatting for frontend ********************)
14+
@test -z $(shell gofmt -l $(SRC)) || (gofmt -d $(SRC); exit 1)
15+
16+
lint-fe:
17+
$(info ******************** running lint tools for frontend ********************)
18+
golangci-lint run -v
19+
20+
test-fe: install-deps-fe
21+
$(info ****************** running tests for frontend ******************)
22+
go test ./...
23+
24+
install-deps-fe:
25+
$(info ******************** downloading dependencies for frontend ********************)
26+
go get -v ./...
27+
28+
build-fe: install-deps-fe
29+
$(info ****************** building frontend ******************)
30+
@mkdir -p ${BIN}
31+
GOARCH=amd64 GOOS=linux go build -o ${BIN}/${BIN_NAME}-linux-amd64 ${MAIN_PKG}
32+
GOARCH=amd64 GOOS=windows go build -o ${BIN}/${BIN_NAME}-windows-amd64.exe ${MAIN_PKG}
33+
GOARCH=arm64 GOOS=darwin go build -o ${BIN}/${BIN_NAME}-darwin-arm64 ${MAIN_PKG}
34+
35+
clean-build-fe:
36+
@rm -rf ${BIN}

0 commit comments

Comments
 (0)