Skip to content

Commit

Permalink
Merge branch 'master' into console-permissions-unknown-types
Browse files Browse the repository at this point in the history
  • Loading branch information
rikinsk authored Jan 17, 2020
2 parents 6db6fe7 + 9c3e9ff commit ad5f590
Show file tree
Hide file tree
Showing 32 changed files with 321 additions and 366 deletions.
45 changes: 35 additions & 10 deletions .circleci/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ CHANGELOG_TEXT=""
# reviewers for pull requests opened to update installation manifests
REVIEWERS="shahidhk,coco98,arvi3411301"

IS_STABLE_RELEASE=false
STABLE_SEMVER_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
if [ ! -z "${CIRCLE_TAG}" ]; then
if [[ "$CIRCLE_TAG" =~ $STABLE_SEMVER_REGEX ]]; then
echo
echo "this is a stable release"
echo
IS_STABLE_RELEASE=true
fi
fi

changelog() {
CHANGELOG=$(git log ${PREVIOUS_TAG}..${LATEST_TAG} --pretty="tformat:- $1: %s" --reverse -- $ROOT/$1)
if [ -n "$CHANGELOG" ]
Expand All @@ -33,10 +44,10 @@ deploy_server() {
}

deploy_server_latest() {
echo "deloying server latest tag"
cd "$ROOT/server"
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USER" --password-stdin
make push-latest
echo "deloying server latest tag"
cd "$ROOT/server"
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USER" --password-stdin
make push-latest
}

draft_github_release() {
Expand All @@ -56,6 +67,7 @@ configure_git() {
}

send_pr_to_repo() {
configure_git
git clone https://github.com/hasura/$1.git ~/$1
cd ~/$1
git checkout -b ${LATEST_TAG}
Expand Down Expand Up @@ -86,17 +98,23 @@ deploy_console() {
# build and push container for auto-migrations
build_and_push_cli_migrations_image() {
IMAGE_TAG="hasura/graphql-engine:${CIRCLE_TAG}.cli-migrations"
LATEST_IMAGE_TAG="hasura/graphql-engine:latest.cli-migrations"
cd "$ROOT/scripts/cli-migrations"
cp /build/_cli_output/binaries/cli-hasura-linux-amd64 .
docker build -t "$IMAGE_TAG" .
docker push "$IMAGE_TAG"
}

# build and push latest container for auto-migrations
push_latest_cli_migrations_image() {
IMAGE_TAG="hasura/graphql-engine:${CIRCLE_TAG}.cli-migrations"
LATEST_IMAGE_TAG="hasura/graphql-engine:latest.cli-migrations"

# push latest.cli-migrations tag
docker tag "$IMAGE_TAG" "$LATEST_IMAGE_TAG"
docker push "$LATEST_IMAGE_TAG"
}


# copy docker-compose-https manifests to gcr for digital ocean one-click app
deploy_do_manifests() {
gsutil cp "$ROOT/install-manifests/docker-compose-https/docker-compose.yaml" \
Expand Down Expand Up @@ -148,9 +166,19 @@ fi
deploy_console
deploy_server
if [[ ! -z "$CIRCLE_TAG" ]]; then
deploy_server_latest
push_server_binary
build_and_push_cli_migrations_image

# if this is a stable release, update all latest assets
if [ $IS_STABLE_RELEASE = true ]; then
deploy_server_latest
push_server_binary
push_latest_cli_migrations_image
send_pr_to_repo graphql-engine-heroku
deploy_do_manifests
fi

# submit a release draft to github
# build changelog
CHANGELOG_TEXT=$(changelog server)
CHANGELOG_TEXT+=$(changelog cli)
CHANGELOG_TEXT+=$(changelog console)
Expand All @@ -159,7 +187,4 @@ $(<$ROOT/.circleci/release_notes.template.md)
EOF
")
draft_github_release
configure_git
send_pr_to_repo graphql-engine-heroku
deploy_do_manifests
fi
31 changes: 28 additions & 3 deletions cli/assets/assets.go

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

75 changes: 75 additions & 0 deletions cli/assets/latest/console.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<html lang="en-us">
<head>
<link rel="icon" type="image/png" href="https://graphql-engine-cdn.hasura.io/console/assets/common/img/favicon_green.png" />
<script>
window.__env = {
apiHost: {{.apiHost}},
apiPort: "{{.apiPort}}",
cliVersion: {{.cliVersion}},
dataApiUrl: {{.dataApiUrl}},
dataApiVersion: {{.dataApiVersion}},
{{- if .hasAccessKey }}
accessKey: {{.adminSecret}},
{{ else }}
adminSecret: {{.adminSecret}},
{{ end -}}
urlPrefix: "/",
consoleMode: "cli",
cliUUID: {{.cliUUID}},
enableTelemetry: {{.enableTelemetry}},
assetsPath: "https://graphql-engine-cdn.hasura.io/console/assets",
serverVersion: "{{.serverVersion}}",
};
</script>
</head>
<body>
<style>
.mainContent {
display: 'none';
opacity: 0;
transition: opacity .20s linear;
}
.mainContent.show {
display: 'block';
opacity: 1;
transition: opacity .20s linear;
}
</style>

<div id="loading">
<div class="page-loading" style="
min-height: 100vh;
width: 100%;
display: flex;
align-items: center;
font-family: sans-serif;
justify-content: center;
">
<span class="" style="
font-size: 2em;
margin-top: -3em;
color: #848484;
">
Loading...
</span>
</div>
</div>
<div id="content" class="mainContent"></div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>

{{ if .cliStaticDir }}

<link rel="stylesheet" href="/static/main.css" charset="UTF-8"/>
<script src="/static/vendor.js" charset="UTF-8"></script>
<script src="/static/main.js" charset="UTF-8"></script>

{{ else }}

<link rel="stylesheet" href="https://graphql-engine-cdn.hasura.io/console/assets/{{.assetsVersion}}/main.css.gz" charset="UTF-8"/>
<script src="https://graphql-engine-cdn.hasura.io/console/assets/{{.assetsVersion}}/vendor.js.gz" charset="UTF-8"></script>
<script src="https://graphql-engine-cdn.hasura.io/console/assets/{{.assetsVersion}}/main.js.gz" charset="UTF-8"></script>

{{ end }}

</body>
</html>
2 changes: 1 addition & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (ec *ExecutionContext) checkServerVersion() error {
ec.Logger.Debugf("versions: cli: [%s] server: [%s]", ec.Version.GetCLIVersion(), ec.Version.GetServerVersion())
ec.Logger.Debugf("compatibility check: [%v] %v", isCompatible, reason)
if !isCompatible {
return errors.Errorf("[cli: %s] [server: %s] versions incompatible: %s", ec.Version.GetCLIVersion(), ec.Version.GetServerVersion(), reason)
ec.Logger.Warnf("[cli: %s] [server: %s] version mismatch: %s", ec.Version.GetCLIVersion(), ec.Version.GetServerVersion(), reason)
}
return nil
}
Expand Down
4 changes: 4 additions & 0 deletions cli/commands/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ func serveConsole(assetsVersion, staticDir string, opts gin.H) (*gin.Engine, err
// An Engine instance with the Logger and Recovery middleware already attached.
r := gin.New()

if !util.DoAssetExist("assets/" + assetsVersion + "/console.html") {
assetsVersion = "latest"
}

// Template console.html
templateRender, err := util.LoadTemplates("assets/"+assetsVersion+"/", "console.html")
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions cli/commands/update-cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func (o *updateOptions) run(showPrompt bool) error {
return errors.Wrap(err, "command: check update")
}

ec.Logger.Debugln("hasUpdate: ", hasUpdate, "latestVersion: ", latestVersion, "currentVersion:", currentVersion)

if !hasUpdate {
o.EC.Logger.WithField("version", currentVersion).Info("hasura cli is up to date")
return nil
Expand Down
2 changes: 1 addition & 1 deletion cli/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func HasUpdate(currentVersion *semver.Version, timeFile string) (bool, *semver.V
return false, nil, errors.Wrap(err, "get latest version")
}

c, err := semver.NewConstraint(fmt.Sprintf("> %s", currentVersion.String()))
c, err := semver.NewConstraint(fmt.Sprintf("> %s-0", currentVersion.String()))
if err != nil {
return false, nil, errors.Wrap(err, "semver constraint build")
}
Expand Down
11 changes: 11 additions & 0 deletions cli/util/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ func (b *binaryFileSystem) Exists(prefix string, filepath string) bool {
return false
}

// BinaryFileSystem creates a binary file system at root from the assets
func BinaryFileSystem(root string) *binaryFileSystem {
fs := &assetfs.AssetFS{assets.Asset, assets.AssetDir, assets.AssetInfo, root}
return &binaryFileSystem{
fs,
}
}

// LoadTemplates loads templates from path for the given list
func LoadTemplates(path string, list ...string) (multitemplate.Render, error) {
r := multitemplate.New()

Expand All @@ -55,3 +57,12 @@ func LoadTemplates(path string, list ...string) (multitemplate.Render, error) {

return r, nil
}

// DoAssetExist returns true if an asset exists at pathk
func DoAssetExist(path string) bool {
_, err := assets.AssetInfo(path)
if err != nil {
return false
}
return true
}
6 changes: 3 additions & 3 deletions cli/version/compatibility.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package version

const (
untaggedBuild = "for untagged builds, server and cli versions should match"
taggedBuild = "cli version (major.minor) should be equal or ahead of server version, please update cli"
untaggedBuild = "untagged build, there could be inconsistencies"
taggedBuild = "older cli version might not be compatible with latest server apis, please update cli"
noServerVersion = "server with no version treated as pre-release build"
noCLIVersion = "cli version is empty, indicates a broken build"
untaggedCLI = "untagged cli build can work with tagged server build"
devCLI = "dev version of cli, compatible with all servers"
devCLI = "dev version of cli, there could be inconsistencies"
)

// CheckCLIServerCompatibility compares server and cli for compatibility,
Expand Down
6 changes: 6 additions & 0 deletions docs/graphql/manual/deployment/downgrading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ You can downgrade the catalogue from a particular version to its previous versio
:backlinks: none
:depth: 1
:local:

From 30 to 29
"""""""""""""
.. code-block:: plpgsql
DROP FUNCTION hdb_catalog.check_violation();
From 27 to 26
"""""""""""""
Expand Down
1 change: 0 additions & 1 deletion server/graphql-engine.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ library
, Hasura.RQL.DDL.Relationship
, Hasura.RQL.DDL.Deps
, Hasura.RQL.DDL.Permission.Internal
, Hasura.RQL.DDL.Permission.Triggers
, Hasura.RQL.DDL.Permission
, Hasura.RQL.DDL.Relationship.Rename
, Hasura.RQL.DDL.Relationship.Types
Expand Down
Loading

0 comments on commit ad5f590

Please sign in to comment.