Skip to content

Contribute

Sergey Vilgelm edited this page Jan 21, 2020 · 7 revisions

Unit Tests

Tools: Docker and go test

$ docker run -d -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=secret -e KEYCLOAK_IMPORT=/tmp/gocloak-realm.json -v "`pwd`/testdata/gocloak-realm.json:/tmp/gocloak-realm.json" -p 8080:8080 --name keycloak quay.io/keycloak/keycloak -Dkeycloak.profile.feature.upload_scripts=enabled
$ go test -race
PASS
ok      github.com/Nerzal/gocloak/v4    24.513s

Code Style

Tool: https://github.com/golangci/golangci-lint

$ golangci-lint run
lient_test.go:533:2: SA4006: this value of `rpt` is never used (staticcheck)
        rpt, err := client.GetRequestingPartyToken(token.AccessToken, cfg.GoCloak.Realm, RequestingPartyTokenOptions{
        ^
client.go:1517:26: error strings should not be capitalized or end with punctuation or a newline (golint)
                return nil, errors.New("Type of a policy required")
                                       ^
client.go:1593:26: error strings should not be capitalized or end with punctuation or a newline (golint)
                return nil, errors.New("Type of a permission required")

Version Bumping

Tool: https://github.com/sv-tools/bumptag

bumptag tool makes it possible to create a new tag with increased version and an annotation. Usage:

$ bumptag --help
Usage: bumptag [<tagname>]

    <tagname>       The name of the tag to create, must be Semantic Versions 2.0.0 (http://semver.org)
    -e, --edit      Edit an annotation
    -r, --dry-run   Prints an annotation for the new tag
    -s, --silent    Do not show the created tag
    -a, --auto-push Push the created tag automatically
    -m, --major     Increment the MAJOR version
    -n, --minor     Increment the MINOR version (default)
    -p, --patch     Increment the PATCH version
        --version   Show a version of the bumptag tool
        --find-tag  Show the last tag, can be useful for CI tools

Examples:

bumptag: creates a tag with +1 for minor (v1.0.0 -> v1.1.0)
bumptag -p: increase patch (v1.0.0 -> v1.0.1), for bug fixes
bumptag v2.10.4: creates the v2.10.4 tag

The script also generates an annotation with all commits merged since the last tag.

And don't forget to execute:

$ git push origin --tags

or

$ bumptag -a
Clone this wiki locally