From 8b409529aaf38122a2cac0d40acf47a7ff470af4 Mon Sep 17 00:00:00 2001 From: Alvin Huang <17609145+alvin-huang@users.noreply.github.com> Date: Fri, 2 Oct 2020 15:23:38 -0400 Subject: [PATCH] ci: fix bindata autoupdate (#8801) * update bindata on ui-v2/ changes * Revert "Remove GIT_SHA environment variable" This reverts commit f620f9aefd41362ce76c3a8e0f4addf402ee0ca2. * Revert "Hardcode in an app version for ember-cli-app-version" This reverts commit 5ae493d79b34ef2143d78a44c21a63623140bba8. * revert modtime change in #8712 --- .circleci/config.yml | 10 +++++---- GNUmakefile | 2 +- .../app/components/hashicorp-consul/index.hbs | 1 + ui-v2/config/environment.js | 21 ++++++++++++------- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 768eb72688..651327d87d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -641,10 +641,12 @@ jobs: - attach_workspace: at: . - run: - name: commit agent/uiserver/bindata_assetfs.go if there are changes + name: commit agent/uiserver/bindata_assetfs.go if there are UI changes command: | - exit 0 - if ! git diff --exit-code agent/uiserver/bindata_assetfs.go; then + # check if there are any changes in ui-v2/ + # if there are, we commit the ui static asset file + # HEAD^! is shorthand for HEAD^..HEAD (parent of HEAD and HEAD) + if ! git diff --quiet --exit-code HEAD^! ui-v2/; then git config --local user.email "hashicorp-ci@users.noreply.github.com" git config --local user.name "hashicorp-ci" @@ -653,7 +655,7 @@ jobs: git commit -m "auto-updated agent/uiserver/bindata_assetfs.go from commit ${short_sha}" git push origin master else - echo "no new static assets to publish" + echo "no UI changes so no static assets to publish" fi - run: *notify-slack-failure diff --git a/GNUmakefile b/GNUmakefile index 9fdfab8ec8..559f97bc78 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -306,7 +306,7 @@ lint: # also run as part of the release build script when it verifies that there are no # changes to the UI assets that aren't checked in. static-assets: - @go-bindata-assetfs -modtime 1 -pkg uiserver -prefix pkg -o $(ASSETFS_PATH) ./pkg/web_ui/... + @go-bindata-assetfs -pkg uiserver -prefix pkg -o $(ASSETFS_PATH) ./pkg/web_ui/... @go fmt $(ASSETFS_PATH) diff --git a/ui-v2/app/components/hashicorp-consul/index.hbs b/ui-v2/app/components/hashicorp-consul/index.hbs index 3ecd0d8589..4433ea5538 100644 --- a/ui-v2/app/components/hashicorp-consul/index.hbs +++ b/ui-v2/app/components/hashicorp-consul/index.hbs @@ -249,4 +249,5 @@ © {{env 'CONSUL_COPYRIGHT_YEAR'}} HashiCorp
Consul {{env 'CONSUL_VERSION'}}
Documentation + {{{concat ''}}} \ No newline at end of file diff --git a/ui-v2/config/environment.js b/ui-v2/config/environment.js index 377630b347..c9d14802fa 100644 --- a/ui-v2/config/environment.js +++ b/ui-v2/config/environment.js @@ -1,7 +1,7 @@ 'use strict'; const fs = require('fs'); const path = require('path'); -module.exports = function(environment, $ = process.env) { +module.exports = function (environment, $ = process.env) { let ENV = { modulePrefix: 'consul-ui', environment, @@ -11,9 +11,6 @@ module.exports = function(environment, $ = process.env) { // torii provider. We provide this object here to // prevent ember from giving a log message when starting ember up torii: {}, - 'ember-cli-app-version': { - version: 'consul-ui', - }, EmberENV: { FEATURES: { // Here you can enable experimental features on an ember canary build @@ -37,7 +34,7 @@ module.exports = function(environment, $ = process.env) { CONSUL_UI_DISABLE_REALTIME: typeof process.env.CONSUL_UI_DISABLE_REALTIME !== 'undefined', CONSUL_UI_DISABLE_ANCHOR_SELECTION: typeof process.env.CONSUL_UI_DISABLE_ANCHOR_SELECTION !== 'undefined', - CONSUL_COPYRIGHT_YEAR: (function(val) { + CONSUL_COPYRIGHT_YEAR: (function (val) { if (val) { return val; } @@ -48,7 +45,17 @@ module.exports = function(environment, $ = process.env) { .split('-') .shift(); })(process.env.CONSUL_COPYRIGHT_YEAR), - CONSUL_VERSION: (function(val) { + CONSUL_GIT_SHA: (function (val) { + if (val) { + return val; + } + + return require('child_process') + .execSync('git rev-parse --short HEAD') + .toString() + .trim(); + })(process.env.CONSUL_GIT_SHA), + CONSUL_VERSION: (function (val) { if (val) { return val; } @@ -57,7 +64,7 @@ module.exports = function(environment, $ = process.env) { const contents = fs.readFileSync(version_go).toString(); return contents .split('\n') - .find(function(item, i, arr) { + .find(function (item, i, arr) { return item.indexOf('Version =') !== -1; }) .trim()