diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..a44ec3b --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,45 @@ +# Golang CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-go/ for more details +references: + # Common configuration for all jobs + defaults: &defaults + docker: + - image: circleci/golang:1.9 + working_directory: /go/src/github.com/Azuka/keycloak-admin-go + steps: + - checkout + - run: + name: Install dependencies + command: | + make init-ci + - run: + name: Lint and run tests + command: | + PATH="$(pwd)/bin:$PATH" make lint-ci + make test-circle + - store_test_results: + path: /tmp/test-results + +version: 2 +jobs: + go-1.9: + <<: *defaults + docker: + - image: circleci/golang:1.9 + go-1.10: + <<: *defaults + docker: + - image: circleci/golang:1.10 + go-1.11: + <<: *defaults + docker: + - image: circleci/golang:1.11 + +workflows: + version: 2 + test-all-go-versions: + jobs: + - go-1.9 + - go-1.10 + - go-1.11 \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..08b7ab1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,18 @@ +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Environment (please complete the following information):** + - `go version` [e.g. `go version go1.11.1 darwin/amd64`] + +**Additional context** +Add any other context about the problem here. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..6e74a07 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,11 @@ +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.gitignore b/.gitignore index 24f4f3b..20f0dbe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /.idea /vendor +/bin /lint.json /.testCoverage.txt* \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ab2c93b..40b7506 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,6 @@ -# This file is a template, and might need editing before it works on your project. -image: circleci/golang:1.10 +image: circleci/golang:1.11 variables: - # Please edit to your GitLab project REPO_NAME: github.com/Azuka/keycloak-admin-go cache: @@ -32,11 +30,4 @@ unit: stage: test script: - cd $GOPATH/src/$REPO_NAME - - make test-ci - - env | sort - -lint: - stage: test - script: - - cd $GOPATH/src/$REPO_NAME - - make lint-ci \ No newline at end of file + - make test-ci \ No newline at end of file diff --git a/Gopkg.lock b/Gopkg.lock index 3e76e44..e58ccb5 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -10,32 +10,24 @@ version = "v2.0.0" [[projects]] - digest = "1:a2c1d0e43bd3baaa071d1b9ed72c27d78169b2b269f71c105ac4ba34b1be4a39" + digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec" name = "github.com/davecgh/go-spew" packages = ["spew"] pruneopts = "UT" - revision = "346938d642f2ec3594ed81d874461961cd0faa76" - version = "v1.1.0" + revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" + version = "v1.1.1" [[projects]] - digest = "1:2ff22b45e9aa8f80ea4a4687f6f9d714a31f1b6c074a223671ae7ce837d4389c" - name = "github.com/go-resty/resty" - packages = ["."] - pruneopts = "UT" - revision = "fccc498aed22c31ff3768bcac00795f94149a21d" - version = "v1.7.0" - -[[projects]] - digest = "1:15042ad3498153684d09f393bbaec6b216c8eec6d61f63dff711de7d64ed8861" + digest = "1:97df918963298c287643883209a2c3f642e6593379f97ab400c2a2e219ab647d" name = "github.com/golang/protobuf" packages = ["proto"] pruneopts = "UT" - revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265" - version = "v1.1.0" + revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5" + version = "v1.2.0" [[projects]] branch = "master" - digest = "1:4429b79947e9af3ccf562cdde4ca61934c7e229726a5afd6527151a91f636a5d" + digest = "1:aa3d8d42865c42626b5c1add193692d045b3188b1479f0a0a88690d21fe20083" name = "github.com/mailru/easyjson" packages = [ ".", @@ -44,7 +36,7 @@ "jwriter", ] pruneopts = "UT" - revision = "d5012789d6659eeed305f54c1b1542e7b65829e6" + revision = "60711f1a8329503b04e1c88535f419d0bb440bff" [[projects]] digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" @@ -76,7 +68,7 @@ [[projects]] branch = "master" - digest = "1:eab31099394d4bae3da2810d726bb38165e16368244e3ce76fe07d27a3a51fc9" + digest = "1:ea6ed8fabeb1373bd53b9398248676eb52ec139c788450b316a078b5a06387a0" name = "golang.org/x/net" packages = [ "context", @@ -85,18 +77,18 @@ "publicsuffix", ] pruneopts = "UT" - revision = "c4299a1a0d8524c11563db160fbf9bddbceadb21" + revision = "04a2e542c03f1d053ab3e4d6e5abcd4b66e2be8e" [[projects]] branch = "master" - digest = "1:af19f6e6c369bf51ef226e989034cd88a45083173c02ac4d7ab74c9a90d356b7" + digest = "1:1bce229fad01cbad9bd00e70ca32afff25ac2cea3dd710d50f88c967c1c3df65" name = "golang.org/x/oauth2" packages = [ ".", "internal", ] pruneopts = "UT" - revision = "3d292e4d0cdc3a0113e6d207bb137145ef1de42f" + revision = "9dcd33a902f40452422c2367fefcb95b54f9f8f8" [[projects]] digest = "1:a2ab62866c75542dd18d2b069fec854577a20211d7c0ea6ae746072a1dccdd18" @@ -122,7 +114,7 @@ version = "v0.3.0" [[projects]] - digest = "1:328b5e4f197d928c444a51a75385f4b978915c0e75521f0ad6a3db976c97a7d3" + digest = "1:6247f76e55a1e1a5c19a81e2d4b4dff6730461eeb5bbb0a16dd4a8ec8637ee93" name = "google.golang.org/appengine" packages = [ "internal", @@ -134,8 +126,8 @@ "urlfetch", ] pruneopts = "UT" - revision = "b1f26356af11148e710935ed1ac8a7f5702c7612" - version = "v1.1.0" + revision = "ae0ab99deb4dc413a2b4bd6c8bdd0eb67f1e4d06" + version = "v1.2.0" [[projects]] branch = "v1" @@ -145,12 +137,19 @@ pruneopts = "UT" revision = "8007e27cdb3239fcfc95c1274d7d8cbcc68b7d52" +[[projects]] + digest = "1:b7fc4c3fd91df516486f53cc86f4b55a0c815782dbe852c5a19cce8e6c577aac" + name = "gopkg.in/resty.v1" + packages = ["."] + pruneopts = "UT" + revision = "d4920dcf5b7689548a6db640278a9b35a5b48ec6" + version = "v1.9.1" + [solve-meta] analyzer-name = "dep" analyzer-version = 1 input-imports = [ "github.com/cenkalti/backoff", - "github.com/go-resty/resty", "github.com/mailru/easyjson", "github.com/mailru/easyjson/jlexer", "github.com/mailru/easyjson/jwriter", @@ -161,6 +160,7 @@ "golang.org/x/net/context/ctxhttp", "golang.org/x/oauth2", "gopkg.in/jarcoal/httpmock.v1", + "gopkg.in/resty.v1", ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 6cef022..b11ae6f 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -26,7 +26,7 @@ [[constraint]] - name = "github.com/go-resty/resty" + name = "gopkg.in/resty.v1" version = "1.7.0" [[constraint]] diff --git a/Makefile b/Makefile index e4fa76b..e50ae43 100644 --- a/Makefile +++ b/Makefile @@ -19,10 +19,9 @@ CI_TEST_REPORTS ?= /tmp/test-results .PHONY: init-ci init-ci: @echo "$(OK_COLOR)==> Installing minimal build requirements$(NO_COLOR)" - go get -u github.com/alecthomas/gometalinter - gometalinter --install + dep ensure -v + curl -L https://git.io/vp6lP | sh go get -u github.com/jstemmer/go-junit-report - dep ensure .PHONY: init init: init-ci @@ -86,6 +85,14 @@ test-ci: go test -v -short -race -cover -coverprofile .testCoverage.txt $(GO_PACKAGES) | tee >(go-junit-report > $(CI_TEST_REPORTS)/report.xml); \ sed '/_easyjson.go/d' .testCoverage.txt > .testCoverage.txt.bak; mv .testCoverage.txt.bak .testCoverage.txt; go tool cover -func=.testCoverage.txt" +# CircleCI test +.PHONY: test-circle +test-circle: + @echo "$(OK_COLOR)==> Running circle test$(NO_COLOR)" + mkdir -p $(CI_TEST_REPORTS) + /bin/bash -c "set -euxo pipefail; \ + go test -v -short -race -cover $(GO_PACKAGES) | tee >(go-junit-report > $(CI_TEST_REPORTS)/report.xml) + # CI Lint .PHONY: lint-ci lint-ci: @@ -100,7 +107,10 @@ qt: .PHONY: local-ci local-ci: - @echo "$(OK_COLOR)==> Running CI locally. Did you run brew install gitlab-runner?$(NO_COLOR)" + @echo "$(OK_COLOR)==> Running CI locally. Did you run brew install gitlab-runner and CircleCI?$(NO_COLOR)" + circleci local execute --job go-1.9 + circleci local execute --job go-1.10 + circleci local execute --job go-1.11 brew services start gitlab-runner gitlab-runner exec docker unit gitlab-runner exec docker lint diff --git a/Readme.md b/Readme.md index 9f048a6..0d6f7fc 100644 --- a/Readme.md +++ b/Readme.md @@ -4,6 +4,7 @@ [![pipeline status](https://gitlab.com/Azuka/keycloak-admin-go/badges/master/pipeline.svg)](https://gitlab.com/Azuka/keycloak-admin-go/commits/master) [![coverage report](https://gitlab.com/Azuka/keycloak-admin-go/badges/master/coverage.svg)](https://gitlab.com/Azuka/keycloak-admin-go/commits/master) [![Go Report Card](https://goreportcard.com/badge/github.com/Azuka/keycloak-admin-go)](https://goreportcard.com/report/github.com/Azuka/keycloak-admin-go) +[![CircleCI](https://circleci.com/gh/Azuka/keycloak-admin-go.svg?style=svg)](https://circleci.com/gh/Azuka/keycloak-admin-go) Keycloak admin client in go. @@ -20,6 +21,8 @@ make init make test make integration ``` +### Local CI +- Install CircleCI locally: https://circleci.com/docs/2.0/local-cli ## Wish List - [x] Add authentication integration tests @@ -53,7 +56,7 @@ make integration - [ ] Root ## Thanks to -- https://github.com/go-resty/resty: quick and dirty REST client +- https://gopkg.in/resty.v1: quick and dirty REST client - https://github.com/mailru/easyjson: faster JSON serialization - https://godoc.org/golang.org/x/oauth2: for the shamelessly copied authentication - https://github.com/fatih/gomodifytags: because I'm too lazy to type json struct tags \ No newline at end of file diff --git a/keycloak/client.go b/keycloak/client.go index 10f4d4f..bbe501c 100644 --- a/keycloak/client.go +++ b/keycloak/client.go @@ -11,7 +11,7 @@ import ( "context" "fmt" - "github.com/go-resty/resty" + "gopkg.in/resty.v1" ) const userAgent = "go/keycloak-admin" diff --git a/keycloak/user_service_test.go b/keycloak/user_service_test.go index 6fd9901..4e201ec 100644 --- a/keycloak/user_service_test.go +++ b/keycloak/user_service_test.go @@ -5,10 +5,10 @@ import ( "net/url" "testing" - "github.com/go-resty/resty" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" "gopkg.in/jarcoal/httpmock.v1" + "gopkg.in/resty.v1" ) func ExampleNewUserService() {