Skip to content

Commit

Permalink
Merge branch 'master' into search-address-example
Browse files Browse the repository at this point in the history
  • Loading branch information
rikinsk authored Feb 28, 2019
2 parents 2a58cb8 + 7d61422 commit 526f5a9
Show file tree
Hide file tree
Showing 429 changed files with 28,456 additions and 5,441 deletions.
63 changes: 62 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ refs:
GRAPHQL_ENGINE: '/build/_server_output/graphql-engine'
command: |
apt-get update
apt install --yes jq
apt install --yes jq curl
OUTPUT_FOLDER=/build/_server_test_output/$PG_VERSION .circleci/test-server.sh
- run:
name: Generate coverage report
Expand Down Expand Up @@ -214,6 +214,37 @@ jobs:
- image: circleci/postgres:9.5-alpine-postgis
<<: *test_pg_env

test_cli_with_last_release:
docker:
- image: hasura/graphql-engine-cli-builder:v0.3
- image: circleci/postgres:10-alpine
environment:
POSTGRES_USER: gql_test
POSTGRES_DB: gql_test
working_directory: /go/src/github.com/hasura/graphql-engine
steps:
- checkout
- attach_workspace:
at: /build
- restore_cache:
keys:
- cli-vendor-{{ checksum "cli/Gopkg.toml" }}-{{ checksum "cli/Gopkg.lock" }}
- run:
name: get cli dependencies
working_directory: cli
command: make deps
- save_cache:
key: cli-vendor-{{ checksum "cli/Gopkg.toml" }}-{{ checksum "cli/Gopkg.lock" }}
paths:
- cli/vendor
- *wait_for_postgres
- run:
name: test cli
command: .circleci/test-cli-with-last-release.sh
- store_artifacts:
path: /build/_cli_output
destination: cli

# test and build cli
test_and_build_cli:
docker:
Expand Down Expand Up @@ -305,6 +336,28 @@ jobs:
paths:
- _console_output

# test server upgrade from last version to current build
test_server_upgrade:
docker:
- image: hasura/graphql-engine-upgrade-tester:v0.4
environment:
HASURA_GRAPHQL_DATABASE_URL: postgres://gql_test:@localhost:5432/gql_test
- image: circleci/postgres:10-alpine
environment:
POSTGRES_USER: gql_test
POSTGRES_DB: gql_test
working_directory: ~/graphql-engine
steps:
- checkout
- attach_workspace:
at: /build
- run:
name: upgrade_test
command: .circleci/server-upgrade/run.sh
- store_artifacts:
path: /build/_server_output
destination: server

deploy:
docker:
- image: hasura/graphql-engine-deployer:v0.3
Expand Down Expand Up @@ -343,13 +396,20 @@ workflows:
<<: *filter_only_vtags
requires:
- build_server
- test_server_upgrade:
<<: *filter_only_vtags
requires:
- build_server
- all_server_tests_pass:
<<: *filter_only_vtags
requires:
- pytest_server_pg_11.1
- pytest_server_pg_10.6
- pytest_server_pg_9.6
- pytest_server_pg_9.5
- test_server_upgrade
- test_cli_with_last_release:
<<: *filter_only_vtags
- test_and_build_cli:
<<: *filter_only_vtags
requires:
Expand All @@ -358,6 +418,7 @@ workflows:
<<: *filter_only_vtags
requires:
- test_and_build_cli
- test_cli_with_last_release
- deploy:
<<: *filter_only_vtags_dev_release_branches
requires:
Expand Down
7 changes: 7 additions & 0 deletions .circleci/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ setup_gcloud() {
gcloud --quiet config set project ${GOOGLE_PROJECT_ID}
}

# push the server binary to google cloud storage
push_server_binary() {
gsutil cp /build/_server_output/graphql-engine \
gs://graphql-engine-cdn.hasura.io/server/latest/linux-amd64
}

# skip deploy for pull requests
if [[ -n "${CIRCLE_PR_NUMBER:-}" ]]; then
echo "not deploying for PRs"
Expand Down Expand Up @@ -134,6 +140,7 @@ deploy_console
deploy_server
if [[ ! -z "$CIRCLE_TAG" ]]; then
deploy_server_latest
push_server_binary
build_and_push_cli_migrations_image
CHANGELOG_TEXT=$(changelog server)
CHANGELOG_TEXT+=$(changelog cli)
Expand Down
3 changes: 3 additions & 0 deletions .circleci/server-upgrade/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_output
node_modules
yarn.lock
6 changes: 6 additions & 0 deletions .circleci/server-upgrade/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:11-slim

