diff --git a/.github/workflows/selenium-lab-tests.yaml b/.github/workflows/selenium-lab-tests.yaml index 74ef84dbc5..3967eea1bd 100644 --- a/.github/workflows/selenium-lab-tests.yaml +++ b/.github/workflows/selenium-lab-tests.yaml @@ -148,6 +148,30 @@ jobs: - name: Build Player run: python3 build/all.py + - name: Preprocess with Babel + run: | + # Run the test preprocessor without running the actual tests. + # This lets us cache Babel's output and run it only once. + # Ignore the exit code, since you get an error code if the filter + # excludes all tests. + ./build/test.py \ + --use-xvfb --browsers Chrome \ + --filter ThisFilterMatchesNoTests || true + + - name: Cache dependencies + uses: actions/cache@v3 + id: npm-cache + with: + path: node_modules/ + key: node-${{ hashFiles('package-lock.json') }} + + - name: Cache Babel output + uses: actions/cache@v3 + id: babel-cache + with: + path: .babel-cache + key: babel-${{ hashFiles('*.js', 'demo/**.js', 'lib/**.js', 'ui/**.js', 'test/**.js', 'third_party/**.js') }} + - name: Store Player build uses: actions/upload-artifact@v3 with: @@ -206,6 +230,17 @@ jobs: with: path: node_modules/ key: node-${{ hashFiles('package-lock.json') }} + fail-on-cache-miss: true # Cached by the build-shaka job above + enableCrossOsArchive: true # Share archives from Linux to Windows + + - name: Cache Babel output + uses: actions/cache@v3 + id: babel-cache + with: + path: .babel-cache + key: babel-${{ hashFiles('*.js', 'demo/**.js', 'lib/**.js', 'ui/**.js', 'test/**.js', 'third_party/**.js') }} + fail-on-cache-miss: true # Cached by the build-shaka job above + enableCrossOsArchive: true # Share archives from Linux to Windows - name: Install dependencies if: steps.npm-cache.outputs.cache-hit != 'true' diff --git a/.gitignore b/.gitignore index 18b18a430a..669e54aaa4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ docs/api/ coverage/ .DS_Store .vscode -/_mytest/ .idea +.babel-cache +/_mytest/ diff --git a/karma.conf.js b/karma.conf.js index 233ec35b3a..5db40c6cf7 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -354,6 +354,8 @@ module.exports = (config) => { }, babelPreprocessor: { + // Cache results in .babel-cache + cachePath: '.babel-cache', options: { presets: ['@babel/preset-env'], // Add source maps so that backtraces refer to the original code. diff --git a/package-lock.json b/package-lock.json index 96adbf38c0..2910ab24f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "@babel/core": "^7.17.5", "@babel/polyfill": "^7.12.1", "@babel/preset-env": "^7.16.11", + "@joeyparrish/karma-babel-preprocessor": "^8.2.0", "@teppeis/clutz": "^1.0.29-4c95e12.v20190929", "awesomplete": "^1.1.5", "babel-plugin-istanbul": "^6.1.1", @@ -40,7 +41,6 @@ "js-yaml": "^4.1.0", "jsdoc": "github:joeyparrish/jsdoc#2ca85bb6", "karma": "^6.3.16", - "karma-babel-preprocessor": "^8.0.2", "karma-coverage": "^2.2.0", "karma-jasmine": "^4.0.1", "karma-jasmine-ajax": "^0.1.13", @@ -2253,6 +2253,21 @@ "regenerator-runtime": "^0.13.3" } }, + "node_modules/@joeyparrish/karma-babel-preprocessor": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@joeyparrish/karma-babel-preprocessor/-/karma-babel-preprocessor-8.2.0.tgz", + "integrity": "sha512-GFAw3UB9Uji/U78c4rKCWa/KPX/UiKJ5W9cqJ9EMvPT+kBZGJv2wjdtvQyc3bEN+KkDYVc86+qnKbK5quRY0JA==", + "dev": true, + "dependencies": { + "node-localcache": "^0.1.4" + }, + "engines": { + "node": ">=6" + }, + "peerDependencies": { + "@babel/core": "7" + } + }, "node_modules/@jridgewell/resolve-uri": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz", @@ -4688,6 +4703,27 @@ "node": ">= 0.4.0" } }, + "node_modules/has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==", + "dev": true, + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/has-ansi/node_modules/ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -5522,18 +5558,6 @@ "node": ">= 10" } }, - "node_modules/karma-babel-preprocessor": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/karma-babel-preprocessor/-/karma-babel-preprocessor-8.0.2.tgz", - "integrity": "sha512-6ZUnHwaK2EyhgxbgeSJW6n6WZUYSEdekHIV/qDUnPgMkVzQBHEvd07d2mTL5AQjV8uTUgH6XslhaPrp+fHWH2A==", - "dev": true, - "engines": { - "node": ">=6" - }, - "peerDependencies": { - "@babel/core": "7" - } - }, "node_modules/karma-coverage": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/karma-coverage/-/karma-coverage-2.2.0.tgz", @@ -6220,6 +6244,12 @@ "node": ">=10" } }, + "node_modules/mkpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mkpath/-/mkpath-1.0.0.tgz", + "integrity": "sha512-PbNHr7Y/9Y/2P5pKFv5XOGBfNQqZ+fdiHWcuf7swLACN5ZW5LU7J5tMU8LSBjpluAxAxKYGD9nnaIbdRy9+m1w==", + "dev": true + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -6330,6 +6360,78 @@ } } }, + "node_modules/node-localcache": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/node-localcache/-/node-localcache-0.1.4.tgz", + "integrity": "sha512-rMFXjC/SDHQmv7Nx0pwnSaaE6CtUx/7F4cRylWZDimlLwokH1ouhghNaNHRyHLjFfoDwgHglJzIrA4gRKd1XRg==", + "dev": true, + "dependencies": { + "chalk": "1.1.1", + "lodash": "4.13.1", + "mkpath": "1.0.0" + } + }, + "node_modules/node-localcache/node_modules/ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/node-localcache/node_modules/ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/node-localcache/node_modules/chalk": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.1.tgz", + "integrity": "sha512-W10W+QfIxJlTm3VRtg8eafwUBkDfUPFvRvPv4jCD9vF4+HzlAyXJ7P3Y5yw/r+gJ1TzFEU6oFqMgp1dIVpYr0A==", + "dev": true, + "dependencies": { + "ansi-styles": "^2.1.0", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/node-localcache/node_modules/lodash": { + "version": "4.13.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.13.1.tgz", + "integrity": "sha512-j/GRONYpkXt1aB1bQHzkq0Th7zhv/syoDVrzCDA3FDMntIin0b7TjXi62q9juDC+QfhRs9COr0LFW38vQSH9Tg==", + "dev": true + }, + "node_modules/node-localcache/node_modules/strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", + "dev": true, + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/node-localcache/node_modules/supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/node-releases": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.2.tgz", @@ -10254,6 +10356,15 @@ "regenerator-runtime": "^0.13.3" } }, + "@joeyparrish/karma-babel-preprocessor": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@joeyparrish/karma-babel-preprocessor/-/karma-babel-preprocessor-8.2.0.tgz", + "integrity": "sha512-GFAw3UB9Uji/U78c4rKCWa/KPX/UiKJ5W9cqJ9EMvPT+kBZGJv2wjdtvQyc3bEN+KkDYVc86+qnKbK5quRY0JA==", + "dev": true, + "requires": { + "node-localcache": "^0.1.4" + } + }, "@jridgewell/resolve-uri": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz", @@ -12170,6 +12281,23 @@ "function-bind": "^1.1.1" } }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", + "dev": true + } + } + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -12824,13 +12952,6 @@ } } }, - "karma-babel-preprocessor": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/karma-babel-preprocessor/-/karma-babel-preprocessor-8.0.2.tgz", - "integrity": "sha512-6ZUnHwaK2EyhgxbgeSJW6n6WZUYSEdekHIV/qDUnPgMkVzQBHEvd07d2mTL5AQjV8uTUgH6XslhaPrp+fHWH2A==", - "dev": true, - "requires": {} - }, "karma-coverage": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/karma-coverage/-/karma-coverage-2.2.0.tgz", @@ -13352,6 +13473,12 @@ "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", "dev": true }, + "mkpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mkpath/-/mkpath-1.0.0.tgz", + "integrity": "sha512-PbNHr7Y/9Y/2P5pKFv5XOGBfNQqZ+fdiHWcuf7swLACN5ZW5LU7J5tMU8LSBjpluAxAxKYGD9nnaIbdRy9+m1w==", + "dev": true + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -13427,6 +13554,65 @@ "whatwg-url": "^5.0.0" } }, + "node-localcache": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/node-localcache/-/node-localcache-0.1.4.tgz", + "integrity": "sha512-rMFXjC/SDHQmv7Nx0pwnSaaE6CtUx/7F4cRylWZDimlLwokH1ouhghNaNHRyHLjFfoDwgHglJzIrA4gRKd1XRg==", + "dev": true, + "requires": { + "chalk": "1.1.1", + "lodash": "4.13.1", + "mkpath": "1.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", + "dev": true + }, + "chalk": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.1.tgz", + "integrity": "sha512-W10W+QfIxJlTm3VRtg8eafwUBkDfUPFvRvPv4jCD9vF4+HzlAyXJ7P3Y5yw/r+gJ1TzFEU6oFqMgp1dIVpYr0A==", + "dev": true, + "requires": { + "ansi-styles": "^2.1.0", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "lodash": { + "version": "4.13.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.13.1.tgz", + "integrity": "sha512-j/GRONYpkXt1aB1bQHzkq0Th7zhv/syoDVrzCDA3FDMntIin0b7TjXi62q9juDC+QfhRs9COr0LFW38vQSH9Tg==", + "dev": true + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", + "dev": true + } + } + }, "node-releases": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.2.tgz", diff --git a/package.json b/package.json index ec9b13c2e6..2c58f5bfbf 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@babel/core": "^7.17.5", "@babel/polyfill": "^7.12.1", "@babel/preset-env": "^7.16.11", + "@joeyparrish/karma-babel-preprocessor": "^8.2.0", "@teppeis/clutz": "^1.0.29-4c95e12.v20190929", "awesomplete": "^1.1.5", "babel-plugin-istanbul": "^6.1.1", @@ -39,7 +40,6 @@ "js-yaml": "^4.1.0", "jsdoc": "github:joeyparrish/jsdoc#2ca85bb6", "karma": "^6.3.16", - "karma-babel-preprocessor": "^8.0.2", "karma-coverage": "^2.2.0", "karma-jasmine": "^4.0.1", "karma-jasmine-ajax": "^0.1.13",