Skip to content

Commit

Permalink
Merge branch 'master' into ampForm
Browse files Browse the repository at this point in the history
  • Loading branch information
Micajuine Ho committed Mar 18, 2021
2 parents f22392c + 9087f42 commit 8ac023b
Show file tree
Hide file tree
Showing 291 changed files with 15,619 additions and 50,835 deletions.
45 changes: 45 additions & 0 deletions .circleci/compute_merge_commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
#
# Copyright 2021 The AMP HTML Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the license.

# This script establishes the merge commit at the start of a CircleCI build so
# all stages use the same commit.

set -e
err=0

GREEN() { echo -e "\n\033[0;32m$1\033[0m"; }

# Try to determine the PR number.
curl -sS https://raw.githubusercontent.com/ampproject/amphtml/master/.circleci/get_pr_number.sh | bash
if [[ -f "$BASH_ENV" ]]; then
source $BASH_ENV
fi

# If PR_NUMBER doesn't exist, there is nothing more to do.
if [[ -z "$PR_NUMBER" ]]; then
exit 0
fi

# GitHub provides refs/pull/<PR_NUMBER>/merge, an up-to-date merge branch for
# every PR branch that can be cleanly merged to master. For more details, see:
# https://discuss.circleci.com/t/show-test-results-for-prospective-merge-of-a-github-pr/1662
MERGE_BRANCH="refs/pull/$PR_NUMBER/merge"
echo $(GREEN "Computing merge SHA of $MERGE_BRANCH...")
CIRCLE_MERGE_SHA="$(git ls-remote https://github.com/ampproject/amphtml.git "$MERGE_BRANCH" | awk '{print $1}')"

echo "$CIRCLE_MERGE_SHA" > .CIRCLECI_MERGE_COMMIT
echo $(GREEN "Stored merge SHA $CIRCLE_MERGE_SHA in .CIRCLECI_MERGE_COMMIT.")
exit 0
27 changes: 9 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ push_builds_only: &push_builds_only
- /^amp-release-.*$/

executors:
amphtml-docker-small-executor:
docker:
- image: cimg/base:2020.12
resource_class: small
amphtml-medium-executor:
machine:
image: ubuntu-2004:202010-01
Expand All @@ -29,11 +33,6 @@ executors:
machine:
image: ubuntu-2004:202010-01
resource_class: xlarge
amphtml-docker-executor:
docker:
# The official, bare bones Docker Image from CircleCI
# https://circleci.com/docs/2.0/circleci-images/?section=executors-and-images#circleci-base-image
- image: cimg/base:2020.12

