From b8b15d5a4b4875d94f94a675df7e34ab6e217d8d Mon Sep 17 00:00:00 2001 From: Florian Dieminger Date: Tue, 3 May 2022 14:08:51 +0200 Subject: [PATCH] chore(build): remove speedcurve (#6153) --- .github/workflows/dev-build.yml | 2 -- .github/workflows/prod-build.yml | 19 ----------- .github/workflows/stage-build.yml | 19 ----------- build/constants.js | 2 -- deployer/src/deployer/constants.py | 5 --- deployer/src/deployer/main.py | 53 ----------------------------- deployer/src/deployer/speedcurve.py | 38 --------------------- docs/envvars.md | 9 ----- libs/constants/index.js | 5 --- ssr/render.js | 26 +------------- testing/tests/index.test.js | 6 ---- 11 files changed, 1 insertion(+), 183 deletions(-) delete mode 100644 deployer/src/deployer/speedcurve.py diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index 4e774776db35..30c84ee7a0d0 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -128,8 +128,6 @@ jobs: # This just makes sure the Google Analytics script gets used even if # it goes nowhere. BUILD_GOOGLE_ANALYTICS_ACCOUNT: UA-00000000-0 - # Same with the Speedcurve LUX - BUILD_SPEEDCURVE_LUX_ID: 000000000 # This removes the ability to sign in REACT_APP_DISABLE_AUTH: true diff --git a/.github/workflows/prod-build.yml b/.github/workflows/prod-build.yml index 18b8135d7998..7b01dec08325 100644 --- a/.github/workflows/prod-build.yml +++ b/.github/workflows/prod-build.yml @@ -150,11 +150,6 @@ jobs: # origin domain isn't what that account expects. BUILD_GOOGLE_ANALYTICS_ACCOUNT: UA-36116321-5 - # See the code for a further explanation for this. - # You get the ID from - # https://speedcurve.com/mozilla-add-ons/mdn/settings/updated/#lux - BUILD_SPEEDCURVE_LUX_ID: 108906238 - # This enables the MDN Plus REACT_APP_ENABLE_PLUS: true @@ -226,13 +221,6 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOYER_PROD_AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOYER_PROD_AWS_SECRET_ACCESS_KEY }} - # Note, command will pick up the site ID and deployment API key - # from environment variables and if either of them is falsy, the - # command will *not* fail. It will simply not deploy anything. - SPEEDCURVE_DEPLOY_API_KEY: ${{ secrets.SPEEDCURVE_DEPLOY_API_KEY }} - # Based on https://api.speedcurve.com/#get-all-sites using the API key - SPEEDCURVE_DEPLOY_SITE_ID: 85742 - DEPLOYER_ELASTICSEARCH_URL: ${{ secrets.DEPLOYER_PROD_ELASTICSEARCH_URL }} run: | @@ -253,13 +241,6 @@ jobs: poetry run deployer update-lambda-functions ./aws-lambda poetry run deployer search-index ../client/build - # Record the deployment in our Speedcurve account. This should always - # be done after the upload of the documents and Lambda functions, as well - # as the search-index update, so those aren't affected if this fails. - poetry run deployer speedcurve-deploy \ - --note "${GITHUB_SHA}" \ - --detail "run_id=${GITHUB_RUN_ID} action=${GITHUB_ACTION}" - - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 with: diff --git a/.github/workflows/stage-build.yml b/.github/workflows/stage-build.yml index 229fa900afc6..2b6dbc96fed7 100644 --- a/.github/workflows/stage-build.yml +++ b/.github/workflows/stage-build.yml @@ -153,11 +153,6 @@ jobs: # origin domain isn't what that account expects. BUILD_GOOGLE_ANALYTICS_ACCOUNT: UA-36116321-5 - # See the code for a further explanation for this. - # You get the ID from - # https://speedcurve.com/mozilla-add-ons/mdn/settings/updated/#lux - BUILD_SPEEDCURVE_LUX_ID: 108906238 - # This enables the Plus call-to-action banner and the Plus landing page REACT_APP_ENABLE_PLUS: true @@ -227,13 +222,6 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOYER_STAGE_AND_DEV_AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOYER_STAGE_AND_DEV_AWS_SECRET_ACCESS_KEY }} - # Note, command will pick up the site ID and deployment API key - # from environment variables and if either of them is falsy, the - # command will *not* fail. It will simply not deploy anything. - SPEEDCURVE_DEPLOY_API_KEY: ${{ secrets.SPEEDCURVE_DEPLOY_API_KEY }} - # Based on https://api.speedcurve.com/#get-all-sites using the API key - SPEEDCURVE_DEPLOY_SITE_ID: 354836 - DEPLOYER_ELASTICSEARCH_URL: ${{ secrets.DEPLOYER_STAGE_ELASTICSEARCH_URL }} run: | @@ -254,13 +242,6 @@ jobs: poetry run deployer update-lambda-functions ./aws-lambda poetry run deployer search-index ../client/build - # Record the deployment in our Speedcurve account. This should always - # be done after the upload of the documents and Lambda functions, as well - # as the search-index update, so those aren't affected if this fails. - poetry run deployer speedcurve-deploy \ - --note "${GITHUB_SHA}" \ - --detail "run_id=${GITHUB_RUN_ID} action=${GITHUB_ACTION}" - - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 with: diff --git a/build/constants.js b/build/constants.js index 95bf68d544b0..18ee7ff3a430 100644 --- a/build/constants.js +++ b/build/constants.js @@ -45,7 +45,6 @@ const GOOGLE_ANALYTICS_ACCOUNT = const GOOGLE_ANALYTICS_DEBUG = JSON.parse( process.env.BUILD_GOOGLE_ANALYTICS_DEBUG || "false" ); -const SPEEDCURVE_LUX_ID = process.env.BUILD_SPEEDCURVE_LUX_ID || ""; const NO_PROGRESSBAR = Boolean( JSON.parse(process.env.BUILD_NO_PROGRESSBAR || process.env.CI || "false") ); @@ -72,7 +71,6 @@ module.exports = { FOLDERSEARCH, GOOGLE_ANALYTICS_ACCOUNT, GOOGLE_ANALYTICS_DEBUG, - SPEEDCURVE_LUX_ID, NO_PROGRESSBAR, VALID_FLAW_CHECKS, FIX_FLAWS, diff --git a/deployer/src/deployer/constants.py b/deployer/src/deployer/constants.py index ea13ef6a5469..e90fbefab086 100644 --- a/deployer/src/deployer/constants.py +++ b/deployer/src/deployer/constants.py @@ -39,11 +39,6 @@ "DEPLOYER_LOG_EACH_SUCCESSFUL_UPLOAD", default=False, cast=bool ) -# You get this from https://speedcurve.com/mozilla-add-ons/mdn/admin/teams/ -SPEEDCURVE_DEPLOY_API_KEY = config("SPEEDCURVE_DEPLOY_API_KEY", default=None) -# Use the API key and see instructions on https://api.speedcurve.com/#get-all-sites -SPEEDCURVE_DEPLOY_SITE_ID = config("SPEEDCURVE_DEPLOY_SITE_ID", default=None) - # If you're doing local development, you can download and install your own # instance of Elasticsearch 7 and start it. Then set this environment variable # value to `http://localhost:9200` diff --git a/deployer/src/deployer/main.py b/deployer/src/deployer/main.py index 26db0756956b..6b2baf721c90 100644 --- a/deployer/src/deployer/main.py +++ b/deployer/src/deployer/main.py @@ -13,15 +13,12 @@ DEFAULT_NO_PROGRESSBAR, DEFAULT_REPO, DEFAULT_GITHUB_TOKEN, - SPEEDCURVE_DEPLOY_API_KEY, - SPEEDCURVE_DEPLOY_SITE_ID, ELASTICSEARCH_URL, ) from .update_lambda_functions import update_all from .upload import upload_content from .utils import log from .whatsdeployed import dump as dump_whatsdeployed -from .speedcurve import deploy_ping as speedcurve_deploy_ping from .analyze_pr import analyze_pr from . import search @@ -258,56 +255,6 @@ def analyze_pr_build(ctx, directory: Path, **kwargs): log.info("\n", "END POST".center(80, "_")) -@cli.command() -@click.option( - "--api-key", - help="Deploy API key", - default=SPEEDCURVE_DEPLOY_API_KEY, - show_default=False, -) -@click.option( - "--site-id", - help="Site ID ", - default=SPEEDCURVE_DEPLOY_SITE_ID, - show_default=True, -) -@click.option( - "--note", - help="Note string to add", - default="", - show_default=True, -) -@click.option( - "--detail", - help="Detail string to add", - default="", - show_default=True, -) -@click.pass_context -def speedcurve_deploy(ctx, **kwargs): - # The reason we're not throwing an error is to make it super convenient - # to call this command, from bash, without first having to check and figure - # out if the relevant environment variables are available. - - api_key = kwargs["api_key"] - if not api_key: - log.warning("SPEEDCURVE_DEPLOY_API_KEY not set or empty") - return - - site_id = kwargs["site_id"] - if not site_id: - log.warning("SPEEDCURVE_DEPLOY_SITE_ID not set or empty") - return - - log.info(f"Pinging Speedcurve Deploy API for {site_id}", bold=True) - note = kwargs["note"] - detail = kwargs["detail"] - log.info(f"Speedcurve Deploy note={note!r}, detail={detail!r}") - speedcurve_deploy_ping( - api_key, site_id, note, detail, dry_run=ctx.obj.get("dry_run") - ) - - @cli.command() @click.option( "--url", diff --git a/deployer/src/deployer/speedcurve.py b/deployer/src/deployer/speedcurve.py deleted file mode 100644 index fa7f25df24e9..000000000000 --- a/deployer/src/deployer/speedcurve.py +++ /dev/null @@ -1,38 +0,0 @@ -import requests -from requests.adapters import HTTPAdapter -from requests.packages.urllib3.util.retry import Retry - -from .utils import log - -POST_URL = "https://api.speedcurve.com/v1/deploys" - - -def deploy_ping( - api_key: str, site_id: str, note: str, detail: str, dry_run: bool = False -): - """Based on https://api.speedcurve.com/#add-a-deploy""" - data = { - "site_id": site_id, - } - if note: - data["note"] = note - if detail: - data["detail"] = detail - - if dry_run: - log.info(f"Posting {data} to {POST_URL} with API key {api_key[:3] + '...'!r}") - return - - adapter = HTTPAdapter( - max_retries=Retry( - backoff_factor=0.3, - status_forcelist=[429, 500, 502, 503, 504], - method_whitelist=["POST"], - ) - ) - session = requests.Session() - session.mount("https://", adapter) - auth = (api_key, "x") - response = session.post(POST_URL, data=data, auth=auth) - response.raise_for_status() - log.info(response.json()) diff --git a/docs/envvars.md b/docs/envvars.md index 439eccf1f7e0..9ec57bfeb621 100644 --- a/docs/envvars.md +++ b/docs/envvars.md @@ -160,15 +160,6 @@ the Google Analytics script tag it will use instead which triggers additional console logging which is useful for developers. -### `BUILD_SPEEDCURVE_LUX_ID` - -**Default: `''`** - -You can get it here on -[this settings page](https://speedcurve.com/mozilla-add-ons/mdn/settings/lux/) -which will give you the ID in the snippet shown there. Also, try to match this -with the domains in those settings to match where we deploy it. - ### `BUILD_ALWAYS_ALLOW_ROBOTS` **Default: `false`** diff --git a/libs/constants/index.js b/libs/constants/index.js index d054ac442304..8759595c2b7e 100644 --- a/libs/constants/index.js +++ b/libs/constants/index.js @@ -72,9 +72,6 @@ const scriptSrcValues = [ "'report-sample'", "'self'", - "*.speedcurve.com", - "'sha256-q7cJjDqNO2e1L5UltvJ1LhvnYN7yJXgGO7b6h9xkL1o='", // LUX - "www.google-analytics.com/analytics.js", "'sha256-JEt9Nmc3BP88wxuTZm9aKNu87vEgGmKW1zzy/vb1KPs='", // polyfill check @@ -136,8 +133,6 @@ const CSP_DIRECTIVES = { "profile.stage.mozaws.net", "profile.accounts.firefox.com", - "lux.speedcurve.com", - "mdn.mozillademos.org", "media.prod.mdn.mozit.cloud", "media.stage.mdn.mozit.cloud", diff --git a/ssr/render.js b/ssr/render.js index 88a97edd6b26..addd2e5130e2 100644 --- a/ssr/render.js +++ b/ssr/render.js @@ -3,11 +3,7 @@ import path from "path"; import { renderToString } from "react-dom/server"; import cheerio from "cheerio"; -import { - ALWAYS_ALLOW_ROBOTS, - BUILD_OUT_ROOT, - SPEEDCURVE_LUX_ID, -} from "../build/constants"; +import { ALWAYS_ALLOW_ROBOTS, BUILD_OUT_ROOT } from "../build/constants"; const { DEFAULT_LOCALE } = require("../libs/constants"); @@ -90,16 +86,6 @@ const getGAScriptPathName = lazy((relPath = "/static/js/ga.js") => { return null; }); -const getSpeedcurveJS = lazy(() => { - return fs - .readFileSync( - // The file is called `...js.txt` so that Prettier never touches it. - path.join(__dirname, "..", "speedcurve-lux-snippet.js.txt"), - "utf-8" - ) - .trim(); -}); - const extractWebFontURLs = lazy(() => { const urls = []; const manifest = JSON.parse( @@ -233,16 +219,6 @@ export default function render( $('link[rel="canonical"]').attr("href", canonicalURL); } - if (SPEEDCURVE_LUX_ID) { - // The snippet is always the same, if it's present, but the ID varies - // See LUX settings here https://speedcurve.com/mozilla-add-ons/mdn/settings/lux/ - const speedcurveJS = getSpeedcurveJS(); - $("` - ).appendTo($("head")); - } - // As part of the pre-build steps, in the build root, a `ga.js` file is generated. // The SSR rendering needs to know if exists and if so, what it's URL pathname is. // The script will do two things: diff --git a/testing/tests/index.test.js b/testing/tests/index.test.js index 37d95f70a761..18bd877da3ca 100644 --- a/testing/tests/index.test.js +++ b/testing/tests/index.test.js @@ -189,12 +189,6 @@ test("content built foo page", () => { // The ID should match what's set in `testing/.env`. expect($('script[src="/static/js/ga.js"]').length).toBe(1); - // The HTML should contain the Speedcurve LUX snippet. - // The ID should match what's set in `testing/.env`. - expect($('script[src^="https://cdn.speedcurve.com/"]').attr("src")).toContain( - "012345" - ); - // Because this en-US page has a French translation expect($('link[rel="alternate"]').length).toBe(3); expect($('link[rel="alternate"][hreflang="en"]').length).toBe(1);