Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Commit 3146d4a

Browse files
committed
feat: introduce air
1 parent 65e0755 commit 3146d4a

File tree

6 files changed

+96
-46
lines changed

6 files changed

+96
-46
lines changed

.air.toml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
root = "."
2+
testdata_dir = "testdata"
3+
tmp_dir = "build/tmp"
4+
5+
[build]
6+
args_bin = ["-c", "exit"]
7+
bin = "/bin/sh"
8+
cmd = "make pre-dev"
9+
delay = 0
10+
exclude_dir = ["docs", "build"]
11+
exclude_file = []
12+
exclude_regex = ["_test.go"]
13+
exclude_unchanged = false
14+
follow_symlink = false
15+
full_bin = ""
16+
include_dir = []
17+
include_ext = ["go", "tpl", "tmpl", "html"]
18+
include_file = []
19+
kill_delay = "0s"
20+
log = "build-errors.log"
21+
rerun = false
22+
rerun_delay = 500
23+
send_interrupt = false
24+
stop_on_error = false
25+
26+
[color]
27+
app = ""
28+
build = "yellow"
29+
main = "magenta"
30+
runner = "green"
31+
watcher = "cyan"
32+
33+
[log]
34+
main_only = false
35+
time = true
36+
37+
[misc]
38+
clean_on_exit = false
39+
40+
[screen]
41+
clear_on_rebuild = false
42+
keep_scroll = true

.github/workflows/codeql.yml

+32-31
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
# For most projects, this workflow file will not need changing; you simply need
23
# to commit it to your repository.
34
#
@@ -9,44 +10,44 @@
910
# the `language` matrix defined below to confirm you have the correct set of
1011
# supported CodeQL languages.
1112
#
12-
name: "CodeQL"
13+
name: CodeQL
1314

1415
on:
15-
push:
16-
branches: [ "master" ]
17-
pull_request:
16+
push:
17+
branches: [master]
18+
pull_request:
1819
# The branches below must be a subset of the branches above
19-
branches: [ "master" ]
20-
schedule:
21-
- cron: '16 20 * * 2'
20+
branches: [master]
21+
schedule:
22+
- cron: 16 20 * * 2
2223

2324
jobs:
24-
analyze:
25-
name: Analyze
26-
runs-on: ubuntu-latest
27-
permissions:
28-
actions: read
29-
contents: read
30-
security-events: write
25+
analyze:
26+
name: Analyze
27+
runs-on: ubuntu-latest
28+
permissions:
29+
actions: read
30+
contents: read
31+
security-events: write
3132

32-
strategy:
33-
fail-fast: false
34-
matrix:
35-
language: [ 'go' ]
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
language: [go]
3637
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
3738
# Use only 'java' to analyze code written in Java, Kotlin or both
3839
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
3940
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
4041

41-
steps:
42-
- name: Checkout repository
43-
uses: actions/checkout@v3
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v3
4445

4546
# Initializes the CodeQL tools for scanning.
46-
- name: Initialize CodeQL
47-
uses: github/codeql-action/init@v2
48-
with:
49-
languages: ${{ matrix.language }}
47+
- name: Initialize CodeQL
48+
uses: github/codeql-action/init@v2
49+
with:
50+
languages: ${{ matrix.language }}
5051
# If you wish to specify custom queries, you can do so here or in a config file.
5152
# By default, queries listed here will override any specified in a config file.
5253
# Prefix the list here with "+" to use these queries and those in the config file.
@@ -57,8 +58,8 @@ jobs:
5758

5859
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
5960
# If this step fails, then you should remove it and run the build manually (see below)
60-
- name: Autobuild
61-
uses: github/codeql-action/autobuild@v2
61+
- name: Autobuild
62+
uses: github/codeql-action/autobuild@v2
6263

6364
# ℹ️ Command-line programs to run using the OS shell.
6465
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -70,7 +71,7 @@ jobs:
7071
# echo "Run, Build Application using script"
7172
# ./location_of_script_within_repo/buildscript.sh
7273

73-
- name: Perform CodeQL Analysis
74-
uses: github/codeql-action/analyze@v2
75-
with:
76-
category: "/language:${{matrix.language}}"
74+
- name: Perform CodeQL Analysis
75+
uses: github/codeql-action/analyze@v2
76+
with:
77+
category: /language:${{matrix.language}}

Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ COPY . .
1212

1313
# Set necessary environment variables needed for our image and build the API server.
1414
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
15-
RUN go build -ldflags="-s -w" -o apiserver .
15+
RUN go build -ldflags="-s -w" -o go-horse .
1616

1717
FROM scratch
1818

1919
# Copy binary and config files from /build to root folder of scratch container.
20-
COPY --from=builder ["/build/apiserver", "/"]
20+
COPY --from=builder ["/build/go-horse", "/"]
2121

2222
ENV HOST="localhost" \
2323
PORT=34764 \
@@ -26,4 +26,4 @@ ENV HOST="localhost" \
2626
EXPOSE $PORT
2727

2828
# Command to run when starting the container.
29-
ENTRYPOINT ["/apiserver"]
29+
ENTRYPOINT ["/go-horse"]

Makefile

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,44 @@
1-
.PHONY: all dev clean pre-commit test build swag pre-dev
1+
.PHONY: all dev pre-dev clean pre-commit install-dev test build swag
22

33
APP_NAME = go-horse
44
BUILD_DIR = $(PWD)/build
55

66
all: dev
77

88
dev:
9-
DEBUG=1 fiber dev -p "make pre-dev" -D docs -e go -e env
9+
mkdir -p build
10+
air
1011

1112
pre-dev: swag
1213
go mod tidy
14+
make build
15+
docker cp ./build/go-horse joj2-go-horse:/go-horse
16+
docker restart joj2-go-horse
17+
docker logs -f joj2-go-horse
1318

1419
clean:
1520
rm -rf ./build
1621

1722
pre-commit:
1823
pre-commit run --all-files
1924

20-
pre-commit-install:
25+
install-dev:
26+
go install github.com/swaggo/swag/cmd/swag@latest
27+
go install github.com/cosmtrek/air@latest
2128
python3 -m pip install -U pre-commit
2229
go install golang.org/x/tools/cmd/goimports@latest
2330
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
2431
pre-commit install
2532

26-
test: clean critic
33+
test: clean
2734
go test -v -timeout 30s -coverprofile=cover.out -cover ./...
2835
go tool cover -func=cover.out
2936

30-
build: test
31-
CGO_ENABLED=0 go build -ldflags="-w -s" -o $(BUILD_DIR)/$(APP_NAME) main.go
37+
build:
38+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o $(BUILD_DIR)/$(APP_NAME) .
3239

3340
run: swag build
3441
$(BUILD_DIR)/$(APP_NAME)
3542

3643
swag:
3744
swag init
38-
pre-commit run --files ./docs/swagger.* || true

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Go-Horse
22

3-
## Install `pre-commit` (Run Once)
3+
## Install Dev Deps (Run Once)
4+
5+
Make sure `$(go env GOPATH)/bin` is in your `$PATH`.
46

57
```bash
6-
$ make pre-commit-install
8+
$ make install-dev
79
```
810

9-
## Run
11+
## Development (With joj-deploy-lite started)
1012

1113
```bash
1214
$ make dev

docs/docs.go

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)