Skip to content

Development and Testing zh TW

KoukeNeko edited this page Sep 9, 2026 · 4 revisions

Development and Testing

English · 繁體中文

快速迴圈

不需要 Docker:

make test
make test-race
make lint

make lint 會執行 go vet 與 golangci-lint run。完整的門檻:

make verify

等同於 test、test-race、lint 與 build。

Docker E2E

make test-integration

Harness 會用獨立的 taiga-cli-e2e Compose project 在 localhost:19000 起一套真實的 Taiga,等待 API 就緒後建置 CLI 並執行帶 integration build tag 的測試,涵蓋 auth、專案、敏捷流程、Wiki、附件、 batch、stats 與 export/import。

測試自行建立臨時帳號、專案與 Issue,結束時只清除自己的 container 與 volume,不會存取或清除你日常 使用的 localhost:9000 Taiga 實例。

E2E 測試位於 test/e2e,因為有 //go:build integration 標籤,所以不會被 go test ./... 執行到。

專案結構

cmd/taiga            CLI 進入點
cmd/releasepack      跨平台可重現打包工具
internal/cli         Cobra 指令層
internal/taiga       Taiga REST API client
internal/config      TOML profile 與 Git-local 設定
internal/credential  OS keyring 抽象
internal/output      JSON envelope 與欄位過濾
internal/completioncache  補全 metadata 快取
internal/atomicfile  原子檔案寫入
internal/version     由 ldflags 注入的建置資訊
internal/releasepack Archive、checksum 與 SBOM 產生

internal/taiga 不依賴 internal/cli,可以當成獨立的 Taiga SDK 使用。

測試策略

internal/cli 的 App 把所有 I/O 與副作用(stdin/stdout/stderr、HTTP client、環境變數、工作目錄、 keyring)都做成可注入的欄位,因此指令層的測試完全不需要碰真實環境或網路,全部以 httptest 驅動。

Release packaging

make release \
  VERSION=v0.1.0 \
  COMMIT="$(git rev-parse HEAD)" \
  SOURCE_DATE_EPOCH="$(git show -s --format=%ct HEAD)"

產生六個平台的 archive、四種 shell completion、SHA256SUMS 與 SPDX 2.3 SBOM,輸出在 dist/<version>/。 CI 會重建 Linux archive 並逐位元比對,確保可重現性。

Release build 另外會簽署並 notarize macOS binary,打包工具透過 SIGN_IDENTITY、SIGN_KEYCHAIN、 NOTARY_KEY、NOTARY_KEY_ID、NOTARY_ISSUER 接收設定。不指定這些變數時(本機建置的預設)會完全跳過 簽署,所有 archive 維持可重現。簽署只作用於 darwin 目標。

維護者的完整發布流程見 RELEASING.md。

Clone this wiki locally