-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit bf5149a
Showing
63 changed files
with
5,071 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,17 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
end_of_line = lf | ||
charset = utf-8 | ||
indent_size = 2 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[Makefile] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[*.go] | ||
indent_style = tab | ||
indent_size = 4 |
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,4 @@ | ||
# for development environment | ||
export PATH=$(pwd)/.dev/build/dev:$PATH | ||
export GPTX_HOME=$(pwd)/.gptx | ||
export OPENAI_API_KEY=sk-*** |
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 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: go.mod | ||
cache: true | ||
- run: make dev/setup | ||
- run: make build/release | ||
- uses: ncipollo/release-action@v1 | ||
with: | ||
artifacts: '.dev/build/release/*' |
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,27 @@ | ||
name: test | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: go.mod | ||
cache: true | ||
- run: make dev/setup | ||
- run: make test | ||
- run: make lint |
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,18 @@ | ||
.DS_Store | ||
Thumbs.db | ||
.idea/ | ||
.vscode/ | ||
node_modules/ | ||
|
||
# dev | ||
/.dev | ||
|
||
# .gptx home for development | ||
/.gptx | ||
|
||
# doenv, direnv | ||
.env | ||
.envrc | ||
|
||
!.gitkeep | ||
|
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,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2023 Kohki Makimoto | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,115 @@ | ||
.DEFAULT_GOAL := help | ||
|
||
SHELL := bash | ||
PATH := $(CURDIR)/.dev/gopath/bin:$(PATH) | ||
VERSION := 0.0.0 | ||
COMMIT_HASH := $(shell git rev-parse HEAD) | ||
BUILD_LDFLAGS = "-s -w -X github.com/kohkimakimoto/gptx/internal.CommitHash=$(COMMIT_HASH) -X github.com/kohkimakimoto/gptx/internal.Version=$(VERSION)" | ||
|
||
# Load .env file if it exists. | ||
ifneq (,$(wildcard ./.env)) | ||
include .env | ||
export | ||
endif | ||
|
||
|
||
.PHONY: help | ||
help: ## Show help | ||
@echo "Usage: make [target]" | ||
@echo "" | ||
@echo "Available targets:" | ||
@grep -E '^[/0-9a-zA-Z_-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' | ||
|
||
|
||
.PHONY: bump | ||
bump: ## Bump up version | ||
@PART=${PART}; \ | ||
if [ -z "$$PART" ]; then \ | ||
PART=minor; \ | ||
fi; \ | ||
if [ $$PART = "major" ]; then \ | ||
perl -i.bak -pe 's/(VERSION := )(\d+)(\.(\d+)\.(\d+))/$$1 . ($$2 + 1) . ".0.0"/e' Makefile; \ | ||
elif [ $$PART = "minor" ]; then \ | ||
perl -i.bak -pe 's/(VERSION := (\d+)\.)(\d+)(\.(\d+))/$$1 . ($$3 + 1) . ".0"/e' Makefile; \ | ||
elif [ $$PART = "patch" ]; then \ | ||
perl -i.bak -pe 's/(VERSION := (\d+\.\d+\.))(\d+)/$$1 . ($$3 + 1)/e' Makefile; \ | ||
else \ | ||
echo "Invalid part: $$PART"; exit 1; \ | ||
fi && rm Makefile.bak | ||
@new_version=$$(perl -ne 'print $$1 if /VERSION := (\d+\.\d+\.\d+)/' Makefile) && \ | ||
git commit -am "Bump up version to $$new_version" && \ | ||
git tag "v$$new_version" | ||
|
||
|
||
.PHONY: dev/setup | ||
dev/setup: ## Setup development environment | ||
@mkdir -p .dev/gopath | ||
@export GOPATH=$(CURDIR)/.dev/gopath && \ | ||
go install honnef.co/go/tools/cmd/staticcheck@latest && \ | ||
go install github.com/Songmu/goxz/cmd/goxz@latest && \ | ||
go install github.com/axw/gocov/gocov@latest && \ | ||
go install github.com/matm/gocov-html/cmd/gocov-html@latest && \ | ||
go install go.etcd.io/bbolt/cmd/bbolt@latest | ||
|
||
|
||
.PHONY: dev/clean | ||
dev/clean: ## Clean up development environment | ||
@export GOPATH=$(CURDIR)/.dev/gopath && go clean -modcache | ||
@rm -rf .dev | ||
|
||
|
||
.PHONY: format | ||
format: ## Format source code | ||
@go fmt ./... | ||
|
||
|
||
.PHONY: test | ||
test: ## Run tests | ||
@go test -race -timeout 30m -cover ./... | ||
|
||
|
||
.PHONY: test/verbos | ||
test/verbose: ## Run tests with verbose outputting. | ||
@go test -race -timeout 30m -cover -v ./... | ||
|
||
|
||
.PHONY: test/coverage | ||
test/coverage: ## Run tests with coverage report | ||
@mkdir -p .dev | ||
@go test -race -timeout 30m -cover ./... -coverprofile=.dev/coverage.out | ||
@gocov convert .dev/coverage.out | gocov-html > .dev/coverage.html | ||
|
||
|
||
.PHONY: lint | ||
lint: ## Static code analysis | ||
@go vet ./... | ||
@staticcheck ./... | ||
|
||
|
||
.PHONY: open-coverage-html | ||
open-coverage-html: ## Open coverage report | ||
@open .dev/coverage.html | ||
|
||
|
||
.PHONY: build | ||
build: ## build dev binary | ||
@mkdir -p .dev/build/dev | ||
@go build -ldflags=$(BUILD_LDFLAGS) -o .dev/build/dev/gptx ./cmd/gptx | ||
|
||
|
||
.PHONY: build/release | ||
build/release: ## build release binary | ||
@mkdir -p .dev/build/release | ||
@goxz -n gptx -pv=v$(VERSION) -os=linux,darwin -static -build-ldflags=$(BUILD_LDFLAGS) -d=.dev/build/release ./cmd/gptx | ||
|
||
|
||
.PHONY: clean | ||
clean: ## Clean generated files | ||
@rm -rf .dev/build | ||
@rm -rf .dev/coverage.html | ||
@rm -rf .dev/coverage.out | ||
|
||
|
||
# check variable definition | ||
guard-%: | ||
@if [[ -z '${${*}}' ]]; then echo 'ERROR: variable $* not set' && exit 1; fi |
Oops, something went wrong.