parent
1bbf28ad19
commit
9b8a244a15
|
@ -25,8 +25,9 @@ var_3: &define_env_vars
|
||||||
# This is the branch being built; e.g. `pull/12345` for PR builds.
|
# This is the branch being built; e.g. `pull/12345` for PR builds.
|
||||||
echo "export CI_BRANCH=$CIRCLE_BRANCH" | tee -a $BASH_ENV
|
echo "export CI_BRANCH=$CIRCLE_BRANCH" | tee -a $BASH_ENV
|
||||||
echo "export CI_COMMIT=$CIRCLE_SHA1" | tee -a $BASH_ENV
|
echo "export CI_COMMIT=$CIRCLE_SHA1" | tee -a $BASH_ENV
|
||||||
# TODO(gkalpak): Fix this.
|
# `CI_COMMIT_RANGE` will only be available when `CIRCLE_COMPARE_URL` is also available,
|
||||||
echo "export CI_COMMIT_RANGE=???" | tee -a $BASH_ENV
|
# i.e. on push builds (a.k.a. non-PR builds). That is fine, since we only need it in push builds.
|
||||||
|
echo "export CI_COMMIT_RANGE=$(sed -r 's|^.*/([0-9a-f]+\.\.\.[0-9a-f]+)$|\1|i' <<< ${CIRCLE_COMPARE_URL:-})" | tee -a $BASH_ENV
|
||||||
echo "export CI_PULL_REQUEST=${CIRCLE_PR_NUMBER:-false}" | tee -a $BASH_ENV
|
echo "export CI_PULL_REQUEST=${CIRCLE_PR_NUMBER:-false}" | tee -a $BASH_ENV
|
||||||
echo "export CI_REPO_NAME=$CIRCLE_PROJECT_REPONAME" | tee -a $BASH_ENV
|
echo "export CI_REPO_NAME=$CIRCLE_PROJECT_REPONAME" | tee -a $BASH_ENV
|
||||||
echo "export CI_REPO_OWNER=$CIRCLE_PROJECT_USERNAME" | tee -a $BASH_ENV
|
echo "export CI_REPO_OWNER=$CIRCLE_PROJECT_USERNAME" | tee -a $BASH_ENV
|
||||||
|
@ -172,8 +173,7 @@ jobs:
|
||||||
command: xvfb-run --auto-servernum yarn --cwd aio test-pwa-score-localhost $CI_AIO_MIN_PWA_SCORE
|
command: xvfb-run --auto-servernum yarn --cwd aio test-pwa-score-localhost $CI_AIO_MIN_PWA_SCORE
|
||||||
# Check the bundle sizes.
|
# Check the bundle sizes.
|
||||||
# (Run before unit and e2e tests, which destroy the `dist/` directory.)
|
# (Run before unit and e2e tests, which destroy the `dist/` directory.)
|
||||||
# TODO(gkalpak): Fix this.
|
- run: yarn --cwd aio payload-size
|
||||||
# - run: yarn --cwd aio payload-size
|
|
||||||
# Run unit tests
|
# Run unit tests
|
||||||
- run: xvfb-run --auto-servernum yarn --cwd aio test --watch=false
|
- run: xvfb-run --auto-servernum yarn --cwd aio test --watch=false
|
||||||
# Run e2e tests
|
# Run e2e tests
|
||||||
|
|
|
@ -34,10 +34,6 @@ env:
|
||||||
# This is needed for publishing builds to the "aio-staging" and "angular-io" firebase projects.
|
# This is needed for publishing builds to the "aio-staging" and "angular-io" firebase projects.
|
||||||
# This token was generated using the aio-deploy@angular.io account using `firebase login:ci` and password from valentine
|
# This token was generated using the aio-deploy@angular.io account using `firebase login:ci` and password from valentine
|
||||||
- secure: "L5CyQmpwWtoR4Qi4xlWQh/cL1M6ZeJL4W4QAr4HdKFMgYt9h+Whqkymyh2NxwmCbPvWa7yUd+OiLQUDCY7L2VIg16hTwoe2CgYDyQA0BEwLzxtRrJXl93TfwMlrUx5JSIzAccD6D4sjtz8kSFMomK2Nls33xOXOukwyhVMjd0Cg="
|
- secure: "L5CyQmpwWtoR4Qi4xlWQh/cL1M6ZeJL4W4QAr4HdKFMgYt9h+Whqkymyh2NxwmCbPvWa7yUd+OiLQUDCY7L2VIg16hTwoe2CgYDyQA0BEwLzxtRrJXl93TfwMlrUx5JSIzAccD6D4sjtz8kSFMomK2Nls33xOXOukwyhVMjd0Cg="
|
||||||
# ANGULAR_PAYLOAD_FIREBASE_TOKEN
|
|
||||||
# This is for payload size data to "angular-payload-size" firebase project
|
|
||||||
# This token was generated using the payload@angular.io account using `firebase login:ci` and password from valentine
|
|
||||||
- secure: "SxotP/ymNy6uWAVbfwM9BlwETPEBpkRvU/F7fCtQDDic99WfQHzzUSQqHTk8eKk3GrGAOSL09vT0WfStQYEIGEoS5UHWNgOnelxhw+d5EnaoB8vQ0dKQBTK092hQg4feFprr+B/tCasyMV6mVwpUzZMbIJNn/Rx7H5g1bp+Gkfg="
|
|
||||||
matrix:
|
matrix:
|
||||||
# Order: a slower build first, so that we don't occupy an idle travis worker waiting for others to complete.
|
# Order: a slower build first, so that we don't occupy an idle travis worker waiting for others to complete.
|
||||||
- CI_MODE=e2e
|
- CI_MODE=e2e
|
||||||
|
|
|
@ -48,7 +48,6 @@ setEnvVar CI_PULL_REQUEST $TRAVIS_PULL_REQUEST
|
||||||
setEnvVar PROJECT_ROOT $(cd ${thisDir}/../..; pwd)
|
setEnvVar PROJECT_ROOT $(cd ${thisDir}/../..; pwd)
|
||||||
# WARNING: Secrets (do not print).
|
# WARNING: Secrets (do not print).
|
||||||
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=$FIREBASE_TOKEN
|
export CI_SECRET_AIO_DEPLOY_FIREBASE_TOKEN=$FIREBASE_TOKEN
|
||||||
export CI_SECRET_PAYLOAD_FIREBASE_TOKEN=$ANGULAR_PAYLOAD_FIREBASE_TOKEN
|
|
||||||
|
|
||||||
if [[ ${TRAVIS:-} ]]; then
|
if [[ ${TRAVIS:-} ]]; then
|
||||||
case ${CI_MODE} in
|
case ${CI_MODE} in
|
||||||
|
|
|
@ -42,22 +42,28 @@ addTimestamp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Write travis commit message to global variable `$payloadData`.
|
# Write travis commit message to global variable `$payloadData`.
|
||||||
|
# $1: string - The commit range for this build (in `<SHA-1>...<SHA-2>` format).
|
||||||
addMessage() {
|
addMessage() {
|
||||||
|
commitRange="$1"
|
||||||
|
|
||||||
# Grab the set of SHAs for the message. This can fail when you force push or do initial build
|
# Grab the set of SHAs for the message. This can fail when you force push or do initial build
|
||||||
# because $CI_COMMIT_RANGE may contain the previous SHA which will not be in the
|
# because $CI_COMMIT_RANGE may contain the previous SHA which will not be in the
|
||||||
# force push or commit, hence we default to last commit.
|
# force push or commit, hence we default to last commit.
|
||||||
message=$(git log --oneline $CI_COMMIT_RANGE -- || git log --oneline -n1)
|
message=$(git log --oneline $commitRange -- || git log --oneline -n1)
|
||||||
message=$(echo $message | sed 's/\\/\\\\/g' | sed 's/"/\\"/g')
|
message=$(echo $message | sed 's/\\/\\\\/g' | sed 's/"/\\"/g')
|
||||||
payloadData="$payloadData\"message\": \"$message\""
|
payloadData="$payloadData\"message\": \"$message\", "
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add change source: `application`, `dependencies`, or `application+dependencies`
|
# Add change source: `application`, `dependencies`, or `application+dependencies`
|
||||||
# Read from global variable `$parentDir`.
|
# Read from global variable `$parentDir`.
|
||||||
# Update the change source in global variable `$payloadData`.
|
# Update the change source in global variable `$payloadData`.
|
||||||
addChange() {
|
# $1: string - The commit range for this build (in `<SHA-1>...<SHA-2>` format).
|
||||||
|
addChangeType() {
|
||||||
|
commitRange="$1"
|
||||||
|
|
||||||
yarnChanged=false
|
yarnChanged=false
|
||||||
allChangedFiles=$(git diff --name-only $CI_COMMIT_RANGE $parentDir | wc -l)
|
allChangedFiles=$(git diff --name-only $commitRange $parentDir | wc -l)
|
||||||
allChangedFileNames=$(git diff --name-only $CI_COMMIT_RANGE $parentDir)
|
allChangedFileNames=$(git diff --name-only $commitRange $parentDir)
|
||||||
|
|
||||||
if [[ $allChangedFileNames == *"yarn.lock"* ]]; then
|
if [[ $allChangedFileNames == *"yarn.lock"* ]]; then
|
||||||
yarnChanged=true
|
yarnChanged=true
|
||||||
|
@ -77,23 +83,24 @@ addChange() {
|
||||||
payloadData="$payloadData\"change\": \"$change\", "
|
payloadData="$payloadData\"change\": \"$change\", "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Convert the current `payloadData` value to a JSON string.
|
||||||
|
# (Basically remove trailing `,` and wrap in `{...}`.)
|
||||||
|
payloadToJson() {
|
||||||
|
echo "{$(sed -r 's|, *$||' <<< $payloadData)}"
|
||||||
|
}
|
||||||
|
|
||||||
# Upload data to firebase database if it's commit, print out data for pull requests.
|
# Upload data to firebase database if it's commit, print out data for pull requests.
|
||||||
# $1: string - The name in database.
|
# $1: string - The name in database.
|
||||||
uploadData() {
|
uploadData() {
|
||||||
name="$1"
|
name="$1"
|
||||||
payloadData="{${payloadData}}"
|
|
||||||
|
|
||||||
echo $payloadData > /tmp/current.log
|
|
||||||
|
|
||||||
readonly safeBranchName=$(echo $CI_BRANCH | sed -e 's/\./_/g')
|
readonly safeBranchName=$(echo $CI_BRANCH | sed -e 's/\./_/g')
|
||||||
|
|
||||||
if [[ "$CI_PULL_REQUEST" == "false" ]]; then
|
|
||||||
readonly dbPath=/payload/$name/$safeBranchName/$CI_COMMIT
|
readonly dbPath=/payload/$name/$safeBranchName/$CI_COMMIT
|
||||||
|
readonly jsonPayload=$(payloadToJson)
|
||||||
|
|
||||||
# WARNING: CI_SECRET_PAYLOAD_FIREBASE_TOKEN should NOT be printed.
|
# WARNING: CI_SECRET_PAYLOAD_FIREBASE_TOKEN should NOT be printed.
|
||||||
set +x
|
set +x
|
||||||
$NODE_MODULES_BIN/firebase database:update --data "$payloadData" --project $PROJECT_NAME --confirm --token "$CI_SECRET_PAYLOAD_FIREBASE_TOKEN" $dbPath
|
$NODE_MODULES_BIN/firebase database:update --data "$jsonPayload" --project $PROJECT_NAME --confirm --token "$CI_SECRET_PAYLOAD_FIREBASE_TOKEN" $dbPath
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Track payload size.
|
# Track payload size.
|
||||||
|
@ -106,21 +113,31 @@ trackPayloadSize() {
|
||||||
name="$1"
|
name="$1"
|
||||||
path="$2"
|
path="$2"
|
||||||
checkSize="$3"
|
checkSize="$3"
|
||||||
trackChange="$4"
|
trackChangeType="$4"
|
||||||
limitFile="${5:-}"
|
limitFile="${5:-}"
|
||||||
|
|
||||||
payloadData=""
|
payloadData=""
|
||||||
|
|
||||||
|
# Calculate the file sizes.
|
||||||
for filename in $path; do
|
for filename in $path; do
|
||||||
declare -A size
|
declare -A size
|
||||||
calculateSize
|
calculateSize
|
||||||
done
|
done
|
||||||
addTimestamp
|
|
||||||
if [[ $trackChange = true ]]; then
|
# Save the file sizes to be retrieved from `payload-size.js`.
|
||||||
addChange
|
echo "$(payloadToJson)" > /tmp/current.log
|
||||||
|
|
||||||
|
# If this is a non-PR build, upload the data to firebase.
|
||||||
|
if [[ "$CI_PULL_REQUEST" == "false" ]]; then
|
||||||
|
if [[ $trackChangeType = true ]]; then
|
||||||
|
addChangeType $CI_COMMIT_RANGE
|
||||||
fi
|
fi
|
||||||
addMessage
|
addTimestamp
|
||||||
|
addMessage $CI_COMMIT_RANGE
|
||||||
uploadData $name
|
uploadData $name
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check the file sizes against the specified limits.
|
||||||
if [[ $checkSize = true ]]; then
|
if [[ $checkSize = true ]]; then
|
||||||
checkSize $name $limitFile
|
checkSize $name $limitFile
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue