Skip to content

Latest commit

 

History

History
175 lines (122 loc) · 4.13 KB

CONTRIBUTING.md

File metadata and controls

175 lines (122 loc) · 4.13 KB

Contribution Guide

Package Publication

The following section refers to publishing package(s) to https://pkg.go.dev.

  1. Establish a LICENSE to the project.
  2. Ensure dependencies are updated.
    go mod tidy
  3. Sync the working tree's HEAD with its remote.
    git add .
    git commit --message "<commit-msg>"
    git push --set-upstream origin main
  4. Assign a tag and push.
    git tag "v$(head VERSION)" && git push origin "v$(head VERSION)"
  5. Make the module available, publicly.
    GOPROXY=proxy.golang.org go list -mutex "github.com/x-ethr/example@v$(head VERSION)"

Adding the package to pkg.go.dev may need to be requested. Navigate to the mirror's expected url, and follow instructions for requesting the addition.

Upon successful request, a message should be displayed:

We're still working on “github.com/x-ethr/example”. Check back in a few minutes!

For any other issues, consult the official documentation.

Testing

Basic
go test ./...
Testing with Useful Logging
go test -c "./path-with-tests" -o pkg.test -json

go tool test2json -t ./pkg.test -test.failfast -test.fullpath -test.v -test.paniconexit0

Simplified

go test ./... -json

Pre-Commit

The following project makes use of pre-commit for local-development git-hooks. These hooks are useful in cases such as preventing secrets from getting pushed into version-control.

See the .pre-commit-config.yaml for implementation specifics.

Local Setup

  1. Install pre-commit from https://pre-commit.com/#install.
  2. Auto-update the config to the latest repos' versions by executing pre-commit autoupdate.
  3. Install with pre-commit install.

Deployment & Initial Setup (Maintainers)

The following section is intended only for project maintainers & developers.

  • Please see the getting started section for installation and upgrade instructions.
  1. Install goreleaser if it isn't installed

    brew install goreleaser/tap/goreleaser
  2. Initialize the repository for new repositories

    goreleaser init
  3. Test the snapshot without VCS deployment

    goreleaser release --snapshot --clean
  4. Configure the default system's local gitlab_token or github_token secret

    mkdir -p ~/.config/goreleaser && touch ~/.config/goreleaser/gitlab_token
    mkdir -p ~/.config/goreleaser && touch ~/.config/goreleaser/github_token
  5. Commit and push to VCS

    git add . && git commit -m "CI - Example" && git push
  6. List git tags to get a version that isn't already established

    git tag --list
  7. Using the output from above, increment the version and push a new tag

    git tag -a v0.0.1 -m "Bump: Initial Release" && git push origin v0.0.1
  8. Create and push a new release

    goreleaser release --clean
  9. Update the Cask if already established

    brew update
  10. Install the package (see the installation section)

General Command Reference(s)

Update the configuration's upstreams

pre-commit autoupdate

Install pre-commit to local instance

pre-commit install

Documentation

Tool godoc is required to render the documentation, which includes examples.

Installation Steps:

  1. Install godoc.
    go install golang.org/x/tools/cmd/godoc@latest
  2. Backup shell profile and update PATH.
    cp ~/.zshrc ~/.zshrc.bak
    printf "export PATH=\"\${PATH}:%s\"\n" "$(go env --json | jq -r ".GOPATH")/bin" >> ~/.zshrc
    source ~/.zshrc
  3. Start the godoc server.
    godoc -http=:6060
  4. Open the webpage.
    open "http://localhost:6060/pkg/"