Welcome to PBnJ! We are really excited to have you. Please use the following guide on your contributing journey. Thanks for contributing!
PBnJ is a service that handles interacting with many different BMC models. It is part of the Tinkerbell stack and provides the glue for machine provisioning by enabling machine restarts and setting next boot devices.
Details and diagrams for PBnJ are found here.
Details on PBnJ's code structure is found here
Please read and understand the DCO found here.
Please read and understand the code of conduct found here.
-
Install Go
PBnJ requires Go 1.15 or later.
-
Install Docker
PBnJ uses Docker for protocol buffer code generation, container image builds and for the Ruby client example. Most versions of Docker will work.
The items below are nice to haves, but not hard requirements for development
-
Install Evans
Evans is a gRPC client. There is a make target (
make evans
) that will setup the connection to the locally running server (make run-server
) -
Install golangci-lint
golangci-lint is used in CI for lint checking and should be run locally before creating a PR.
-
Install jq
jq is used when running the PBnJ server to pretty print the logs.
-
Install buf
buf is used for linting the protocol buffers.
To build PBnJ using your local Go environment, run:
# will build a binary in the native OS format
make build
# you can specify the OS binary format
make linux
make darwin
# Built binaries can be found in ./bin/
To build the PBnJ container image, run:
make image
# Built image will be named pbnj:local
To execute the unit tests, run:
make test
# to get code coverage numbers, run:
make cover
To execute linting, run:
# runs golangci-lint
make lint
# runs goimports
make goimports
# CI runs go vet, there's no make target for that since its built in.
go vet ./...
The test/ directory holds the code for running functional tests against real hardware. See the README in the test directory for details.
Locally, PBnJ can be run in two different ways.
-
Local direct
make run-server
-
Local with Docker
# build the container image make image # run the image make run-image
To start a PBnJ client, after getting PBnJ running with one of the two options above, run:
make evans
PBnJ uses a fork and pull request model. See this doc for more details.
PBnJ uses GitHub Actions for CI. The workflow is found in .github/workflows/ci.yaml. It is run for each commit and PR. The container image building only happens once a PR is merged into the main line.
PBnJ does run code coverage with each PR. Coverage thresholds are not currently enforced. It is always nice and very welcomed to add tests and keep or increase the code coverage percentage.
This checklist is a helper to make sure there's no gotchas that come up when you submit a PR.
- You've reviewed the code of conduct
- All commits are DCO signed off
- Code is formatted and linted
- Code builds successfully
- All tests are passing
- Code coverage percentage. (main line is the base with which to compare)