Skip to content

build: switch to yaml file for size test golden #19621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
/.github/ISSUE_TEMPLATE/** @andrewseguin @jelbourn
/.vscode/** @angular/dev-infra-components @mmalerba
/.ng-dev/** @angular/dev-infra-components
/goldens/size-test.json @jelbourn @mmalerba @crisbeto
/goldens/size-test.yml @jelbourn @mmalerba @crisbeto
/goldens/** @angular/dev-infra-components
/src/* @angular/dev-infra-components
/* @angular/dev-infra-components
2 changes: 1 addition & 1 deletion goldens/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
exports_files([
"size-test.json",
"size-test.yaml",
])
3 changes: 0 additions & 3 deletions goldens/size-test.json

This file was deleted.

1 change: 1 addition & 0 deletions goldens/size-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
material/list/nav-list: 153231
2 changes: 2 additions & 0 deletions integration/size-test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ ts_library(
srcs = ["check-size.ts"],
deps = [
"@npm//@types/node",
"@npm//@types/yaml",
"@npm//chalk",
"@npm//yaml",
],
)
7 changes: 4 additions & 3 deletions integration/size-test/check-size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import chalk from 'chalk';
import {readFileSync, statSync, writeFileSync} from 'fs';
import {parse, stringify} from 'yaml';

/**
* Absolute byte deviation from the expected value that is allowed. If the
Expand All @@ -27,16 +28,16 @@ const PERCENTAGE_DEVIATION_THRESHOLD = 1;
*/
const [testId, testFileRootpath, isApprove] = process.argv.slice(2);
const testFilePath = require.resolve(`angular_material/${testFileRootpath}`);
const goldenFilePath = require.resolve('../../goldens/size-test.json');
const goldenFilePath = require.resolve('../../goldens/size-test.yaml');

const golden = JSON.parse(readFileSync(goldenFilePath, 'utf8'));
const golden = parse(readFileSync(goldenFilePath, 'utf8')) || {};
const fileStat = statSync(testFilePath);
const actualSize = fileStat.size;

// If in approve mode, update the golden to reflect the new size.
if (isApprove) {
golden[testId] = actualSize;
writeFileSync(goldenFilePath, JSON.stringify(golden, null, 2));
writeFileSync(goldenFilePath, stringify(golden));
console.info(chalk.green(`Approved golden size for "${testId}"`));
process.exit(0);
}
Expand Down
4 changes: 2 additions & 2 deletions integration/size-test/index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def size_test(name, file, deps):
nodejs_test(
name = name,
data = [
"//goldens:size-test.json",
"//goldens:size-test.yaml",
"//integration/size-test:check-size",
":%s_bundle_min" % name,
],
Expand All @@ -65,7 +65,7 @@ def size_test(name, file, deps):
name = "%s.approve" % name,
testonly = True,
data = [
"//goldens:size-test.json",
"//goldens:size-test.yaml",
"//integration/size-test:check-size",
":%s_bundle_min" % name,
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//integration/size-test:index.bzl", "size_test")

size_test(
name = "list",
file = "list.ts",
name = "nav-list",
file = "nav-list.ts",
deps = ["//src/material/list"],
)
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"@types/semver": "^6.2.0",
"@types/send": "^0.14.5",
"@types/stylelint": "^9.10.1",
"@types/yaml": "^1.9.7",
"autoprefixer": "^6.7.6",
"axe-webdriverjs": "^1.1.1",
"browser-sync": "^2.26.7",
Expand Down Expand Up @@ -167,7 +168,7 @@
"typescript-3.7": "npm:typescript@~3.7.0",
"typescript-3.8": "npm:typescript@~3.8.0",
"vrsource-tslint-rules": "5.1.1",
"yaml": "^1.7.2",
"yaml": "^1.10.0",
"yargs": "15.3.0"
},
"resolutions": {
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,13 @@
dependencies:
"@types/node" "*"

"@types/yaml@^1.9.7":
version "1.9.7"
resolved "https://registry.yarnpkg.com/@types/yaml/-/yaml-1.9.7.tgz#2331f36e0aac91311a63d33eb026c21687729679"
integrity sha512-8WMXRDD1D+wCohjfslHDgICd2JtMATZU8CkhH8LVJqcJs6dyYj5TGptzP8wApbmEullGBSsCEzzap73DQ1HJaA==
dependencies:
yaml "*"

"@types/youtube@^0.0.38":
version "0.0.38"
resolved "https://registry.yarnpkg.com/@types/youtube/-/youtube-0.0.38.tgz#04aa5efa61f4d52e9cf682575a9dfed58f31e8c1"
Expand Down Expand Up @@ -12759,6 +12766,11 @@ yallist@^3.0.0, yallist@^3.0.2:
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9"
integrity sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==

yaml@*, yaml@^1.10.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==

yaml@^1.7.2:
version "1.7.2"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.7.2.tgz#f26aabf738590ab61efaca502358e48dc9f348b2"
Expand Down