-
Notifications
You must be signed in to change notification settings - Fork 6.8k
build: cronjob to run tests against mdc snapshot builds #16668
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
jelbourn
merged 1 commit into
angular:master
from
devversion:build/snapshot-cronjob-mdc-master
Aug 20, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,12 @@ var_17: &setup_bazel_binary | |
name: "Setting up global Bazel binary" | ||
command: ./scripts/circleci/setup_bazel_binary.sh | ||
|
||
# **Note**: When updating the beginning of the cache key, also update the fallback cache | ||
# key to match the new cache key prefix. This allows us to take advantage of CircleCI's | ||
# fallback caching. Read more here: https://circleci.com/docs/2.0/caching/#restoring-cache. | ||
var_18: &mdc_deps_cache_key v1-mdc-deps-{{ checksum "/tmp/material-components-web/package-lock.json" }} | ||
var_19: &mdc_deps_fallback_cache_key v1-mdc-deps- | ||
|
||
# ----------------------------- | ||
# Container version of CircleCI | ||
# ----------------------------- | ||
|
@@ -456,6 +462,53 @@ jobs: | |
- run: bazel build src/... --build_tag_filters=-docs-package,-e2e --define=compile=aot | ||
- run: bazel test src/... --build_tag_filters=-docs-package,-e2e --test_tag_filters=-e2e --define=compile=aot | ||
|
||
# ---------------------------------------------------------------------------- | ||
# Job that runs all Bazel tests against material-components-web#master. | ||
# ---------------------------------------------------------------------------- | ||
mdc_snapshot_test_cronjob: | ||
<<: *job_defaults | ||
resource_class: xlarge | ||
environment: | ||
GCP_DECRYPT_TOKEN: *gcp_decrypt_token | ||
MDC_REPO_URL: "https://github.com/material-components/material-components-web.git" | ||
MDC_REPO_BRANCH: "master" | ||
MDC_REPO_TMP_DIR: "/tmp/material-components-web" | ||
steps: | ||
- *checkout_code | ||
- *restore_cache | ||
- *setup_bazel_binary | ||
- *setup_bazel_ci_config | ||
- *setup_bazel_remote_execution | ||
- *yarn_download | ||
- *yarn_install | ||
|
||
- run: git clone ${MDC_REPO_URL} --branch ${MDC_REPO_BRANCH} --depth 1 ${MDC_REPO_TMP_DIR} | ||
- restore_cache: | ||
keys: | ||
- *mdc_deps_cache_key | ||
- *mdc_deps_fallback_cache_key | ||
- run: | ||
name: "Installing dependencies for MDC repository" | ||
# MDC repository does not use Yarn for node dependencies, so in order to respect the | ||
# lock-file we need to use "npm" when installing dependencies. | ||
command: cd ${MDC_REPO_TMP_DIR} && npm install | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abhiomkar have you all considered switching to |
||
- save_cache: | ||
key: *mdc_deps_cache_key | ||
paths: | ||
# Repository path must be kept in sync with the `$MDC_REPO_TMP_DIR` env variable. | ||
# It needs to be hardcoded here, because env variables interpolation is not supported. | ||
- "/tmp/material-components-web/node_modules" | ||
- run: | ||
name: "Building MDC snapshot builds" | ||
command: | | ||
cd ${MDC_REPO_TMP_DIR} | ||
yarn dist && node scripts/cp-pkgs.js | ||
# Setup the components repository to use the MDC snapshot builds. | ||
- run: node ./scripts/circleci/setup-mdc-snapshots.js ${MDC_REPO_TMP_DIR}/packages/ $(git -C ${MDC_REPO_TMP_DIR} rev-parse HEAD) | ||
# Run project tests with the MDC snapshot builds. | ||
- run: bazel build src/... --build_tag_filters=-docs-package,-e2e | ||
- run: bazel test src/... --build_tag_filters=-docs-package,-e2e --test_tag_filters=-e2e | ||
|
||
# ---------------------------------------------------------------------------------------- | ||
# Workflow definitions. A workflow usually groups multiple jobs together. This is useful if | ||
# one job depends on another. | ||
|
@@ -519,6 +572,7 @@ workflows: | |
# workflow. See: https://circleci.com/ideas/?idea=CCI-I-295 | ||
- snapshot_tests_local_browsers | ||
- ivy_snapshot_test_cronjob | ||
- mdc_snapshot_test_cronjob | ||
triggers: | ||
- schedule: | ||
cron: "0 * * * *" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* Script that sets up the MDC snapshot github builds. We set up the snapshot builds by | ||
* overwriting the versions in the "package.json" and taking advantage of Yarn's resolutions | ||
* feature. Yarn resolutions will be used to overwrite nested MDC package versions. | ||
* | ||
* node_modules/@material/toolbar@snapshot | ||
* node_modules/material-components-web@latest | ||
* node_modules/@material/toolbar@snapshot | ||
*/ | ||
|
||
const {yellow, green} = require('chalk'); | ||
const {writeFileSync, existsSync} = require('fs'); | ||
const {join} = require('path'); | ||
const globSync = require('glob').sync; | ||
|
||
const args = process.argv.slice(2); | ||
const [mdcPackagesPath, uniqueId] = args; | ||
const projectDir = join(__dirname, '../../'); | ||
const packageJsonPath = join(projectDir, 'package.json'); | ||
const packageJson = require(packageJsonPath); | ||
|
||
if (!mdcPackagesPath || !uniqueId) { | ||
throw Error('Usage: node ./scripts/setup-mdc-snapshots.js <mdcPackagesPath> <uniqueId>'); | ||
} | ||
|
||
// Initialize the "resolutions" property in case it is not present in the "package.json" yet. | ||
// See: https://yarnpkg.com/lang/en/docs/package-json/#toc-resolutions for the API. | ||
packageJson['resolutions'] = packageJson['resolutions'] || {}; | ||
|
||
const mdcPackages = globSync('./*/', {cwd: mdcPackagesPath, absolute: true}); | ||
|
||
for (let packagePath of mdcPackages) { | ||
const pkgJsonPath = join(packagePath, 'package.json'); | ||
|
||
if (!existsSync(pkgJsonPath)) { | ||
continue; | ||
} | ||
|
||
const packageName = require(pkgJsonPath).name; | ||
const newPackageVersion = `file:${packagePath}`; | ||
|
||
// Add resolutions for each package in the format "**/{PACKAGE}" so that all | ||
// nested versions of that specific MDC package will have the same version. | ||
packageJson.resolutions[`**/${packageName}`] = newPackageVersion; | ||
|
||
// Since the resolutions only cover the version of all nested installs, we also need | ||
// to explicitly set the version for the package listed in the project "package.json". | ||
packageJson.dependencies[packageName] = newPackageVersion; | ||
|
||
// In case this dependency was previously a dev dependency, just remove it because we | ||
// re-added it as a normal dependency for simplicity. | ||
delete packageJson.devDependencies[packageName]; | ||
} | ||
|
||
// Update the version field in the "package.json" to a new version that contains | ||
// the specified unique id. We need to ensure that the "package.json" is different | ||
// if something changes upstream in the MDC repository as Bazel otherwise incorrectly | ||
// re-uses results from previous builds. | ||
packageJson.version = `${packageJson.version}-${uniqueId}`; | ||
|
||
// Write changes to the "packageJson", so that we can install the new versions afterwards. | ||
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); | ||
|
||
console.log(green('Successfully added the "resolutions" to the "package.json".')); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found out on Friday that MDC's development HEAD is actually a branch called
develop
instead ofmaster
, so I believe we should test thatcc @abhiomkar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this document describes that
develop
includes breaking-changes. Though I'm not sure which one we want to pick. It looks like both do not really intersect. e.g. a non-breaking change is not merged into bothmaster
anddevelop
(based on my observation on the repo)