commands:
save_merge_commit:
Expand All @@ -42,7 +41,7 @@ commands:
name: 'Save Merge Commit'
key: git-{{ .Branch }}-{{ .Revision }}
paths:
- .CIRCLECI_WORKFLOW_MERGE_COMMIT
- .CIRCLECI_MERGE_COMMIT
restore_merge_commit:
steps:
- restore_cache:
Expand All @@ -54,7 +53,7 @@ commands:
- restore_merge_commit
- run:
name: 'Fetch Merge Commit'
command: ./.circleci/fetch_merge_commit.sh merge
command: ./.circleci/fetch_merge_commit.sh
- run:
name: 'Check Config'
command: ./.circleci/check_config.sh
Expand All @@ -81,11 +80,11 @@ commands:
jobs:
'Compute Merge Commit':
executor:
name: amphtml-docker-executor
name: amphtml-docker-small-executor
steps:
- run:
name: 'Fetch Merge Commit'
command: curl -o- https://raw.githubusercontent.com/ampproject/amphtml/master/.circleci/fetch_merge_commit.sh | bash /dev/stdin fetch
name: 'Compute Merge Commit'
command: curl -sS https://raw.githubusercontent.com/ampproject/amphtml/master/.circleci/compute_merge_commit.sh | bash
- save_merge_commit
'Checks':
executor:
Expand Down Expand Up @@ -278,7 +277,6 @@ workflows:
- 'Bundle Size':
<<: *push_and_pr_builds
requires:
- 'Compute Merge Commit'
- 'Nomodule Build'
- 'Module Build'
- 'Validator Tests':
Expand All @@ -288,7 +286,6 @@ workflows:
- 'Visual Diff Tests':
<<: *push_and_pr_builds
requires:
- 'Compute Merge Commit'
- 'Nomodule Build'
- 'Unit Tests':
<<: *push_and_pr_builds
Expand All @@ -297,7 +294,6 @@ workflows:
- 'Unminified Tests':
<<: *push_and_pr_builds
requires:
- 'Compute Merge Commit'
- 'Unminified Build'
- 'Nomodule Tests':
name: 'Nomodule Tests (<< matrix.config >>)'
Expand All @@ -306,7 +302,6 @@ workflows:
config: ['prod', 'canary']
<<: *push_and_pr_builds
requires:
- 'Compute Merge Commit'
- 'Nomodule Build'
- 'Module Tests':
name: 'Module Tests (<< matrix.config >>)'
Expand All @@ -315,13 +310,11 @@ workflows:
config: ['prod', 'canary']
<<: *push_and_pr_builds
requires:
- 'Compute Merge Commit'
- 'Nomodule Build'
- 'Module Build'
- 'End-to-End Tests':
<<: *push_and_pr_builds
requires:
- 'Compute Merge Commit'
- 'Nomodule Build'
- 'Experiment Build':
name: 'Experiment << matrix.exp >> Build'
Expand All @@ -338,11 +331,9 @@ workflows:
exp: ['A', 'B', 'C']
<<: *push_and_pr_builds
requires:
- 'Compute Merge Commit'
- 'Experiment << matrix.exp >> Build'
# TODO(wg-performance, #12128): This takes 30 mins and fails regularly.
# - 'Performance Tests':
# <<: *push_builds_only
# requires:
# - 'Compute Merge Commit'
# - 'Nomodule Build'
57 changes: 15 additions & 42 deletions .circleci/fetch_merge_commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,64 +16,37 @@

# This script fetches the merge commit of a PR branch with master to make sure
# PRs are tested against all the latest changes on CircleCI.
# Reference: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables

set -e
err=0

GREEN() { echo -e "\n\033[0;32m$1\033[0m"; }
YELLOW() { echo -e "\n\033[0;33m$1\033[0m"; }
RED() { echo -e "\n\033[0;31m$1\033[0m"; }

if [[ -z "$1" ]]; then
echo "Usage: fetch_merge_commit.sh [fetch | merge]"
exit 1
# Try to determine the PR number.
./.circleci/get_pr_number.sh
if [[ -f "$BASH_ENV" ]]; then
source $BASH_ENV
fi

