-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
Integration tests
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,48 @@ | ||
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 . | ||
docker build -f .circleci/node.Dockerfile -t gqlgen/node . | ||
- run: | ||
name: "golang tests" | ||
command: docker run --rm gqlgen/golang .circleci/test.sh | ||
|
||
- run: | ||
name: "integration tests" | ||
command: | | ||
function cleanup { | ||
echo "Cleaning up containers..." | ||
docker kill $SERVER_CONTAINER 1>/dev/null 2>/dev/null || true | ||
docker rm --force -v $SERVER_CONTAINER 1>/dev/null 2>/dev/null || true | ||
} | ||
trap cleanup EXIT | ||
SERVER_CONTAINER=$(docker run -d \ | ||
-e PORT=1234 \ | ||
--name integration_server \ | ||
gqlgen/golang go run ./integration/server/server.go \ | ||
) | ||
sleep 2 | ||
docker run \ | ||
-e SERVER_URL=http://integration_server:1234/query \ | ||
--link=integration_server \ | ||
gqlgen/node ../.circleci/integration.sh | ||
echo "### server logs" | ||
docker logs $SERVER_CONTAINER | ||
exit $(docker inspect $SERVER_CONTAINER --format='{{.State.ExitCode}}') | ||
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/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
echo "### running jest integration spec" | ||
./node_modules/.bin/jest --color | ||
|
||
|
||
echo "### validating introspected schema" | ||
./node_modules/.bin/graphql get-schema | ||
|
||
if ! diff <(tail -n +3 schema-expected.graphql) <(tail -n +3 schema-fetched.graphql) ; then | ||
echo "The expected schema has changed, you need to update schema-expected.graphql with any expected changes" | ||
exit 1 | ||
fi | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM node:10 | ||
|
||
WORKDIR /gqlgen/integration | ||
|
||
|
||
COPY integration/package*.json /gqlgen/integration/ | ||
RUN npm ci | ||
|
||
COPY . /gqlgen/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
echo "### go generating" | ||
go generate $(go list ./... | grep -v codegen/tests) | ||
|
||
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 $(go list ./... | grep -v codegen/tests) | ||
|
||
echo "### linting" | ||
gometalinter --vendor ./... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/**/node_modules | ||
/codegen/tests/gen | ||
/vendor |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["env"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"projects": { | ||
"Project Name": { | ||
"schemaPath": "schema-fetched.graphql", | ||
"extensions": { | ||
"endpoints": { | ||
"dev": { | ||
"url": "${env:SERVER_URL}" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |