Makefile
automates common development tasks for this Go project.
The main commands are:
make # Short form for 'make all'.
make all # The default command. It formats, vets, and builds all the Go commands.
make build # Compile all commands and places the binaries in the bin/ directory.
make clean # Delete the bin/ directory to clean up build files.
make fmt # Format all Go code in the project.
make help # Display a help message with all available commands.
make install # Install all the commands to your GOPATH/bin, making them executable from your terminal.
make test # Run all the tests in the project.
make tidy # Tidy the go.mod and go.sum files.
make vet # Analyze the code for potential issues.git_tree_go/
├── cmd/ # Command implementations
│ ├── git-commitAll/
│ ├── git-evars/
│ ├── git-exec/
│ ├── git-list-executables/
│ ├── git-replicate/
│ ├── git-treeconfig/
│ └── git-update/
├── internal/ # Internal packages
│ ├── abstract_command.go
│ ├── config.go
│ ├── roots.go
│ ├── git_tree_walker.go
│ ├── log.go
│ ├── task.go
│ ├── thread_pool.go
│ └── zowee_optimizer.go
├── go.mod
├── go.sum
├── Makefile
└── README.md
Build just one command:
make git-commitAll
make git-evars
make git-exec
make git-list-executables
make git-replicate
make git-treeconfig
make git-updateExample:
$ make
Formatting code...
internal/util.go
internal/task.go
Vetting code...
Building all commands...
Building git-commitAll...
Building git-evars...
Building git-exec...
Building git-replicate...
Building git-treeconfig...
Building git-update...
Build complete!Commands such as git-exec can be run several ways.
The most direct is to use go run and point to the source of the file to compile and run.
Unlike go build, go run does not leave a permanent executable file in your project directory.
$ go run ./cmd/git-exec $work pwdAlternatively, build everything to bin/ first:
$ make build
$ ./bin/git-exec $work pwdAlternatively, build just the command to bin/ first:
$ make git-exec
$ ./bin/git-exec $work pwdMake and run:
$ make test
Running tests...
? git-tree-go/cmd/git-commitAll [no test files]
? git-tree-go/cmd/git-evars [no test files]
? git-tree-go/cmd/git-exec [no test files]
? git-tree-go/cmd/git-replicate [no test files]
? git-tree-go/cmd/git-treeconfig [no test files]
? git-tree-go/cmd/git-update [no test files]
=== RUN TestAbstractCommand_Initialization
--- PASS: TestAbstractCommand_Initialization (0.00s)
=== RUN TestAbstractCommand_ArgumentHandling
--- PASS: TestAbstractCommand_ArgumentHandling (0.00s)
=== RUN TestAbstractCommand_ParseCommonFlags_Quiet
--- PASS: TestAbstractCommand_ParseCommonFlags_Quiet (0.00s)
=== RUN TestAbstractCommand_ParseCommonFlags_Serial
--- PASS: TestAbstractCommand_ParseCommonFlags_Serial (0.00s)
=== RUN TestAbstractCommand_ParseCommonFlags_Verbose
FAIL git-tree-go/internal 0.003s
FAIL
make: *** [Makefile:49: test] Error 1Or just look at failures:
$ make test | grep FAIL
--- FAIL: TestRoots_Level1_OnePathWithManySlashes (0.00s)
--- FAIL: TestRoots_DeeperLevel (0.00s)
--- FAIL: TestZoweeOptimizer_MultipleBranchesFromCommonRoot (0.00s)
--- FAIL: TestZoweeOptimizer_ComplexNesting (0.00s)
FAIL
FAIL git-tree-go/internal 0.677s
FAILRun all tests:
$ make test:allRun tests for a specific command:
$ go test ./cmd/git-commitAll/
$ go test ./cmd/git-exec/
$ go test ./cmd/git-evars/
$ go test ./cmd/git-replicate/
$ go test ./cmd/git-update/Run with verbose output:
$ go test -v ./cmd/...Skip integration tests (short mode):
$ go test -short ./cmd/...Add this to ~/.bashrc:
eval `ssh-agent -s`
ssh-add ~/.ssh/id_rsa
export GITHUB_USERNAME=mslinn
# Create classic token at https://github.com/settings/tokens with repo scope
export GITHUB_TOKEN=your_personal_access_token
For a new release, you need to update internal/version.go to a new version
(e.g., 0.1.14) and ensure CHANGELOG.md does not yet have that version.
Run:
$ ./releaseOr:
$ make releaseThis project uses GoReleaser and GitHub Actions for automated releases. To create a new release:
The easiest way to create a release:
$ ./scripts/release 1.2.3This script will:
- Validate the version format
- Check that your working directory is clean
- Run tests
- Create and push a version tag
- Trigger the GitHub Actions release workflow
Alternatively, create and push a tag manually:
$ git tag -a v1.2.3 -m "Release v1.2.3"
$ git push origin v1.2.3Once the tag is pushed, GitHub Actions will automatically:
- Build binaries for all platforms (Linux, macOS, Windows on amd64 and arm64)
- Create a GitHub release
- Upload all binaries and checksums
- Generate release notes
For more details, see RELEASING.md.