aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Huang <tmashuang@users.noreply.github.com>2018-04-04 04:30:15 +0800
committerGitHub <noreply@github.com>2018-04-04 04:30:15 +0800
commitd6c4450b1cf1470cf437a80a3f78c937d267aef5 (patch)
treea6c5e2d2f6ff606689a50d28430ac9f6470dc568
parent11d4f3200eb68033c11aa6a57fc6e0ef2d019076 (diff)
parent502a203218066de284eecc7666bfef3ffe486a20 (diff)
downloadtangerine-wallet-browser-d6c4450b1cf1470cf437a80a3f78c937d267aef5.tar
tangerine-wallet-browser-d6c4450b1cf1470cf437a80a3f78c937d267aef5.tar.gz
tangerine-wallet-browser-d6c4450b1cf1470cf437a80a3f78c937d267aef5.tar.bz2
tangerine-wallet-browser-d6c4450b1cf1470cf437a80a3f78c937d267aef5.tar.lz
tangerine-wallet-browser-d6c4450b1cf1470cf437a80a3f78c937d267aef5.tar.xz
tangerine-wallet-browser-d6c4450b1cf1470cf437a80a3f78c937d267aef5.tar.zst
tangerine-wallet-browser-d6c4450b1cf1470cf437a80a3f78c937d267aef5.zip
Merge pull request #3850 from MetaMask/ci-improvements
Ci improvements
-rw-r--r--.circleci/config.yml38
-rwxr-xr-xdevelopment/metamaskbot-build-announce.js109
-rw-r--r--development/sentry-publish.js55
-rw-r--r--package-lock.json8
-rw-r--r--package.json8
5 files changed, 144 insertions, 74 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 14d693d7d..ee2054130 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -23,7 +23,7 @@ workflows:
requires:
- prep-deps-npm
- prep-build
- - job-announce:
+ - job-publish:
requires:
- prep-deps-npm
- prep-build
@@ -67,7 +67,7 @@ jobs:
steps:
- checkout
- restore_cache:
- key: dependency-cache-{{ checksum "package-lock.json" }}
+ key: dependency-cache-{{ .Revision }}
- run:
name: Install deps via npm
command: npm install
@@ -75,6 +75,10 @@ jobs:
key: dependency-cache-{{ checksum "package-lock.json" }}
paths:
- node_modules
+ - save_cache:
+ key: dependency-cache-{{ .Revision }}
+ paths:
+ - node_modules
prep-deps-firefox:
docker:
@@ -97,7 +101,7 @@ jobs:
steps:
- checkout
- restore_cache:
- key: dependency-cache-{{ checksum "package-lock.json" }}
+ key: dependency-cache-{{ .Revision }}
- run:
name: build:dist
command: npm run dist
@@ -116,7 +120,7 @@ jobs:
steps:
- checkout
- restore_cache:
- key: dependency-cache-{{ checksum "package-lock.json" }}
+ key: dependency-cache-{{ .Revision }}
- run:
name: Get Scss Cache key
# this allows us to checksum against a whole directory
@@ -135,7 +139,7 @@ jobs:
steps:
- checkout
- restore_cache:
- key: dependency-cache-{{ checksum "package-lock.json" }}
+ key: dependency-cache-{{ .Revision }}
- run:
name: Test
command: npm run lint
@@ -146,7 +150,7 @@ jobs:
steps:
- checkout
- restore_cache:
- key: dependency-cache-{{ checksum "package-lock.json" }}
+ key: dependency-cache-{{ .Revision }}
- restore_cache:
key: build-cache-{{ .Revision }}
- run:
@@ -162,7 +166,7 @@ jobs:
steps:
- checkout
- restore_cache:
- key: dependency-cache-{{ checksum "package-lock.json" }}
+ key: dependency-cache-{{ .Revision }}
- restore_cache:
key: build-cache-{{ .Revision }}
- run:
@@ -173,13 +177,13 @@ jobs:
paths:
- test-artifacts
- job-announce:
+ job-publish:
docker:
- image: circleci/node:8-browsers
steps:
- checkout
- restore_cache:
- key: dependency-cache-{{ checksum "package-lock.json" }}
+ key: dependency-cache-{{ .Revision }}
- restore_cache:
key: build-cache-{{ .Revision }}
- restore_cache:
@@ -188,6 +192,9 @@ jobs:
path: dist/mascara
destination: builds/mascara
- store_artifacts:
+ path: dist/sourcemaps
+ destination: builds/sourcemaps
+ - store_artifacts:
path: builds
destination: builds
- store_artifacts:
@@ -196,6 +203,9 @@ jobs:
- run:
name: build:announce
command: ./development/metamaskbot-build-announce.js
+ - run:
+ name: sentry sourcemaps upload
+ command: npm run sentry:publish
test-unit:
docker:
@@ -203,7 +213,7 @@ jobs:
steps:
- checkout
- restore_cache:
- key: dependency-cache-{{ checksum "package-lock.json" }}
+ key: dependency-cache-{{ .Revision }}
- run:
name: test:coverage
command: npm run test:coverage
@@ -225,7 +235,7 @@ jobs:
&& sudo mv /usr/bin/firefox /usr/bin/firefox-old
&& sudo ln -s /opt/firefox58/firefox /usr/bin/firefox
- restore_cache:
- key: dependency-cache-{{ checksum "package-lock.json" }}
+ key: dependency-cache-{{ .Revision }}
- run:
name: Get Scss Cache key
# this allows us to checksum against a whole directory
@@ -244,7 +254,7 @@ jobs:
steps:
- checkout
- restore_cache:
- key: dependency-cache-{{ checksum "package-lock.json" }}
+ key: dependency-cache-{{ .Revision }}
- run:
name: Get Scss Cache key
# this allows us to checksum against a whole directory
@@ -272,7 +282,7 @@ jobs:
&& sudo mv /usr/bin/firefox /usr/bin/firefox-old
&& sudo ln -s /opt/firefox58/firefox /usr/bin/firefox
- restore_cache:
- key: dependency-cache-{{ checksum "package-lock.json" }}
+ key: dependency-cache-{{ .Revision }}
- run:
name: Get Scss Cache key
# this allows us to checksum against a whole directory
@@ -291,7 +301,7 @@ jobs:
steps:
- checkout
- restore_cache:
- key: dependency-cache-{{ checksum "package-lock.json" }}
+ key: dependency-cache-{{ .Revision }}
- run:
name: Get Scss Cache key
# this allows us to checksum against a whole directory
diff --git a/development/metamaskbot-build-announce.js b/development/metamaskbot-build-announce.js
index 41e2796b4..88614ca5c 100755
--- a/development/metamaskbot-build-announce.js
+++ b/development/metamaskbot-build-announce.js
@@ -1,51 +1,62 @@
#!/usr/bin/env node
const request = require('request-promise')
-const { version } = require('../dist/chrome/manifest.json')
-
-const GITHUB_COMMENT_TOKEN = process.env.GITHUB_COMMENT_TOKEN
-const CIRCLE_PULL_REQUEST = process.env.CIRCLE_PULL_REQUEST
-console.log('CIRCLE_PULL_REQUEST', CIRCLE_PULL_REQUEST)
-const CIRCLE_SHA1 = process.env.CIRCLE_SHA1
-console.log('CIRCLE_SHA1', CIRCLE_SHA1)
-const CIRCLE_BUILD_NUM = process.env.CIRCLE_BUILD_NUM
-console.log('CIRCLE_BUILD_NUM', CIRCLE_BUILD_NUM)
-
-const CIRCLE_PR_NUMBER = CIRCLE_PULL_REQUEST.split('/').pop()
-const SHORT_SHA1 = CIRCLE_SHA1.slice(0,7)
-const BUILD_LINK_BASE = `https://${CIRCLE_BUILD_NUM}-42009758-gh.circle-artifacts.com/0`
-
-const MASCARA = `${BUILD_LINK_BASE}/builds/mascara/home.html`
-const CHROME = `${BUILD_LINK_BASE}/builds/metamask-chrome-${version}.zip`
-const FIREFOX = `${BUILD_LINK_BASE}/builds/metamask-firefox-${version}.zip`
-const EDGE = `${BUILD_LINK_BASE}/builds/metamask-edge-${version}.zip`
-const OPERA = `${BUILD_LINK_BASE}/builds/metamask-opera-${version}.zip`
-const WALKTHROUGH = `${BUILD_LINK_BASE}/test-artifacts/screens/walkthrough%20%28en%29.gif`
-
-const commentBody = `
-<details>
- <summary>
- Builds ready [${SHORT_SHA1}]:
- <a href="${MASCARA}">mascara</a>,
- <a href="${CHROME}">chrome</a>,
- <a href="${FIREFOX}">firefox</a>,
- <a href="${EDGE}">edge</a>,
- <a href="${OPERA}">opera</a>
- </summary>
- <image src="${WALKTHROUGH}">
-</details>
-`
-
-const JSON_PAYLOAD = JSON.stringify({ body: commentBody })
-const POST_COMMENT_URI = `https://api.github.com/repos/metamask/metamask-extension/issues/${CIRCLE_PR_NUMBER}/comments`
-console.log(`Announcement:\n${commentBody}`)
-console.log(`Posting to: ${POST_COMMENT_URI}`)
-
-request({
- method: 'POST',
- uri: POST_COMMENT_URI,
- body: JSON_PAYLOAD,
- headers: {
- 'User-Agent': 'metamaskbot',
- 'Authorization': `token ${GITHUB_COMMENT_TOKEN}`,
- },
-})
+const VERSION = require('../dist/chrome/manifest.json').version
+
+start().catch(console.error)
+
+async function start() {
+
+ const GITHUB_COMMENT_TOKEN = process.env.GITHUB_COMMENT_TOKEN
+ const CIRCLE_PULL_REQUEST = process.env.CIRCLE_PULL_REQUEST
+ console.log('CIRCLE_PULL_REQUEST', CIRCLE_PULL_REQUEST)
+ const CIRCLE_SHA1 = process.env.CIRCLE_SHA1
+ console.log('CIRCLE_SHA1', CIRCLE_SHA1)
+ const CIRCLE_BUILD_NUM = process.env.CIRCLE_BUILD_NUM
+ console.log('CIRCLE_BUILD_NUM', CIRCLE_BUILD_NUM)
+
+ if (!CIRCLE_PULL_REQUEST) {
+ console.warn(`No pull request detected for commit "${CIRCLE_SHA1}"`)
+ return
+ }
+
+ const CIRCLE_PR_NUMBER = CIRCLE_PULL_REQUEST.split('/').pop()
+ const SHORT_SHA1 = CIRCLE_SHA1.slice(0,7)
+ const BUILD_LINK_BASE = `https://${CIRCLE_BUILD_NUM}-42009758-gh.circle-artifacts.com/0`
+
+ const MASCARA = `${BUILD_LINK_BASE}/builds/mascara/home.html`
+ const CHROME = `${BUILD_LINK_BASE}/builds/metamask-chrome-${VERSION}.zip`
+ const FIREFOX = `${BUILD_LINK_BASE}/builds/metamask-firefox-${VERSION}.zip`
+ const EDGE = `${BUILD_LINK_BASE}/builds/metamask-edge-${VERSION}.zip`
+ const OPERA = `${BUILD_LINK_BASE}/builds/metamask-opera-${VERSION}.zip`
+ const WALKTHROUGH = `${BUILD_LINK_BASE}/test-artifacts/screens/walkthrough%20%28en%29.gif`
+
+ const commentBody = `
+ <details>
+ <summary>
+ Builds ready [${SHORT_SHA1}]:
+ <a href="${MASCARA}">mascara</a>,
+ <a href="${CHROME}">chrome</a>,
+ <a href="${FIREFOX}">firefox</a>,
+ <a href="${EDGE}">edge</a>,
+ <a href="${OPERA}">opera</a>
+ </summary>
+ <image src="${WALKTHROUGH}">
+ </details>
+ `
+
+ const JSON_PAYLOAD = JSON.stringify({ body: commentBody })
+ const POST_COMMENT_URI = `https://api.github.com/repos/metamask/metamask-extension/issues/${CIRCLE_PR_NUMBER}/comments`
+ console.log(`Announcement:\n${commentBody}`)
+ console.log(`Posting to: ${POST_COMMENT_URI}`)
+
+ await request({
+ method: 'POST',
+ uri: POST_COMMENT_URI,
+ body: JSON_PAYLOAD,
+ headers: {
+ 'User-Agent': 'metamaskbot',
+ 'Authorization': `token ${GITHUB_COMMENT_TOKEN}`,
+ },
+ })
+
+}
diff --git a/development/sentry-publish.js b/development/sentry-publish.js
new file mode 100644
index 000000000..ab3acabbd
--- /dev/null
+++ b/development/sentry-publish.js
@@ -0,0 +1,55 @@
+#!/usr/bin/env node
+const pify = require('pify')
+const exec = pify(require('child_process').exec, { multiArgs: true })
+const VERSION = require('../dist/chrome/manifest.json').version
+
+start().catch(console.error)
+
+async function start(){
+ const authWorked = await checkIfAuthWorks()
+ if (!authWorked) {
+ console.log(`Sentry auth failed...`)
+ }
+ // check if version exists or not
+ const versionAlreadyExists = await checkIfVersionExists()
+ // abort if versions exists
+ if (versionAlreadyExists) {
+ console.log(`Version "${VERSION}" already exists on Sentry, aborting sourcemap upload.`)
+ return
+ }
+
+ // create sentry release
+ console.log(`creating Sentry release for "${VERSION}"...`)
+ await exec(`sentry-cli releases --org 'metamask' --project 'metamask' new ${VERSION}`)
+ console.log(`removing any existing files from Sentry release "${VERSION}"...`)
+ await exec(`sentry-cli releases --org 'metamask' --project 'metamask' files ${VERSION} delete --all`)
+ // upload sentry source and sourcemaps
+ console.log(`uploading source files Sentry release "${VERSION}"...`)
+ await exec(`for FILEPATH in ./dist/chrome/*.js; do [ -e $FILEPATH ] || continue; export FILE=\`basename $FILEPATH\` && echo uploading $FILE && sentry-cli releases --org 'metamask' --project 'metamask' files ${VERSION} upload $FILEPATH metamask/$FILE; done;`)
+ console.log(`uploading sourcemaps Sentry release "${VERSION}"...`)
+ await exec(`sentry-cli releases --org 'metamask' --project 'metamask' files ${VERSION} upload-sourcemaps ./dist/sourcemaps/ --url-prefix 'sourcemaps'`)
+ console.log('all done!')
+}
+
+async function checkIfAuthWorks() {
+ const itWorked = await doesNotFail(async () => {
+ await exec(`sentry-cli releases --org 'metamask' --project 'metamask' list`)
+ })
+ return itWorked
+}
+
+async function checkIfVersionExists() {
+ const versionAlreadyExists = await doesNotFail(async () => {
+ await exec(`sentry-cli releases --org 'metamask' --project 'metamask' info ${VERSION}`)
+ })
+ return versionAlreadyExists
+}
+
+async function doesNotFail(asyncFn) {
+ try {
+ await asyncFn()
+ return true
+ } catch (err) {
+ return false
+ }
+}
diff --git a/package-lock.json b/package-lock.json
index 1029c507f..2c1589bec 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -188,7 +188,7 @@
"integrity": "sha1-AtD3eBwe5eG+WkMSoyX76LGzcjE=",
"dev": true,
"requires": {
- "https-proxy-agent": "2.2.0",
+ "https-proxy-agent": "2.2.1",
"node-fetch": "1.7.3",
"progress": "2.0.0",
"proxy-from-env": "1.0.0"
@@ -213,9 +213,9 @@
}
},
"https-proxy-agent": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.0.tgz",
- "integrity": "sha512-uUWcfXHvy/dwfM9bqa6AozvAjS32dZSTUYd/4SEpYKRg6LEcPLshksnQYRudM9AyNvUARMfAg5TLjUDyX/K4vA==",
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz",
+ "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==",
"dev": true,
"requires": {
"agent-base": "4.2.0",
diff --git a/package.json b/package.json
index 1227b82b7..310e357ca 100644
--- a/package.json
+++ b/package.json
@@ -31,13 +31,7 @@
"test:mascara:build:background": "browserify mascara/src/background.js -o dist/mascara/background.js",
"test:mascara:build:tests": "browserify test/integration/lib/first-time.js -o dist/mascara/tests.js",
"ganache:start": "ganache-cli -m 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'",
- "sentry": "export RELEASE=`cat app/manifest.json| jq -r .version` && npm run sentry:release && npm run sentry:upload",
- "sentry:release": "npm run sentry:release:new && npm run sentry:release:clean",
- "sentry:release:new": "sentry-cli releases --org 'metamask' --project 'metamask' new $RELEASE",
- "sentry:release:clean": "sentry-cli releases --org 'metamask' --project 'metamask' files $RELEASE delete --all",
- "sentry:upload": "npm run sentry:upload:source && npm run sentry:upload:maps",
- "sentry:upload:source": "for FILEPATH in ./dist/chrome/scripts/*.js; do [ -e $FILEPATH ] || continue; export FILE=`basename $FILEPATH` && echo uploading $FILE && sentry-cli releases --org 'metamask' --project 'metamask' files $RELEASE upload $FILEPATH metamask/scripts/$FILE; done;",
- "sentry:upload:maps": "sentry-cli releases --org 'metamask' --project 'metamask' files $RELEASE upload-sourcemaps ./dist/sourcemaps/ --url-prefix 'sourcemaps' --rewrite",
+ "sentry:publish": "node ./development/sentry-publish.js",
"lint": "gulp lint",
"lint:fix": "gulp lint:fix",
"ui": "npm run test:flat:build:states && beefy development/ui-dev.js:bundle.js --live --open --index=./development/index.html --cwd ./",