-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b92d7cf
commit 2865060
Showing
18 changed files
with
800 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
time: "08:00" | ||
labels: | ||
- "dependencies" | ||
commit-message: | ||
prefix: "feat" | ||
include: "scope" | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
time: "08:00" | ||
labels: | ||
- "dependencies" | ||
commit-message: | ||
prefix: "chore" | ||
include: "scope" | ||
- package-ecosystem: "docker" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
time: "08:00" | ||
labels: | ||
- "dependencies" | ||
commit-message: | ||
prefix: "feat" | ||
include: "scope" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: goreleaser | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
env: | ||
DOCKER_CLI_EXPERIMENTAL: "enabled" | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- | ||
name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.23.2 | ||
# - | ||
# name: Set up Node.js | ||
# uses: actions/setup-node@v4 | ||
# with: | ||
# node-version: 20.18.0 | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
# - | ||
# name: Set up Docker Buildx | ||
# uses: docker/setup-buildx-action@v3 | ||
# - | ||
# name: Login to Docker Hub | ||
# uses: docker/login-action@v3 | ||
# with: | ||
# username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
# password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
# - | ||
# name: ghcr-login | ||
# uses: docker/login-action@v3 | ||
# with: | ||
# registry: ghcr.io | ||
# username: ${{ github.repository_owner }} | ||
# password: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v6 | ||
with: | ||
version: latest | ||
args: release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,9 @@ go.work.sum | |
|
||
# env file | ||
.env | ||
|
||
|
||
.vscode/ | ||
.idea/ | ||
dist/ | ||
go-template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
linters: | ||
enable: | ||
- gofmt | ||
- goimports | ||
- govet | ||
- revive | ||
- errcheck | ||
- staticcheck | ||
- gosimple | ||
- ineffassign | ||
|
||
run: | ||
timeout: 5m | ||
|
||
issues: | ||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
- errcheck | ||
|
||
linters-settings: | ||
gofmt: | ||
simplify: true | ||
govet: | ||
shadow: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
version: 2 | ||
env: | ||
- GO111MODULE=on | ||
- CGO_ENABLED=0 | ||
|
||
# before: | ||
# hooks: | ||
# - ./scripts/manpages.sh | ||
# - ./scripts/completions.sh | ||
|
||
builds: | ||
- | ||
binary: go-template | ||
ldflags: | ||
- -s -w | ||
- -X main.version={{ .Version }} | ||
- -X main.buildTime={{ .Date }} | ||
- -X main.gitCommit={{ .FullCommit }} | ||
goos: | ||
- linux | ||
- darwin | ||
- windows | ||
- freebsd | ||
goarch: | ||
- "386" | ||
- amd64 | ||
- arm64 | ||
overrides: | ||
- goos: darwin | ||
goarch: amd64 | ||
ldflags: | ||
- -s -w | ||
env: | ||
- CGO_ENABLED=0 | ||
- goos: darwin | ||
goarch: arm64 | ||
ldflags: | ||
- -s -w | ||
env: | ||
- CGO_ENABLED=0 | ||
- goos: linux | ||
ldflags: | ||
- -s -w -extldflags "-static" | ||
- -X main.version={{ .Version }} | ||
- -X main.buildTime={{ .Date }} | ||
- -X main.gitCommit={{ .FullCommit }} | ||
|
||
|
||
archives: | ||
- | ||
builds: | ||
- go-template | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
# files: | ||
# - "config_example.toml" | ||
|
||
release: | ||
github: | ||
owner: nerdneilsfield | ||
name: go-template | ||
|
||
# dockers: | ||
# - image_templates: | ||
# - 'nerdneils/go-template:{{ .Tag }}-amd64' | ||
# - 'ghcr.io/nerdneilsfield/go-template:{{ .Tag }}-amd64' | ||
# dockerfile: Dockerfile | ||
# use: buildx | ||
# build_flag_templates: | ||
# - "--pull" | ||
# - "--label=io.artifacthub.package.readme-url=https://raw.githubusercontent.com/nerdneilsfield/go-template/master/README.md" | ||
# - "--label=io.artifacthub.package.maintainers=[{\"name\":\"dengqqi\",\"email\":\"dengqqi935@gmail.com\"}]" | ||
# - "--label=io.artifacthub.package.license=MIT" | ||
# - "--label=org.opencontainers.image.description=A fast and flexible translation gateway that routes requests to various LLM endpoints with configurable rate limiting and model-specific prompts." | ||
# - "--label=org.opencontainers.image.created={{.Date}}" | ||
# - "--label=org.opencontainers.image.name={{.ProjectName}}" | ||
# - "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
# - "--label=org.opencontainers.image.version={{.Version}}" | ||
# - "--label=org.opencontainers.image.source={{.GitURL}}" | ||
# - "--platform=linux/amd64" | ||
# extra_files: | ||
# - "config_example.toml" | ||
# - image_templates: | ||
# - 'nerdneils/go-template:{{ .Tag }}-arm64' | ||
# - 'ghcr.io/nerdneilsfield/go-template:{{ .Tag }}-arm64' | ||
# dockerfile: Dockerfile | ||
# use: buildx | ||
# build_flag_templates: | ||
# - "--pull" | ||
# - "--label=io.artifacthub.package.readme-url=https://raw.githubusercontent.com/nerdneilsfield/go-template/master/README.md" | ||
# # - "--label=io.artifacthub.package.logo-url=https://raw.githubusercontent.com/nerdneilsfield/ghproxy-go/master/www/static/images/logo.png" | ||
# - "--label=io.artifacthub.package.maintainers=[{\"name\":\"dengqqi\",\"email\":\"dengqqi935@gmail.com\"}]" | ||
# - "--label=io.artifacthub.package.license=MIT" | ||
# - "--label=org.opencontainers.image.description=A fast and flexible translation gateway that routes requests to various LLM endpoints with configurable rate limiting and model-specific prompts." | ||
# - "--label=org.opencontainers.image.created={{.Date}}" | ||
# - "--label=org.opencontainers.image.name={{.ProjectName}}" | ||
# - "--label=org.opencontainers.image.revision={{.FullCommit}}" | ||
# - "--label=org.opencontainers.image.version={{.Version}}" | ||
# - "--label=org.opencontainers.image.source={{.GitURL}}" | ||
# - "--platform=linux/arm64" | ||
# goarch: arm64 | ||
# extra_files: | ||
# - "config_example.toml" | ||
|
||
# docker_manifests: | ||
# - name_template: 'nerdneils/go-template:{{ .Tag }}' | ||
# image_templates: | ||
# - 'nerdneils/go-template:{{ .Tag }}-amd64' | ||
# - 'nerdneils/go-template:{{ .Tag }}-arm64' | ||
# - name_template: 'ghcr.io/nerdneilsfield/go-template:{{ .Tag }}' | ||
# image_templates: | ||
# - 'ghcr.io/nerdneilsfield/go-template:{{ .Tag }}-amd64' | ||
# - 'ghcr.io/nerdneilsfield/go-template:{{ .Tag }}-arm64' | ||
# - name_template: 'nerdneils/go-template:latest' | ||
# image_templates: | ||
# - 'nerdneils/go-template:{{ .Tag }}-amd64' | ||
# - 'nerdneils/go-template:{{ .Tag }}-arm64' | ||
# - name_template: 'ghcr.io/nerdneilsfield/go-template:latest' | ||
# image_templates: | ||
# - 'ghcr.io/nerdneilsfield/go-template:{{ .Tag }}-amd64' | ||
# - 'ghcr.io/nerdneilsfield/go-template:{{ .Tag }}-arm64' | ||
|
||
checksum: | ||
name_template: "checksums.txt" | ||
|
||
changelog: | ||
sort: asc | ||
use: github | ||
filters: | ||
exclude: | ||
- '^test:' | ||
- '^chore' | ||
- 'merge conflict' | ||
- Merge pull request | ||
- Merge remote-tracking branch | ||
- Merge branch | ||
- go mod tidy | ||
groups: | ||
- title: Dependency updates | ||
regexp: '^.*?(feat|fix)\(deps\)!?:.+$' | ||
order: 300 | ||
- title: 'New Features' | ||
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$' | ||
order: 100 | ||
- title: 'Bug fixes' | ||
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$' | ||
order: 200 | ||
- title: 'Documentation updates' | ||
regexp: ^.*?doc(\([[:word:]]+\))??!?:.+$ | ||
order: 400 | ||
- title: Other work | ||
order: 9999 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"plugins": ["prettier-plugin-go"], | ||
"printWidth": 100, | ||
"tabWidth": 4, | ||
"semi": false, | ||
"trailingComma": "es5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM alpine:latest | ||
|
||
COPY polyglot-gate-server /app/polyglot-gate-server | ||
COPY config_example.toml /app/config.toml | ||
|
||
ENTRYPOINT ["/app/polyglot-gate-server", "run", "/app/config.toml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
projectname?=go-template | ||
|
||
default: help | ||
|
||
.PHONY: help | ||
help: ## list makefile targets | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
.PHONY: build | ||
build: ## build golang binary | ||
@go build -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags)" -o $(projectname) | ||
|
||
.PHONY: install | ||
install: ## install golang binary | ||
@go install -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags)" | ||
|
||
.PHONY: run | ||
run: ## run the app | ||
@go run -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags)" main.go | ||
|
||
.PHONY: bootstrap | ||
bootstrap: ## install build deps | ||
go generate -tags tools tools/tools.go | ||
|
||
PHONY: test | ||
test: clean ## display test coverage | ||
go test --cover -parallel=1 -v -coverprofile=coverage.out ./... | ||
go tool cover -func=coverage.out | sort -rnk3 | ||
|
||
PHONY: clean | ||
clean: ## clean up environment | ||
@rm -rf coverage.out dist/ $(projectname) | ||
|
||
PHONY: cover | ||
cover: ## display test coverage | ||
go test -v -race $(shell go list ./... | grep -v /vendor/) -v -coverprofile=coverage.out | ||
go tool cover -func=coverage.out | ||
|
||
PHONY: fmt | ||
fmt: ## format go files | ||
gofumpt -w . | ||
gci write . | ||
|
||
PHONY: lint | ||
lint: ## lint go files | ||
golangci-lint run -c .golang-ci.yml | ||
|
||
PHONY: release-test | ||
release-test: ## test release | ||
goreleaser release --rm-dist --snapshot --clean --skip-publish | ||
|
||
# .PHONY: pre-commit | ||
# pre-commit: ## run pre-commit hooks | ||
# pre-commit run --all-files |
Oops, something went wrong.