This document covers the local development setup, build processes, testing infrastructure, and development tools for the go-dota2 project. It provides guidance for developers who want to build, test, and contribute to the codebase.
For information about the automated code generation pipeline that creates the Dota 2 API, see page 5. For details about the CI/CD workflows including security scanning and quality assurance, see page 6.2.
The go-dota2 project requires a standard Go development environment with additional tooling for protocol buffer compilation and code generation.
aptre): The project utilizes go run github.com/aperturerobotics/common/cmd/aptre as a unified CLI for linting, formatting, and dependency management Makefile4Makefile.The project leverages aptre to manage development tools. This avoids manual installation of various binaries and ensures version consistency across different development environments.
Development Tools Orchestrated by aptre
| Tool | Purpose | Makefile Target |
|---|---|---|
golangci-lint | Comprehensive Go linting | make lint Makefile40-41 |
go-mod-outdated | Dependency update analysis | make outdated Makefile32-33 |
goimports | Go import formatting | make format Makefile53 |
gofumpt | Enhanced Go code formatting | make format Makefile54 |
aptre fix | Automatic lint fixing | make fix Makefile44-45 |
Sources: Makefile1-55 .github/workflows/tests.yml19
The project uses a Makefile-based build system that orchestrates multiple build phases including dependency management, code generation, and testing.
Makefile Target Dependencies and Outputs
Sources: Makefile1-55 .github/workflows/tests.yml44-49
The build system provides several key targets for different development workflows:
| Target | Command Executed | Dependencies | Output |
|---|---|---|---|
make vendor | go mod vendor | go.mod, go.sum | vendor/ directory Makefile12-13 |
make test | go test -v ./... | None (Local Go) | Test results Makefile48-49 |
make lint | $(APTRE) lint | vendor/ | Lint analysis report Makefile40-41 |
make format | $(APTRE) format | All .go files | Formatted source code Makefile52-55 |
make gen | go run ./cmd/generate | cmd/generate | Full code generation pipeline Makefile28-29 |
make genproto | $(APTRE) generate ... | vendor/ | Protocol buffer Go files Makefile16-17 |
make apigen | go run . generate-api | apigen/ | Generated API methods Makefile24-25 |
make outdated | $(APTRE) outdated | go.mod | Dependency status report Makefile32-33 |
Sources: Makefile1-55
The project implements a comprehensive testing strategy with both local and CI-based test execution. The test workflow is defined in both the Makefile for local execution and the GitHub Actions workflow for CI.
Test Execution Sequence
Sources: Makefile40-55 .github/workflows/tests.yml44-49
The project uses Go module vendoring (go mod vendor) to create a local copy of all dependencies in the vendor/ directory Makefile13 This ensures:
The vendoring step is explicitly required for genproto targets to ensure the generation tool has access to the correct dependency versions Makefile16
Sources: Makefile12-17 .github/workflows/tests.yml44-45
The project uses GitHub Actions for continuous integration. The test workflow is defined in .github/workflows/tests.yml.
Test Workflow: .github/workflows/tests.yml Step-by-Step Execution
Sources: .github/workflows/tests.yml1-50
The CI pipeline implements two cache layers to reduce build time and speed up test execution. The caching mechanism uses actions/cache@v5.0.5 .github/workflows/tests.yml34
Cache Configuration Details
| Cache Type | Path Variable | Cache Key |
|---|---|---|
| Go Build Cache | ${{ steps.go-cache-paths.outputs.go-build }} | ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} .github/workflows/tests.yml36-37 |
| Go Module Cache | ${{ steps.go-cache-paths.outputs.go-mod }} | ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} .github/workflows/tests.yml42-43 |
The cache paths are dynamically discovered using go env .github/workflows/tests.yml31-32
A separate workflow, update-protos.yml, handles the periodic synchronization of Dota 2 protocol definitions.
generator/Protobufs to the latest HEAD .github/workflows/update-protos.yml23make gen to run the full pipeline, including cmd/generate and apigen .github/workflows/update-protos.yml32.pb.go and API files .github/workflows/update-protos.yml46-53Refresh this wiki