Skip to content

Commit

Permalink
chore(build): remove speedcurve (#6153)
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo authored May 3, 2022
1 parent c57ee58 commit b8b15d5
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 183 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 0 additions & 19 deletions .github/workflows/prod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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: |
Expand All @@ -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:
Expand Down
19 changes: 0 additions & 19 deletions .github/workflows/stage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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: |
Expand All @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions build/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
);
Expand All @@ -72,7 +71,6 @@ module.exports = {
FOLDERSEARCH,
GOOGLE_ANALYTICS_ACCOUNT,
GOOGLE_ANALYTICS_DEBUG,
SPEEDCURVE_LUX_ID,
NO_PROGRESSBAR,
VALID_FLAW_CHECKS,
FIX_FLAWS,
Expand Down
5 changes: 0 additions & 5 deletions deployer/src/deployer/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
53 changes: 0 additions & 53 deletions deployer/src/deployer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down
38 changes: 0 additions & 38 deletions deployer/src/deployer/speedcurve.py

This file was deleted.

9 changes: 0 additions & 9 deletions docs/envvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`**
Expand Down
5 changes: 0 additions & 5 deletions libs/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
26 changes: 1 addition & 25 deletions ssr/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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();
$("<script>").text(speedcurveJS).appendTo($("head"));
$(
`<script src="https://cdn.speedcurve.com/js/lux.js?id=${SPEEDCURVE_LUX_ID}" async defer crossorigin="anonymous"></script>`
).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:
Expand Down
6 changes: 0 additions & 6 deletions testing/tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b8b15d5

Please sign in to comment.