# This is executable Markdown that's tested on CI.
# How is that possible? See https://gist.github.com/bwoods/1c25cb7723a06a076c2152a2781d4d49
set -o errexit -o nounset -o xtrace
alias ~~~=":<<'~~~sh'";:<<'~~~sh'
This repo includes:
- 🧱 Latest version of Bazel and dependencies
- 📦 Curated bazelrc flags via [bazelrc-preset.bzl]
- 🧰 Developer environment setup with [bazel_env.bzl]
- ✅ Pre-commit hooks for automatic linting and formatting
- 📚 go.mod package integration
Note
You can customize languages and features with the interactive wizard in the aspect init command.
init is an alternative to this starter repo, which was generated using the 'go' preset.
See https://docs.aspect.build/cli/overview
First, we recommend you setup a Bazel-based developer environment with direnv.
- install https://direnv.net/docs/installation.html
- run
direnv allowand follow the prompts tobazel run //tools:bazel_env
This isn't strictly required, but the commands which follow assume that needed tools are on the PATH,
so skipping direnv means you're responsible for installing them yourself.
First, run scaffold which is on the PATH thanks to direnv. This creates a new command in the repo.
scaffold new https://github.com/alexeagle/cowsay-go-scaffold Project=cowsayNext, create or update the go.mod file, including the nmyk.io/cowsay dependency pinning. This uses the Bazel-managed go SDK.
go mod tidyNow we generate BUILD files:
bazel run gazelleWe can see that the app builds now:
bazel build cowsay/cmd/helloLet's run the application, starting a server in the background.
bazel run cowsay/cmd/hello &
# Wait for the server
while ! nc -z localhost 8080; do
sleep 0.5
doneFinally we can hit that server to verify the application output matches expectation:
output=$(curl localhost:8080)
echo "${output}" | grep -q "Hello, world" || {
echo >&2 "Wanted output containing 'Hello, world' but got '${output}'"
exit 1
}TODO: Build an OCI container for the target platform with bazel build //cmd/hello:image.load