Skip to content

Commit 9b52991

Browse files
gkalpakmatsko
authored andcommitted
ci: remove change type from uploaded payload size data (angular#33987)
The change type was only recorded for `aio/` and was not correct anyway. For example: - It considered `package.json` changes as `application` (even if only `package.json` and `yarn.lock` had changed). - It failed to account for changes in `@angular/*` dependencies, when using the locally built Angular packages (instead reporting them as `other`). - It only looked at the last commit, so it failed to provide accurate information for multi-commit builds (which are rare, but possible). For the above reasons (and because there is no straight-forward way of fixing it), this commit removes the change type from the uploaded data. If necessary, it is still possible to find the type of changes from the uploaded info (e.g. extract the associated commits and look at their changes using git). PR Close angular#33987
1 parent 9bc8864 commit 9b52991

3 files changed

Lines changed: 12 additions & 40 deletions

File tree

aio/scripts/payload.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ source ../scripts/ci/payload-size.sh
1212
# Provide node_modules from aio
1313
NODE_MODULES_BIN=$PROJECT_ROOT/aio/node_modules/.bin/
1414

15-
trackPayloadSize "$target" "dist/*.js" true true "${thisDir}/_payload-limits.json"
15+
trackPayloadSize "$target" "dist/*.js" true "${thisDir}/_payload-limits.json"

integration/run_tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ for testDir in ${TEST_DIRS}; do
6464
yarn build
6565
fi
6666

67-
trackPayloadSize "$testDir" "dist/*.js" true false "${basedir}/integration/_payload-limits.json"
67+
trackPayloadSize "$testDir" "dist/*.js" true "${basedir}/integration/_payload-limits.json"
6868
fi
6969

7070
# remove the temporary node modules directory to keep the source folder clean.
@@ -73,5 +73,5 @@ for testDir in ${TEST_DIRS}; do
7373
done
7474

7575
if $CI; then
76-
trackPayloadSize "umd" "../dist/packages-dist/*/bundles/*.umd.min.js" false false
76+
trackPayloadSize "umd" "../dist/packages-dist/*/bundles/*.umd.min.js" false
7777
fi

scripts/ci/payload-size.sh

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -80,36 +80,6 @@ addMessage() {
8080
payloadData="$payloadData\"message\": \"$message\", "
8181
}
8282

83-
# Add change source: `application`, `dependencies`, or `application+dependencies`
84-
# Read from global variable `$parentDir`.
85-
# Update the change source in global variable `$payloadData`.
86-
# $1: string - The commit range for this build (in `<SHA-1>...<SHA-2>` format).
87-
addChangeType() {
88-
commitRange="$1"
89-
90-
yarnChanged=false
91-
allChangedFiles=$(git diff --name-only $commitRange $parentDir | wc -l)
92-
allChangedFileNames=$(git diff --name-only $commitRange $parentDir)
93-
94-
if [[ $allChangedFileNames == *"yarn.lock"* ]]; then
95-
yarnChanged=true
96-
fi
97-
98-
if [[ $allChangedFiles -eq 1 ]] && [[ "$yarnChanged" = true ]]; then
99-
# only yarn.lock changed
100-
change='dependencies'
101-
elif [[ $allChangedFiles -gt 1 ]] && [[ "$yarnChanged" = true ]]; then
102-
change='application+dependencies'
103-
elif [[ $allChangedFiles -gt 0 ]]; then
104-
change='application'
105-
else
106-
# Nothing changed inside $parentDir (but size may still be affected; e.g. when using the locally
107-
# built packages)
108-
change='other'
109-
fi
110-
payloadData="$payloadData\"change\": \"$change\", "
111-
}
112-
11383
# Convert the current `payloadData` value to a JSON string.
11484
# (Basically remove trailing `,` and wrap in `{...}`.)
11585
payloadToJson() {
@@ -134,18 +104,17 @@ uploadData() {
134104
# $1: string - The name in database.
135105
# $2: string - The file path.
136106
# $3: true | false - Whether to check the payload size and fail the test if it exceeds limit.
137-
# $4: true | false - Whether to record the type of changes.
138-
# $5: [string] - The payload size limit file. Only necessary if `$3` is `true`.
107+
# $4: [string] - The payload size limit file. Only necessary if `$3` is `true`.
139108
trackPayloadSize() {
140109
name="$1"
141110
path="$2"
142111
checkSize="$3"
143-
trackChangeType="$4"
144-
limitFile="${5:-}"
112+
limitFile="${4:-}"
145113

146114
payloadData=""
147115

148116
# Calculate the file sizes.
117+
echo "Calculating sizes for files in '$path'..."
149118
for filename in $path; do
150119
calculateSize
151120
done
@@ -155,17 +124,20 @@ trackPayloadSize() {
155124

156125
# If this is a non-PR build, upload the data to firebase.
157126
if [[ "$CI_PULL_REQUEST" == "false" ]]; then
158-
if [[ $trackChangeType = true ]]; then
159-
addChangeType $CI_COMMIT_RANGE
160-
fi
127+
echo "Uploading data for '$name'..."
161128
addTimestamp
162129
addBuildUrl $CI_BUILD_URL
163130
addMessage $CI_COMMIT_RANGE
164131
uploadData $name
132+
else
133+
echo "Skipped uploading data for '$name', because this is a pull request."
165134
fi
166135

167136
# Check the file sizes against the specified limits.
168137
if [[ $checkSize = true ]]; then
138+
echo "Verifying sizes against '$limitFile'..."
169139
checkSize $name $limitFile
140+
else
141+
echo "Skipped verifying sizes (checkSize: false)."
170142
fi
171143
}

0 commit comments

Comments
 (0)