| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
This document describes how to set up your development environment to build and test Angular. It also explains the basic mechanics of using git, node, and yarn.
See the contribution guidelines if you'd like to contribute to Angular.
Before you can build and test Angular, you must install and configure the following products on your development machine:
Git and/or the GitHub app (for Mac or Windows); GitHub's Guide to Installing Git is a good source of information.
Node.js, (version specified in the engines field of package.json) which is used to run a development web server, run tests, and generate distributable files.
Yarn (version specified in the engines field of package.json) which is used to install dependencies.
Java Development Kit which is used to execute the selenium standalone server for e2e testing.
Fork and clone the Angular repository:
# Clone your GitHub repository:
git clone git@github.com:<github username>/angular.git
# Go to the Angular directory:
cd angular
# Add the main Angular repository as an upstream remote to your repository:
git remote add upstream https://github.com/angular/angular.gitNext, install the JavaScript modules needed to build and test Angular:
# Install Angular project dependencies (package.json)
yarn installTo build Angular run:
node ./scripts/build-packages-dist.jsBazel is used as the primary tool for building and testing Angular. Building and testing is incremental with Bazel, and it's possible to only run tests for an individual package instead of for all packages. Read more about this in the BAZEL.md document.
You should execute all test suites before submitting a PR to GitHub:
Note: The first test run will be much slower than future runs. This is because future runs will benefit from Bazel's capability to do incremental builds.
All the tests are executed on our Continuous Integration infrastructure. PRs can only be merged if the code is formatted properly and all tests are passing.
Angular uses clang-format to format the source code. If the source code is not properly formatted, the CI will fail and the PR cannot be merged.
You can automatically format your code by running:
A better way is to set up your IDE to format the changed file on each file save.
let g:clang_format#command = '$ANGULAR_PATH/node_modules/.bin/clang-format'where $ANGULAR_PATH is an environment variable of the absolute path of your Angular directory.
You can check that your code is properly formatted and adheres to coding style by running:
$ yarn gulp lintWhen a build of any branch on the upstream fork angular/angular is green on CircleCI, it automatically publishes build artifacts to repositories in the Angular org, eg. the @angular/core package is published to https://github.com/angular/core-builds.
You may find that your un-merged change needs some validation from external participants. Rather than requiring them to pull your Pull Request and build Angular locally, they can depend on snapshots of the Angular packages created based on the code in the Pull Request.
Each CI run for a Pull Request stores the built Angular packages as build artifacts. The artifacts are not guaranteed to be available as a long-term distribution mechanism, but they are guaranteed to be available around the time of the build.
You can access the artifacts for a specific CI run by going to the workflow page, clicking on the publish_packages_as_artifacts job and then switching to the "Artifacts" tab. (If you happen to know the build number of the job, the URL will be something like: https://circleci.com/gh/angular/angular/<build-number>#artifacts)
On the "Artifacts" tab, there is a list of links to compressed archives for Angular packages. The archive names are of the format <package-name>-pr<pr-number>-<sha>.tgz (for example core-pr12345-a1b2c3d.tgz).
One can use the URL to the .tgz file for each package to install them as dependencies in a project they need to test the Pull Request changes against. Both npm and yarn support installing dependencies from URLs to .tgz files, for example by updating the dependencies in package.json to point to the artifact URLs and then running npm/yarn install:
"dependencies": {
"@angular/common": "https://<...>.circle-artifacts.com/0/angular/common-pr12345-a1b2c3d.tgz",
"@angular/core": "https://<...>.circle-artifacts.com/0/angular/core-pr12345-a1b2c3d.tgz",
"...": "..."
}In addition to the individual package archives, a .tgz file including all packages is also available (named all-pr<pr-number>-<sha>.tgz). This can be used if one prefers to download all packages locally and test them by either of the following ways:
Update the dependencies in package.json to point to the local uncompressed package directories.
Directly copy the local uncompressed package directories into the node_modules/ directory of a project.
Note that (while faster) the second approach has limitations. For example: a. Any transitive dependencies of the copied packages will not be automatically updated. b. The packages need to be copied over every time npm/yarn install is run. c. Some package managers (such as pnpm or yarn pnp) might not work correctly.
You can also manually publish *-builds snapshots just like our CircleCI build does for upstream builds. Before being able to publish the packages, you need to build them locally by running the ./scripts/build-packages-dist.js script.
First time, you need to create the GitHub repositories:
$ export TOKEN=[get one from https://github.com/settings/tokens]
$ CREATE_REPOS=1 ./scripts/ci/publish-build-artifacts.sh [GitHub username]For subsequent snapshots, just run:
$ ./scripts/ci/publish-build-artifacts.sh [GitHub username]The script will publish the build snapshot to a branch with the same name as your current branch, and create it if it doesn't exist.
It will automatically recognize *.bazel and *.bzl files.
Bazel builds in the Angular repository use a shared cache. When a build occurs a hash of the inputs is computed and checked against available outputs in the shared cache. If an output is found, it is used as the output for the build action rather than performing the build locally.
Remote Build Execution requires authentication as a google.com or angular.io account.
The --config=remote flag can be added to enable remote execution of builds. This flag can be added to the .bazelrc.user file using the script at scripts/local-dev/setup-rbe.sh.
| Back | FazBrowse Home | New Git URL |