mirror of
https://github.com/yusing/godoxy.git
synced 2026-02-26 18:47:40 +01:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79327e98bd | ||
|
|
206f69d249 | ||
|
|
3f6b09d05e | ||
|
|
af68eb4b18 | ||
|
|
9927267149 | ||
|
|
af8cddc1b2 | ||
|
|
c74da5cba9 | ||
|
|
c23cf8ef06 | ||
|
|
733716ba2b |
10
.github/workflows/cli-binary.yml
vendored
10
.github/workflows/cli-binary.yml
vendored
@@ -47,14 +47,20 @@ jobs:
|
||||
|
||||
- name: Build CLI
|
||||
run: |
|
||||
make CLI_BIN_PATH=bin/${{ matrix.binary_name }} build-cli
|
||||
make cli=1 NAME=${{ matrix.binary_name }} build
|
||||
|
||||
- name: Check binary
|
||||
run: |
|
||||
file bin/${{ matrix.binary_name }}
|
||||
|
||||
- name: Upload artifact
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.binary_name }}
|
||||
path: bin/${{ matrix.binary_name }}
|
||||
|
||||
- name: Upload to release
|
||||
uses: softprops/action-gh-release@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
files: bin/${{ matrix.binary_name }}
|
||||
|
||||
21
.github/workflows/merge-main-into-compat.yml
vendored
21
.github/workflows/merge-main-into-compat.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Cherry-pick into Compat
|
||||
name: Refresh Compat from Main Patch
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -8,7 +8,7 @@ on:
|
||||
- ".github/workflows/merge-main-into-compat.yml"
|
||||
|
||||
jobs:
|
||||
cherry-pick:
|
||||
refresh-compat:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -20,20 +20,9 @@ jobs:
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
- name: Cherry-pick commits from last tag
|
||||
- name: Refresh compat with single patch commit
|
||||
run: |
|
||||
git fetch origin compat
|
||||
git checkout compat
|
||||
CURRENT_TAG=${{ github.ref_name }}
|
||||
PREV_TAG=$(git describe --tags --abbrev=0 $CURRENT_TAG^ 2>/dev/null || echo "")
|
||||
|
||||
if [ -z "$PREV_TAG" ]; then
|
||||
echo "No previous tag found. Cherry-picking all commits up to $CURRENT_TAG"
|
||||
git rev-list --reverse --no-merges $CURRENT_TAG | xargs -r git cherry-pick
|
||||
else
|
||||
echo "Cherry-picking commits from $PREV_TAG to $CURRENT_TAG"
|
||||
git rev-list --reverse --no-merges $PREV_TAG..$CURRENT_TAG | xargs -r git cherry-pick
|
||||
fi
|
||||
./scripts/refresh-compat.sh
|
||||
- name: Push compat
|
||||
run: |
|
||||
git push origin compat
|
||||
git push origin compat --force
|
||||
|
||||
32
AGENTS.md
Normal file
32
AGENTS.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# AGENTS.md
|
||||
|
||||
## Development Commands
|
||||
|
||||
- Build: You should not run build command.
|
||||
- Test: `go test -ldflags="-checklinkname=0" ...`
|
||||
|
||||
## Documentation
|
||||
|
||||
Update package level `README.md` if exists after making significant changes.
|
||||
|
||||
## Go Guidelines
|
||||
|
||||
1. Use builtin `min` and `max` functions instead of creating custom ones
|
||||
2. Prefer `for i := range 10` over `for i := 0; i < 10; i++`
|
||||
3. Beware of variable shadowing when making edits
|
||||
4. Use `internal/task/task.go` for lifetime management:
|
||||
- `task.RootTask()` for background operations
|
||||
- `parent.Subtask()` for nested tasks
|
||||
- `OnFinished()` and `OnCancel()` callbacks for cleanup
|
||||
5. Use `gperr "goutils/errs"` to build pretty nested errors:
|
||||
- `gperr.Multiline()` for multiple operation attempts
|
||||
- `gperr.NewBuilder()` to collect errors
|
||||
- `gperr.NewGroup() + group.Go()` to collect errors of multiple concurrent operations
|
||||
- `gperr.PrependSubject()` to prepend subject to errors
|
||||
6. Use `github.com/puzpuzpuz/xsync/v4` for lock-free thread safe maps
|
||||
7. Use `goutils/synk` to retrieve and put byte buffer
|
||||
|
||||
## Testing
|
||||
|
||||
- Run scoped tests instead of `./...`
|
||||
- Use `testify`, no manual assertions.
|
||||
32
Makefile
32
Makefile
@@ -17,15 +17,22 @@ endif
|
||||
|
||||
LDFLAGS = -X github.com/yusing/goutils/version.version=${VERSION} -checklinkname=0
|
||||
|
||||
PACKAGE ?= ./cmd
|
||||
|
||||
ifeq ($(agent), 1)
|
||||
NAME = godoxy-agent
|
||||
PWD = ${shell pwd}/agent
|
||||
else ifeq ($(socket-proxy), 1)
|
||||
NAME = godoxy-socket-proxy
|
||||
PWD = ${shell pwd}/socket-proxy
|
||||
else ifeq ($(cli), 1)
|
||||
NAME = godoxy-cli
|
||||
PWD = ${shell pwd}/cmd/cli
|
||||
PACKAGE = .
|
||||
else
|
||||
NAME = godoxy
|
||||
PWD = ${shell pwd}
|
||||
godoxy = 1
|
||||
endif
|
||||
|
||||
ifeq ($(trace), 1)
|
||||
@@ -58,7 +65,6 @@ endif
|
||||
|
||||
BUILD_FLAGS += -tags '$(GO_TAGS)' -ldflags='$(LDFLAGS)'
|
||||
BIN_PATH := $(shell pwd)/bin/${NAME}
|
||||
CLI_BIN_PATH ?= $(shell pwd)/bin/godoxy-cli
|
||||
|
||||
export NAME
|
||||
export CGO_ENABLED
|
||||
@@ -76,7 +82,11 @@ endif
|
||||
|
||||
|
||||
# CAP_NET_BIND_SERVICE: permission for binding to :80 and :443
|
||||
POST_BUILD = $(SETCAP_CMD) CAP_NET_BIND_SERVICE=+ep ${BIN_PATH};
|
||||
POST_BUILD = echo;
|
||||
|
||||
ifeq ($(godoxy), 1)
|
||||
POST_BUILD += $(SETCAP_CMD) CAP_NET_BIND_SERVICE=+ep ${BIN_PATH};
|
||||
endif
|
||||
ifeq ($(docker), 1)
|
||||
POST_BUILD += mkdir -p /app && mv ${BIN_PATH} /app/run;
|
||||
endif
|
||||
@@ -133,13 +143,18 @@ minify-js:
|
||||
done \
|
||||
fi
|
||||
|
||||
build: minify-js
|
||||
build:
|
||||
@if [ "${godoxy}" = "1" ]; then \
|
||||
make minify-js; \
|
||||
elif [ "${cli}" = "1" ]; then \
|
||||
make gen-cli; \
|
||||
fi
|
||||
mkdir -p $(shell dirname ${BIN_PATH})
|
||||
go build -C ${PWD} ${BUILD_FLAGS} -o ${BIN_PATH} ./cmd
|
||||
go build -C ${PWD} ${BUILD_FLAGS} -o ${BIN_PATH} ${PACKAGE}
|
||||
${POST_BUILD}
|
||||
|
||||
run: minify-js
|
||||
cd ${PWD} && [ -f .env ] && godotenv -f .env go run ${BUILD_FLAGS} ./cmd
|
||||
cd ${PWD} && [ -f .env ] && godotenv -f .env go run ${BUILD_FLAGS} ${PACKAGE}
|
||||
|
||||
dev:
|
||||
docker compose -f dev.compose.yml $(args)
|
||||
@@ -186,13 +201,10 @@ gen-api-types: gen-swagger
|
||||
bunx --bun swagger-typescript-api generate --sort-types --generate-union-enums --axios --add-readonly --route-types \
|
||||
--responses -o ${WEBUI_DIR}/src/lib -n api.ts -p internal/api/v1/docs/swagger.json
|
||||
|
||||
.PHONY: gen-cli build-cli update-wiki
|
||||
|
||||
gen-cli:
|
||||
cd cmd/cli && go run ./gen
|
||||
|
||||
build-cli: gen-cli
|
||||
mkdir -p $(shell dirname ${CLI_BIN_PATH})
|
||||
go build -C cmd/cli -o ${CLI_BIN_PATH} .
|
||||
|
||||
.PHONY: gen-cli build-cli update-wiki
|
||||
update-wiki:
|
||||
DOCS_DIR=${DOCS_DIR} REPO_URL=${REPO_URL} bun --bun scripts/update-wiki/main.ts
|
||||
|
||||
2
goutils
2
goutils
Submodule goutils updated: 246c8e9ba1...4f468fdce8
55
scripts/refresh-compat.sh
Executable file
55
scripts/refresh-compat.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
if ! git diff --quiet || ! git diff --cached --quiet; then
|
||||
echo "Working tree is not clean. Commit or stash changes before running refresh-compat.sh." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git fetch origin main compat
|
||||
git checkout -B compat origin/compat
|
||||
patch_file="$(mktemp)"
|
||||
trap 'rm -f "$patch_file"' EXIT
|
||||
git diff origin/main -- ':(glob)**/*.go' >"$patch_file"
|
||||
git checkout -B main origin/main
|
||||
git branch -D compat
|
||||
git checkout -b compat
|
||||
git apply "$patch_file"
|
||||
mapfile -t changed_go_files < <(git diff --name-only -- '*.go')
|
||||
fmt_go_files=()
|
||||
for file in "${changed_go_files[@]}"; do
|
||||
[ -f "$file" ] || continue
|
||||
sed -i 's/sonic\./json\./g' "$file"
|
||||
sed -i 's/"github.com\/bytedance\/sonic"/"encoding\/json"/g' "$file"
|
||||
sed -E -i 's/\bsonic[[:space:]]+"encoding\/json"/json "encoding\/json"/g' "$file"
|
||||
fmt_go_files+=("$file")
|
||||
done
|
||||
if [ "${#fmt_go_files[@]}" -gt 0 ]; then
|
||||
gofmt -w "${fmt_go_files[@]}"
|
||||
fi
|
||||
|
||||
# create placeholder files for minified JS files so go vet won't complain
|
||||
while IFS= read -r file; do
|
||||
ext="${file##*.}"
|
||||
base="${file%.*}"
|
||||
min_file="${base}-min.${ext}"
|
||||
[ -f "$min_file" ] || : >"$min_file"
|
||||
done < <(find internal/ -name '*.js' ! -name '*-min.js')
|
||||
|
||||
docker_version="$(
|
||||
git show origin/compat:go.mod |
|
||||
sed -n 's/^[[:space:]]*github.com\/docker\/docker[[:space:]]\+\(v[^[:space:]]\+\).*/\1/p' |
|
||||
head -n 1
|
||||
)"
|
||||
if [ -n "$docker_version" ]; then
|
||||
go mod edit -droprequire=github.com/docker/docker/api || true
|
||||
go mod edit -droprequire=github.com/docker/docker/client || true
|
||||
go mod edit -require="github.com/docker/docker@${docker_version}"
|
||||
fi
|
||||
|
||||
go mod tidy
|
||||
go mod -C agent tidy
|
||||
git add -A
|
||||
git commit -m "Apply compat patch"
|
||||
go vet ./...
|
||||
go vet -C agent ./...
|
||||
Reference in New Issue
Block a user