Skip to content

Commit

Permalink
Update build and imports, request templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
Azuka committed Oct 22, 2018
1 parent 80c5ae7 commit c1091f2
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 43 deletions.
45 changes: 45 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.idea
/vendor
/bin
/lint.json
/.testCoverage.txt*
13 changes: 2 additions & 11 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
- make test-ci
48 changes: 24 additions & 24 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


[[constraint]]
name = "github.com/go-resty/resty"
name = "gopkg.in/resty.v1"
version = "1.7.0"

[[constraint]]
Expand Down
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
5 changes: 4 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion keycloak/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"context"
"fmt"

"github.com/go-resty/resty"
"gopkg.in/resty.v1"
)

const userAgent = "go/keycloak-admin"
Expand Down
2 changes: 1 addition & 1 deletion keycloak/user_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit c1091f2

Please sign in to comment.