From b14d4616f3e6a88ba34440daea72ff4823ccde50 Mon Sep 17 00:00:00 2001 From: Bastien Abadie Date: Wed, 21 Aug 2019 16:04:56 +0200 Subject: [PATCH 1/2] frontend: Use backend url from env during build --- .taskcluster.yml | 10 ++++++++++ frontend/src/common.js | 2 +- frontend/webpack.common.js | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.taskcluster.yml b/.taskcluster.yml index efc7161a3..7e0dbd60e 100644 --- a/.taskcluster.yml +++ b/.taskcluster.yml @@ -41,6 +41,14 @@ tasks: else: ${event.ref[11:]} else: 'dev' + backend_url: + $if: 'tasks_for == "github-push"' + then: + $if: 'event.ref == "refs/heads/testing"' + then: 'https://api.coverage.moz.tools' + else: 'https://api.coverage.testing.moz.tools' + else: 'dev' + taskboot_image: "mozilla/taskboot:0.1.9" in: - taskId: {$eval: as_slugid("check_lint")} @@ -226,6 +234,8 @@ tasks: payload: maxRunTime: 3600 image: node + env: + BACKEND_URL: "${backend_url}" command: - sh - -lxce diff --git a/frontend/src/common.js b/frontend/src/common.js index 3fda84781..f0d0c7e25 100644 --- a/frontend/src/common.js +++ b/frontend/src/common.js @@ -36,7 +36,7 @@ export async function main(load, display, opts) { // Coverage retrieval. -const COVERAGE_BACKEND_HOST = 'https://api.coverage.moz.tools'; +const COVERAGE_BACKEND_HOST = process.env.BACKEND_URL; function cache_get(cache, key) { if (key in cache) { diff --git a/frontend/webpack.common.js b/frontend/webpack.common.js index b0c6db5b1..164e15e69 100644 --- a/frontend/webpack.common.js +++ b/frontend/webpack.common.js @@ -1,4 +1,5 @@ const path = require('path'); +const webpack = require('webpack'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin') const MiniCssExtractPlugin = require('mini-css-extract-plugin'); @@ -18,6 +19,9 @@ module.exports = { new MiniCssExtractPlugin({ filename: 'coverage-[hash].css', }), + new webpack.EnvironmentPlugin({ + BACKEND_URL: 'http://localhost:8000', + }), ], module: { rules: [ From 7064d723cf1c07fc5843f0504165c391b9de1c80 Mon Sep 17 00:00:00 2001 From: Bastien Abadie Date: Thu, 22 Aug 2019 14:49:15 +0200 Subject: [PATCH 2/2] Fix taskcluster yml dumb mistake --- .taskcluster.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.taskcluster.yml b/.taskcluster.yml index 7e0dbd60e..bb53a1d66 100644 --- a/.taskcluster.yml +++ b/.taskcluster.yml @@ -45,9 +45,9 @@ tasks: $if: 'tasks_for == "github-push"' then: $if: 'event.ref == "refs/heads/testing"' - then: 'https://api.coverage.moz.tools' - else: 'https://api.coverage.testing.moz.tools' - else: 'dev' + then: 'https://api.coverage.testing.moz.tools' + else: 'https://api.coverage.moz.tools' + else: 'https://api.coverage.moz.tools' taskboot_image: "mozilla/taskboot:0.1.9" in: