diff --git a/.circleci/cli-builder.dockerfile b/.circleci/cli-builder.dockerfile index 8c1d3a7da79d9..fd7e89055bf35 100644 --- a/.circleci/cli-builder.dockerfile +++ b/.circleci/cli-builder.dockerfile @@ -10,10 +10,10 @@ RUN go get github.com/golang/dep/cmd/dep \ # install UPX and netcat RUN apt-get update && apt-get install -y \ - xz-utils netcat libpq5 \ + xz-utils netcat libpq5 postgresql-client \ && curl -Lo /tmp/upx-${upx_version}.tar.xz https://github.com/upx/upx/releases/download/v${upx_version}/upx-${upx_version}-amd64_linux.tar.xz \ && xz -d -c /tmp/upx-${upx_version}.tar.xz \ | tar -xOf - upx-${upx_version}-amd64_linux/upx > /bin/upx \ && chmod a+x /bin/upx \ && apt-get -y auto-remove \ - && rm -rf /var/lib/apt/lists/* \ No newline at end of file + && rm -rf /var/lib/apt/lists/* diff --git a/.circleci/config.yml b/.circleci/config.yml index 93f9fa724fe3c..a76e9c671cc06 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -70,7 +70,7 @@ jobs: # changes only contains files in .ciignore check_build_worthiness: docker: - - image: hasura/graphql-engine-cli-builder:v0.2 + - image: hasura/graphql-engine-cli-builder:v0.3 working_directory: ~/graphql-engine steps: - checkout @@ -81,7 +81,7 @@ jobs: # build the server binary, and package into docker image build_server: docker: - - image: hasura/graphql-engine-server-builder:v0.2 + - image: hasura/graphql-engine-server-builder:v0.3 working_directory: ~/graphql-engine steps: - checkout @@ -137,28 +137,28 @@ jobs: test_server_pg_10.4: <<: *test_server docker: - - image: hasura/graphql-engine-cli-builder:v0.2 + - image: hasura/graphql-engine-cli-builder:v0.3 - image: circleci/postgres:10.4-alpine <<: *test_pg_env test_server_pg_9.6: <<: *test_server docker: - - image: hasura/graphql-engine-cli-builder:v0.2 + - image: hasura/graphql-engine-cli-builder:v0.3 - image: circleci/postgres:9.6-alpine <<: *test_pg_env test_server_pg_9.5: <<: *test_server docker: - - image: hasura/graphql-engine-cli-builder:v0.2 + - image: hasura/graphql-engine-cli-builder:v0.3 - image: circleci/postgres:9.5-alpine <<: *test_pg_env # test and build cli test_and_build_cli: docker: - - image: hasura/graphql-engine-cli-builder:v0.2 + - image: hasura/graphql-engine-cli-builder:v0.3 - image: circleci/postgres:10-alpine environment: POSTGRES_USER: gql_test @@ -201,7 +201,7 @@ jobs: # test and build console test_and_build_console: docker: - - image: hasura/graphql-engine-console-builder:v0.2 + - image: hasura/graphql-engine-console-builder:v0.3 - image: circleci/postgres:10-alpine environment: POSTGRES_USER: gql_test @@ -245,7 +245,7 @@ jobs: deploy: docker: - - image: hasura/graphql-engine-deployer:v0.2 + - image: hasura/graphql-engine-deployer:v0.3 working_directory: ~/graphql-engine steps: - *setup_remote_docker diff --git a/.circleci/test-cli.sh b/.circleci/test-cli.sh index c159c62f6fa60..343bce27a9cc0 100755 --- a/.circleci/test-cli.sh +++ b/.circleci/test-cli.sh @@ -20,13 +20,25 @@ cd "$CLI_ROOT" mkdir -p /build/_cli_output touch /build/_cli_output/server.log -# start graphql-engine +# start graphql-engine without access key /build/_server_output/graphql-engine \ --database-url postgres://gql_test@localhost:5432/gql_test serve > /build/_cli_output/server.log 2>&1 & -#PID=$! +PID=$! wait_for_port 8080 # test cli HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" make test -#kill $PID +kill $PID + +# start graphql-engine with access key +psql -U gql_test -h localhost -c 'CREATE DATABASE "gql_test_with_access";' +/build/_server_output/graphql-engine \ + --database-url postgres://gql_test@localhost:5432/gql_test_with_access serve --access-key "abcd" > /build/_cli_output/server.log 2>&1 & +PID=$! + +wait_for_port 8080 + +# test cli +GOCACHE=off HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" HASURA_GRAPHQL_TEST_ACCESS_KEY="abcd" make test +kill $PID diff --git a/cli/commands/metadata_apply_test.go b/cli/commands/metadata_apply_test.go index 261d1fba585a4..c6f3a42867223 100644 --- a/cli/commands/metadata_apply_test.go +++ b/cli/commands/metadata_apply_test.go @@ -2,6 +2,7 @@ package commands import ( "net/url" + "os" "testing" "time" @@ -19,7 +20,7 @@ func testMetadataApply(t *testing.T, metadataFile string, endpoint *url.URL) { MetadataFile: metadataFile, Config: &cli.HasuraGraphQLConfig{ Endpoint: endpoint.String(), - AccessKey: "", + AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"), ParsedEndpoint: endpoint, }, }, diff --git a/cli/commands/metadata_export_test.go b/cli/commands/metadata_export_test.go index 98e8f0d21b9a5..ea7012a676a81 100644 --- a/cli/commands/metadata_export_test.go +++ b/cli/commands/metadata_export_test.go @@ -2,6 +2,7 @@ package commands import ( "net/url" + "os" "testing" "time" @@ -19,7 +20,7 @@ func testMetadataExport(t *testing.T, metadataFile string, endpoint *url.URL) { MetadataFile: metadataFile, Config: &cli.HasuraGraphQLConfig{ Endpoint: endpoint.String(), - AccessKey: "", + AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"), ParsedEndpoint: endpoint, }, }, diff --git a/cli/commands/metadata_reset_test.go b/cli/commands/metadata_reset_test.go index 1b508dc9a2c69..78dc8d736d8a0 100644 --- a/cli/commands/metadata_reset_test.go +++ b/cli/commands/metadata_reset_test.go @@ -2,6 +2,7 @@ package commands import ( "net/url" + "os" "testing" "time" @@ -19,7 +20,7 @@ func testMetadataReset(t *testing.T, metadataFile string, endpoint *url.URL) { MetadataFile: metadataFile, Config: &cli.HasuraGraphQLConfig{ Endpoint: endpoint.String(), - AccessKey: "", + AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"), ParsedEndpoint: endpoint, }, }, diff --git a/cli/commands/migrate_apply_test.go b/cli/commands/migrate_apply_test.go index 218cbf92d6776..dd647604c5794 100644 --- a/cli/commands/migrate_apply_test.go +++ b/cli/commands/migrate_apply_test.go @@ -24,7 +24,7 @@ func testMigrateApply(t *testing.T, endpoint *url.URL, migrationsDir string, up MigrationDir: migrationsDir, Config: &cli.HasuraGraphQLConfig{ Endpoint: endpoint.String(), - AccessKey: "", + AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"), ParsedEndpoint: endpoint, }, }, diff --git a/cli/commands/migrate_status_test.go b/cli/commands/migrate_status_test.go index 4dbbb0d055fb0..a0fc63f4cce89 100644 --- a/cli/commands/migrate_status_test.go +++ b/cli/commands/migrate_status_test.go @@ -25,7 +25,7 @@ func testMigrateStatus(t *testing.T, endpoint *url.URL, migrationsDir string, ex MigrationDir: migrationsDir, Config: &cli.HasuraGraphQLConfig{ Endpoint: endpoint.String(), - AccessKey: "", + AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"), ParsedEndpoint: endpoint, }, },