RUN apt-get update && apt-get install -y \
libpq5 \
netcat \
&& curl -L https://github.com/hasura/graphql-engine/raw/master/cli/get.sh | INSTALL_PATH=/bin bash
1 change: 1 addition & 0 deletions .circleci/server-upgrade/api-server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
13 changes: 13 additions & 0 deletions .circleci/server-upgrade/api-server/echo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const echo = (req, res) => {
try {
const { event: { op, data }, table: { name, schema } } = req.body;
const response = { message: 'received event', data: { op, data, name, schema } };
console.log('--->', response);
return res.json(response);
} catch (err) {
console.error('xxx>', err);
return res.status(500).json({ error: err.message || err });
}
};

export default echo;
15 changes: 15 additions & 0 deletions .circleci/server-upgrade/api-server/graphql.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { buildSchema } from 'graphql';

const schema = buildSchema(`
type Query {
hello: String
}
`);

const root = {
hello: () => {
return 'Hello world!';
}
};

export { schema, root };
23 changes: 23 additions & 0 deletions .circleci/server-upgrade/api-server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import express from 'express';
import morgan from 'morgan';
import graphqlHTTP from 'express-graphql';

import echo from './echo';
import { schema, root } from './graphql';

const app = express();
app.use(express.json());
app.use(morgan('tiny'));

app.get('/', (req, res) => res.send('api server listening for requests'));

app.post('/trigger/echo', echo);

app.use('/remote-schema/hello', graphqlHTTP({
schema: schema,
rootValue: root,
graphiql: process.env.ENABLE_GRAPHIQL === 'true' ? true : false,
}));

const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`event triggers listening on port ${port}!`));
23 changes: 23 additions & 0 deletions .circleci/server-upgrade/api-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "api-server",
"version": "1.0.0",
"description": "api server for event triggers and remote schemas",
"main": "index.js",
"author": "shahidhk",
"license": "MIT",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon -r esm index.js",
"start-prod": "node -r esm index.js"
},
"devDependencies": {
"nodemon": "^1.18.10"
},
"dependencies": {
"esm": "^3.2.6",
"express": "^4.16.4",
"express-graphql": "^0.7.1",
"graphql": "^14.1.1",
"morgan": "^1.9.1"
}
}
1 change: 1 addition & 0 deletions .circleci/server-upgrade/hasura/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
endpoint: http://localhost:8080
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- args:
sql: DROP TABLE "public"."author"
type: run_sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- args:
sql: CREATE TABLE "public"."author"("id" serial NOT NULL, "name" text NOT NULL,
PRIMARY KEY ("id") );
type: run_sql
- args:
name: author
schema: public
type: add_existing_table_or_view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- args:
sql: DROP TABLE "public"."article"
type: run_sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- args:
sql: CREATE TABLE "public"."article"("id" serial NOT NULL, "title" text NOT NULL,
"author_id" integer NOT NULL, PRIMARY KEY ("id") );
type: run_sql
- args:
name: article
schema: public
type: add_existing_table_or_view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- args:
sql: ALTER TABLE "public"."article" DROP CONSTRAINT "article_author_id_fkey"
type: run_sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- args:
sql: ALTER TABLE "public"."article" ADD FOREIGN KEY ("author_id") REFERENCES "public"."author"
("id")
type: run_sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- args:
relationship: authorByauthorId
table:
name: article
schema: public
type: drop_relationship
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- args:
name: authorByauthorId
table:
name: article
schema: public
using:
foreign_key_constraint_on: author_id
type: create_object_relationship
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- args:
relationship: articlesByauthorId
table:
name: author
schema: public
type: drop_relationship
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- args:
name: articlesByauthorId
table:
name: author
schema: public
using:
foreign_key_constraint_on:
column: author_id
table:
name: article
schema: public
type: create_array_relationship
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- args:
role: user
table:
name: author
schema: public
type: drop_insert_permission
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- args:
permission:
allow_upsert: true
check:
id:
_eq: X-Hasura-User-Id
columns:
- name
set:
id: x-hasura-user-id
role: user
table:
name: author
schema: public
type: create_insert_permission
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- args:
role: user
table:
name: author
schema: public
type: drop_select_permission
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- args:
permission:
allow_aggregations: true
columns:
- id
- name
filter:
id:
_eq: X-Hasura-User-Id
limit: null
role: user
table:
name: author
schema: public
type: create_select_permission
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- args:
role: user
table:
name: author
schema: public
type: drop_update_permission
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- args:
permission:
columns:
- name
filter:
id:
_eq: X-Hasura-User-Id
set: {}
role: user
table:
name: author
schema: public
type: create_update_permission
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- args:
role: user
table:
name: author
schema: public
type: drop_delete_permission
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- args:
permission:
filter:
id:
_eq: X-Hasura-User-Id
role: user
table:
name: author
schema: public
type: create_delete_permission
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- args:
role: user
table:
name: article
schema: public
type: drop_insert_permission
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- args:
permission:
allow_upsert: true
check:
author_id:
_eq: X-Hasura-User-Id
columns:
- id
- title
set:
author_id: x-hasura-user-id
role: user
table:
name: article
schema: public
type: create_insert_permission
Loading

0 comments on commit 526f5a9

Please sign in to comment.