# Push builds are only run against master and amp-release branches.
if [[ "$CIRCLE_BRANCH" == "master" || "$CIRCLE_BRANCH" =~ ^amp-release-* ]]; then
echo $(GREEN "Nothing to do because $CIRCLE_BRANCH is not a PR branch.")
# Warn if the build is linked to a PR on a different repo (known CircleCI bug).
if [[ -n "$CIRCLE_PULL_REQUEST" && ! "$CIRCLE_PULL_REQUEST" =~ ^https://github.com/ampproject/amphtml* ]]; then
echo $(YELLOW "WARNING: Build is incorrectly linked to a PR outside ampproject/amphtml:")
echo $(YELLOW "$CIRCLE_PULL_REQUEST")
fi
exit 0
fi

# CIRCLE_PR_NUMBER is present for PRs originating from forks, but absent for PRs
# originating from a branch on the main repo. In such cases, extract the PR
# number from CIRCLE_PULL_REQUEST.
if [[ "$CIRCLE_PR_NUMBER" ]]; then
PR_NUMBER=$CIRCLE_PR_NUMBER
else
PR_NUMBER=${CIRCLE_PULL_REQUEST#"https://github.com/ampproject/amphtml/pull/"}
fi

# If neither CIRCLE_PR_NUMBER nor CIRCLE_PULL_REQUEST are available, it's
# possible this is a PR branch that is yet to be associated with a PR. Exit
# early becaue there is no merge commit to fetch.
# If PR_NUMBER doesn't exist, there is nothing more to do.
if [[ -z "$PR_NUMBER" ]]; then
echo $(GREEN "Nothing to do because $CIRCLE_BRANCH is not yet linked to a PR.")
exit 0
fi

if [[ "$1" == "fetch" ]]; then
# GitHub provides refs/pull/<PR_NUMBER>/merge, an up-to-date merge branch for
# every PR branch that can be cleanly merged to master. For more details, see:
# https://discuss.circleci.com/t/show-test-results-for-prospective-merge-of-a-github-pr/1662
MERGE_BRANCH="refs/pull/$PR_NUMBER/merge"
echo $(GREEN "Fetching merge SHA from $MERGE_BRANCH...")

CIRCLE_MERGE_SHA="$(git ls-remote https://github.com/ampproject/amphtml.git "$MERGE_BRANCH" | awk '{print $1}')"
echo $(GREEN "Fetched merge SHA $CIRCLE_MERGE_SHA...")
echo "$CIRCLE_MERGE_SHA" > .CIRCLECI_WORKFLOW_MERGE_COMMIT
# If PR_NUMBER exists, but the merge commit file doesn't exist, the PR was
# created after the first stage of CI was run. There is nothing more to do.
if [[ ! -f .CIRCLECI_MERGE_COMMIT ]]; then
exit 0
fi

export CIRCLE_MERGE_SHA="$(cat .CIRCLECI_WORKFLOW_MERGE_COMMIT)"
echo $(GREEN "Fetching merge commit $CIRCLE_MERGE_SHA...")
(set -x && git pull --ff-only origin "$CIRCLE_MERGE_SHA") || err=$?
# Extract the merge commit for this workflow and make it visible to other steps.
CIRCLECI_MERGE_COMMIT="$(cat .CIRCLECI_MERGE_COMMIT)"
echo "export CIRCLECI_MERGE_COMMIT=$CIRCLECI_MERGE_COMMIT" >> $BASH_ENV

# Fetch the merge commit. This ensures that all CI stages use the same commit.
echo $(GREEN "Fetching merge commit $CIRCLECI_MERGE_COMMIT...")
(set -x && git pull --ff-only origin "$CIRCLECI_MERGE_COMMIT") || err=$?

# If a clean merge is not possible, do not proceed with the build. GitHub's UI
# will show an error indicating there was a merge conflict.
Expand Down
55 changes: 55 additions & 0 deletions .circleci/get_pr_number.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
#
# Copyright 2021 The AMP HTML Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the license.

# This script extracts the PR number (if there is one) for a CircleCI build.
# Reference: https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables

set -e
err=0

GREEN() { echo -e "\n\033[0;32m$1\033[0m"; }
YELLOW() { echo -e "\n\033[0;33m$1\033[0m"; }

# Push builds are only run against master and amp-release branches.
if [[ "$CIRCLE_BRANCH" == "master" || "$CIRCLE_BRANCH" =~ ^amp-release-* ]]; then
echo $(GREEN "Nothing to do because $CIRCLE_BRANCH is not a PR branch.")
# Warn if the build is linked to a PR on a different repo (known CircleCI bug).
if [[ -n "$CIRCLE_PULL_REQUEST" && ! "$CIRCLE_PULL_REQUEST" =~ ^https://github.com/ampproject/amphtml* ]]; then
echo $(YELLOW "WARNING: Build is incorrectly linked to a PR outside ampproject/amphtml:")
echo $(YELLOW "$CIRCLE_PULL_REQUEST")
fi
exit 0
fi

# CIRCLE_PR_NUMBER is present for PRs originating from forks, but absent for PRs
# originating from a branch on the main repo. In such cases, extract the PR
# number from CIRCLE_PULL_REQUEST.
if [[ "$CIRCLE_PR_NUMBER" ]]; then
PR_NUMBER=$CIRCLE_PR_NUMBER
else
PR_NUMBER=${CIRCLE_PULL_REQUEST#"https://github.com/ampproject/amphtml/pull/"}
fi

# If neither CIRCLE_PR_NUMBER nor CIRCLE_PULL_REQUEST are available, it's
# possible this is a PR branch that is yet to be associated with a PR. Exit
# early becaue there is no merge commit to fetch.
if [[ -z "$PR_NUMBER" ]]; then
echo $(GREEN "Nothing to do because $CIRCLE_BRANCH is not yet linked to a PR.")
exit 0
fi

echo "export PR_NUMBER=$PR_NUMBER" >> $BASH_ENV
echo $(GREEN "This is a PR build for #$PR_NUMBER.")
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DS_Store
.g4ignore
.CIRCLECI_WORKFLOW_MERGE_COMMIT
.CIRCLECI_MERGE_COMMIT
build/
.amp-dep-check
c
Expand Down
2 changes: 2 additions & 0 deletions 3p/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ import {contentad} from '../ads/vendors/contentad';
import {criteo} from '../ads/vendors/criteo';
import {csa} from '../ads/vendors/csa';
import {dable} from '../ads/vendors/dable';
import {digiteka} from '../ads/vendors/digiteka';
import {directadvert} from '../ads/vendors/directadvert';
import {distroscale} from '../ads/vendors/distroscale';
import {dotandads} from '../ads/vendors/dotandads';
Expand Down Expand Up @@ -543,6 +544,7 @@ register('swoop', swoop);
register('taboola', taboola);
register('tcsemotion', tcsemotion);
register('teads', teads);
register('digiteka', digiteka);
register('temedya', temedya);
register('torimochi', torimochi);
register('tracdelight', tracdelight);
Expand Down
20 changes: 18 additions & 2 deletions ads/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,10 @@ const adConfig = jsonConfiguration({
renderStartImplemented: true,
},

'digiteka': {
renderStartImplemented: true,
},

'directadvert': {
renderStartImplemented: true,
},
Expand Down Expand Up @@ -700,8 +704,20 @@ const adConfig = jsonConfiguration({
},

'marfeel': {
prefetch: 'https://www.googletagservices.com/tag/js/gpt.js',
preconnect: 'https://live.mrf.io',
prefetch: 'https://securepubads.g.doubleclick.net/tag/js/gpt.js',
preconnect: [
'https://live.mrf.io',
'https://tpc.googlesyndication.com',
'https://fastlane.rubiconproject.com',
'https://htlb.casalemedia.com',
'https://prg.smartadserver.com',
'https://ib.adnxs.com',
'https://bidder.criteo.com',
'https://marfeel-d.openx.net',
'https://ice.360yield.com',
'https://mbid.marfeelrev.com',
'https://adservice.google.com',
],
consentHandlingOverride: true,
},

Expand Down
38 changes: 38 additions & 0 deletions ads/vendors/digiteka.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright 2021 The AMP HTML Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {loadScript, validateData} from '../../3p/3p';

/**
* @param {!Window} global
* @param {!Object} data
*/
export function digiteka(global, data) {
/*eslint "google-camelcase/google-camelcase": 0*/
global._digiteka_amp = {
allowed_data: ['mdtk', 'zone', 'adunit'],
mandatory_data: ['mdtk', 'zone'],
data,
};

validateData(
data,
global._digiteka_amp.mandatory_data,
global._digiteka_amp.allowed_data
);

loadScript(global, 'https://ot.digiteka.com/amp.js');
}
Loading

0 comments on commit 8ac023b

Please sign in to comment.