Skip to content

Commit

Permalink
Use docker in docker for the existing testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Scarr committed Aug 8, 2018
1 parent 0eb08ab commit f372b1c
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 20 deletions.
26 changes: 11 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
version: 2
jobs:
build:
working_directory: /app
docker:
- image: golang:1.9
working_directory: /go/src/github.com/99designs/gqlgen
steps: &steps
- image: docker:18
steps:
- checkout
- run: >
curl -L -o /bin/dep https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 &&
chmod +x /bin/dep &&
go get -u github.com/alecthomas/gometalinter github.com/vektah/gorunpkg &&
gometalinter --install &&
dep ensure -vendor-only
- run: go install -v . && go get -u github.com/vektah/dataloaden github.com/pkg/errors
- run: go generate ./... && if [[ $(git --no-pager diff) ]] ; then echo "you need to run go generate" ; git --no-pager diff ; exit 1 ; fi
- run: go vet ./...
- run: go test -race ./...
- run: gometalinter --vendor ./...

- setup_remote_docker:
docker_layer_caching: true
- run:
name: "docker build"
command: docker build -f .circleci/golang.Dockerfile -t gqlgen/golang .
- run:
name: "golang tests"
command: docker run --rm gqlgen/golang .circleci/test.sh
12 changes: 12 additions & 0 deletions .circleci/golang.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM golang:1.10

RUN curl -L -o /bin/dep https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 && chmod +x /bin/dep
RUN go get -u github.com/alecthomas/gometalinter github.com/vektah/gorunpkg
RUN gometalinter --install

WORKDIR /go/src/github.com/99designs/gqlgen

COPY Gopkg.* /go/src/github.com/99designs/gqlgen/
RUN dep ensure -v --vendor-only

COPY . /go/src/github.com/99designs/gqlgen/
17 changes: 17 additions & 0 deletions .circleci/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -eu

echo "+++ generating"
go generate -v ./...
if [[ $(git --no-pager diff) ]] ; then
echo "you need to run go generate"
git --no-pager diff
exit 1
fi

echo "+++ running testsuite"
go test -race ./...

echo "+++ linting"
gometalinter --vendor ./...
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/example/chat/node_modules
/codegen/tests/gen
/vendor
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ indent_size = 4
[*.{go,gotpl}]
indent_style = tab

[*.{yml}]
[*.yml]
indent_size = 2

# These often end up with go code inside, so lets keep tabs
Expand Down
6 changes: 3 additions & 3 deletions example/scalars/resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ func (r *queryResolver) User(ctx context.Context, id external.ObjectID) (*model.
ID: id,
Name: fmt.Sprintf("Test User %d", id),
Created: time.Now(),
Address: model.Address{ID: 1, Location: &model.Point{1, 2}},
Address: model.Address{ID: 1, Location: &model.Point{X: 1, Y: 2}},
Tier: model.TierC,
}, nil
}

func (r *queryResolver) Search(ctx context.Context, input model.SearchArgs) ([]model.User, error) {
location := model.Point{1, 2}
location := model.Point{X: 1, Y: 2}
if input.Location != nil {
location = *input.Location
}
Expand Down Expand Up @@ -70,5 +70,5 @@ func (r *userResolver) PrimitiveResolver(ctx context.Context, obj *model.User) (
}

func (r *userResolver) CustomResolver(ctx context.Context, obj *model.User) (model.Point, error) {
return model.Point{5, 1}, nil
return model.Point{X: 5, Y: 1}, nil
}
2 changes: 1 addition & 1 deletion test/resolvers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (r *testResolver) User() UserResolver {
type elementResolver struct{ *testResolver }

func (r *elementResolver) Child(ctx context.Context, obj *models.Element) (models.Element, error) {
return models.Element{obj.ID * 10}, nil
return models.Element{ID: obj.ID * 10}, nil
}

func (r *elementResolver) Error(ctx context.Context, obj *models.Element) (bool, error) {
Expand Down

0 comments on commit f372b1c

Please sign in to comment.