Commit Graph

84 Commits

Author SHA1 Message Date
Joey Perrott d3b0d1e3fb refactor(dev-infra): add spawnSync to child process utils, normalize naming of child-process utils (#42911)
Create a `spawnSync` command for common usage, additionally update naming to use `spawn` instead of
`spawnWithDebugOutput`

PR Close #42911
2021-07-21 22:33:37 +00:00
Andrew Kushnir c1c1cda866 Revert "refactor(dev-infra): add spawnSync to child process utils, normalize naming of child-process utils (#42394)" (#42829)
This reverts commit 08444c6679.

PR Close #42829
2021-07-12 15:24:55 -07:00
Andrew Kushnir 3d668162d9 Revert "refactor(dev-infra): remove usages and dependency on shelljs (#42394)" (#42829)
This reverts commit f0d857eff8.

PR Close #42829
2021-07-12 15:24:54 -07:00
Joey Perrott f0d857eff8 refactor(dev-infra): remove usages and dependency on shelljs (#42394)
Remove usages of shelljs and instead use spawn/spawnSync.

PR Close #42394
2021-07-12 14:39:08 -07:00
Joey Perrott 08444c6679 refactor(dev-infra): add spawnSync to child process utils, normalize naming of child-process utils (#42394)
Create a `spawnSync` command for common usage, additionally update naming to use `spawn` instead of
`spawnWithDebugOutput`

PR Close #42394
2021-07-12 14:39:07 -07:00
Paul Gschwendtner b5ab7aff43 refactor: add override keyword to members implementing abstract declarations (#42512)
In combination with the TS `noImplicitOverride` compatibility changes,
we also want to follow the best-practice of adding `override` to
members which are implemented as part of abstract classes. This
commit fixes all instances which will be flagged as part of the
custom `no-implicit-override-abstract` TSLint rule.

PR Close #42512
2021-07-12 13:11:17 -07:00
Paul Gschwendtner 762e057e85 build: update to rules_nodejs v4.0.0-beta.0 (#42760)
Updates the Bazel NodeJS rules to v4.0.0-beta.0. This is necessary
so that the Angular components repo can update, and it's generally
good to stay as up-to-date as possible with the Bazel rules as it's
easy to fall behind, and updating early allows us to discover issues
affecting our tooling earlier (where they are easier to address due to
e.g. potential breaking change policy).

PR Close #42760
2021-07-09 14:50:15 -07:00
Paul Gschwendtner f29fe5ced0 fix(dev-infra): use API pagination for retrieving project branches (#42666)
We rely on a Github API `/branches` request to determine the active
release trains. Currently this logic is broken if more than 100
protected branches exist within a repository. This issue surfaced
recently where the `items_per_page` setting was set to `30`, causing
the merge tooling and release tooling to not detect the proper "latest"
release train.

This commit uses Github pagination for retrieving branches to determine
the active release trains, and makes the logic more long-term proof.

PR Close #42666
2021-06-29 10:33:54 -07:00
Paul Gschwendtner 279e63f65f refactor(dev-infra): update octokit to latest version v18 (#42666)
We previously held off with updating Octokit to v18 due to
their more noticable issues with typings. This commit updates
us to the latest version in order to take advantage of the new
pagination API (which is also strongly-typed), and to not fall
behind too much over time (Octokit seems to change quite often..)

We work around the problem with the types for `getContent` by just
using a type cast with a TODO (and link to the issue). Similarly we
work around a problem where the Octokit types have an incorrect type
for the name of the labels array in an API response.

PR Close #42666
2021-06-29 10:33:54 -07:00
Paul Gschwendtner 67f65a9d25 refactor(dev-infra): improve type-safety of git client utility (#42468)
Currently the `GitClient` accepts a generic parameter for determining
whether the `githubToken` should be set or not. This worked fine so far
in terms of distinguishing between an authenticated and
non-authenticated git client instance, but if we intend to conditionally
show methods only for authenticated instances, the generic parameter
is not suitable.

This commit splits up the `GitClient` into two classes. One for
the base logic without any authorization, and a second class that
extends the base logic with authentication logic. i.e. the
`AuthenticatedGitClient`. This allows us to have specific methods only
for the authenticated instance. e.g.

  * `hasOauthScopes` has been moved to only exist for authenticated
    instances.
  * the GraphQL functionality within `gitClient.github` is not
    accessible for non-authenticated instances. GraphQL API requires
    authentication as per Github.

The initial motiviation for this was that we want to throw if
`hasOAuthScopes` is called without the Octokit instance having
a token configured. This should help avoiding issues as within
3b434ed94d
that prevented the caretaker process momentarily.

Additionally, the Git client has moved from `index.ts` to
`git-client.ts` for better discoverability in the codebase.

PR Close #42468
2021-06-03 14:34:33 -07:00
Paul Gschwendtner fa84d19e97 refactor(dev-infra): always use en-US locale for printing date in merge tool (#42470)
In the dev-infra merge tool, a test fails locally if it runs on
a system with a different system locale. We can either make the
test more flexible, or update the merge tool to always print the date
in `en-US` format. The latter is more reasonable given our console
messages being in english anyway.

PR Close #42470
2021-06-03 13:19:03 -07:00
Paul Gschwendtner 49c3ce58bf refactor(dev-infra): remove duplicate method that checks for uncommitted changes (#42409)
Removes the duplicate `hasLocalChanges` method from the Git client. We
already have `hasUncommittedChanges`. Also removes a TODO for adding
`assertNoLocalChanges` as it seems more flexible to manually check
(i.e. better messaging with context on the current tool; e.g. "cannot
perform rebase")

PR Close #42409
2021-06-03 10:36:40 -07:00
Paul Gschwendtner 97c5a3ae6f feat(dev-infra): prevent deprecations from being merged into patch branch (#42454)
As per SemVer, deprecations should only be released if the
minor version is incremented. This means that we should error
if commits w/ deprecations target an upcoming patch, LTS release.

Additionally, we also error if deprecations are made as part of
an upcoming release-candidate.

PR Close #42454
2021-06-02 13:23:54 -07:00
Paul Gschwendtner 107f15df03 refactor(dev-infra): add JSDoc throws description to assertion functions (#42454)
Adds the JSDoc `@throws` annotation to functions that would throw
within in the ng-dev tool. We want to add `@throws` so clearly
communicate if the invocation of a function results in errors or not.

This helps if IDEs show the `@throws` annotation on invocation, or
if TS ever lands a feature like Java `throws`, with more fine-grained
and typed error handling.

PR Close #42454
2021-06-02 13:23:54 -07:00
Joey Perrott aeb407296b refactor(dev-infra): update to later version of @octokit/rest and remove class extenstion of Octokit (#42395)
Update @octokit/rest and remove the usage of a class extension of Octokit as the
class does not have a class define constructor.

PR Close #42395
2021-06-01 10:14:48 -07:00
Paul Gschwendtner 2843f15e8c fix(dev-infra): merge tool should ensure that token has `workflow` oauth scope (#41989)
Currently if a PR modifies any file that configures a Github action
(e.g. a workflow file), the caretaker might face an error when merging
such PR:

```
! [remote rejected]       merge_pr_target_11.2.x -> 11.2.x (refusing to allow a Personal Access Token to create or update workflow
```

This happens because Github requires the token being used for the
push operation to have the `workflow` scope set. This is a special
scope added by Github to ensure that no changes can be made on
upstream branches that might expose the `GITHUB_TOKEN` environment
variable, which is available for push builds and could cause the
token being leaked.

With this commit we enforce that the caretaker adds the workflow
scope to their github token. Since PRs can only be merged if reviewed
thoroughly, it's acceptable to allow workflow file changes being
merged through the merge tool by the caretaker (especially since we
also allow CircleCI config files being merged with the default
`repo`/`public_repo` scope).

PR Close #41989
2021-05-07 14:10:39 -04:00
Joey Perrott 393ce94718 feat(dev-infra): Set up new common release notes generation tooling (#41905)
Enables the new common release notes generation within the ng-dev release publishing
tooling.

PR Close #41905
2021-05-06 09:40:29 -04:00
Joey Perrott b1ae31c712 fix(dev-infra): add github token requirement for discover-new-conflicts (#41825)
Add the github token option/requirement for the pr discover-new-conflicts
command.

PR Close #41825
2021-04-27 10:23:16 -07:00
George Kalpakas 8058396c52 docs(dev-infra): update jsdoc comments to reflect recent code changes (#41688)
PR Close #41688
2021-04-19 08:28:34 -07:00
Joey Perrott 83d6a96163 feat(dev-infra): prevent pr merges of features or breaking changes on rc (#41660)
Prevent pull requests targeting `target: rc` from merging PRs with breaking
changes or features from being merged.

PR Close #41660
2021-04-16 13:09:47 -07:00
Joey Perrott dd4c3dba3f refactor(dev-infra): move `getRepoBaseDir()` to `GitClient` (#41527)
As `getRepoBaseDir()` relies on git, it should be a method on `GitClient` for retrieval
rather than its own utility outside of the common GitClient used for all git ineractions.

PR Close #41527
2021-04-15 11:28:12 -07:00
Joey Perrott a63cf7221b feat(dev-infra): prevent attempting to merge draft, closed or merged pull requests (#41604)
During pull request validation, assert that the pull request is not in
draft mode, already merged or already closed.

PR Close #41604
2021-04-14 15:44:55 -07:00
Alan Agius ed7d288364 build: update several dependencies (#41434)
With this change we update several dependencies to avoid Renovate creating a lot of PRs during onboarding. We also remove yarn workspaces as after further analysis these are not needed.

Certain dependencies such as `@octokit/rest`, `remark` and `@babel/*` have not been updated as they require a decent amount of work to update, and it's best to leave them for a seperate PR.

PR Close #41434
2021-04-12 16:46:29 -07:00
Joey Perrott 9bf8e5164d refactor(dev-infra): use a singleton for GitClient (#41515)
Creates a singleton class for GitClient rather than relying on creating an instance to
require being passed around throughout its usages.

PR Close #41515
2021-04-12 16:43:54 -07:00
Joey Perrott 4a69a7b952 feat(dev-infra): verify breaking changes are properly labeled before merging (#41546)
During merging with `ng-dev pr merge` tooling will ensure that pull requests are
properly labeled for breaking changes.  Pull requests with commits noting breaking
changes must also be labeled as such, additionally pull requests with breaking
change labels must contain commits noting breaking changes.

Fixes #38776

PR Close #41546
2021-04-12 10:11:17 -07:00
Joey Perrott 7a40d8cefd fix(dev-infra): use base ref name rather than sha for the githubTargetBranch (#41523)
After updating to use the v4 graphql api in the merge tooling, the githubTargetBranch
was set to be the sha of the latest commit rather than the branch name of the target
branch.  This caused our tooling to mismatch which branches were actually being targeted
with the effect that if a PR targeted only the patch branch (i.e. labeled `target: patch`
and targeting `11.2.x` in github)it would still expect to merge into both `11.2.x` and
`master`.  This is now corrected to once again use the branch name, restoring to the
previous functionality.

PR Close #41523
2021-04-08 15:18:02 -07:00
Joey Perrott c7d86bca21 feat(dev-infra): add support for `targetLabelExemptScopes` for merging (#41459)
Add a property, `targetLabelExemptScopes`, to the merge configuration allowing certain
scopes to be exempted from requirements for features and breaking changes only included
in PRs targetting certain labels.

PR Close #41459
2021-04-07 11:52:35 -07:00
Joey Perrott 7dba0711c2 feat(dev-infra): prevent merges for PRs with invalid breaking changes or commit types (#41459)
Check commits in pull requests to ensure the pr can be merged into the target branch. Confirms
that prs targeting minor do not contain breaking changes, and prs targeting patch or lts do not
contain breaking changes or `feat` commits.

PR Close #41459
2021-04-07 11:52:35 -07:00
Joey Perrott 2d3539f4df refactor(dev-infra): use graphql to query PRs in merge tooling (#41459)
Migrate to use graqhql to query for PR information during the validation and
preperation portions of the pr merge tooling.

PR Close #41459
2021-04-07 11:52:35 -07:00
Joey Perrott 381ea9d7d4 refactor(dev-infra): set up new method for checking range of commits (#41341)
Check a range of commits by retrieving the log files to be parsed with the expected
format for the parser.

This change is in part of a larger set of changes making the process for obtaining
and parsing commits for release note creation and message validation consistent.
This consistency will make it easier to debug as well as ease the design of tooling
which is built on top of these processes.

PR Close #41341
2021-04-01 11:30:26 -07:00
Joey Perrott 0516fbb180 refactor(dev-infra): use conventional-commits-parser for commit parsing (#41286)
Use conventional-commits-parser for parsing commits for validation, this is being done
in anticipation of relying on this parser for release note creation.  Unifying how commits
are parsed will provide the most consistency in our tooling.

PR Close #41286
2021-03-23 13:10:47 -07:00
Joey Perrott 2980d85b8c feat(dev-infra): support --no-branch-prompt to suppress the merge tool branch target confirmation (#40528)
Add support for a `--no-branch-prompt` flag for the `ng-dev pr merge` tool.  This
flag enables suppression of the confirmation prompt for which branches the specified
PR will merge into.

PR Close #40528
2021-01-25 10:45:57 -08:00
Joey Perrott 3d7e207a25 fix(dev-infra): detect multiple target labels as invalid (#40156)
When multiple target labels are applied to a PR, it should be considered
invalid as our tooling does not support a single PR targetting multiple
trains/versions.

PR Close #40156
2021-01-11 09:56:22 -08:00
Joey Perrott 634c393d35 fix(dev-infra): correct the environment variable to skip husky during merge (#40025)
With the migration to husky@5, the environment variable used to skip husky changed from
`HUSKY_SKIP_HOOKS` to `HUSKY`.  To continue skipping husky during the merge process as
expected, the environment variable used is updated.

PR Close #40025
2020-12-08 16:16:43 -08:00
Joey Perrott 25e3dc594d refactor(dev-infra): separate retrieving targeted branches from printing them (#39897)
Separate retrieving targeted branches from printing the branches to allow for
other tools to better integrate with the results.

PR Close #39897
2020-12-08 08:54:08 -08:00
Joey Perrott d9356f2842 feat(dev-infra): close pull requests on merge which do not target master branch (#39979)
Previously, when a PR which does not target the master branch in the Github UI was
merged it would not close automatically.  This change detects when this case occurs
and closes the PR via the Github API.

For example:

  A PR which targets the 11.0.x branch in the Github UI has the `target: patch` label

This PR is only pushed into the 11.0.x branch, which does not trigger Github's
reference based actions to close the PR.

PR Close #39979
2020-12-07 09:47:30 -08:00
Joey Perrott b1ebfb1cab feat(dev-infra): support squashing fixups in the `ng-dev pr rebase` command (#39747)
Adding support for squashing fixup commits during when rebasing can allow
for rebasing to better unblock things like merging.

PR Close #39747
2020-11-20 12:49:43 -08:00
Joey Perrott d0dd0e80f6 feat(dev-infra): provide tooling to check what branches a pr targets (#39504)
Create a command in the `ng-dev` toolset that allows user's to check
what branches a PR will merge into based on its targeting.

PR Close #39504
2020-11-03 14:55:24 -08:00
Joey Perrott be64f98076 fix(dev-infra): run fetches in the git client in quiet mode (#39503)
When fetch is run in normal mode, the `git-fetch-pack` plumbing command
outputs progress to stderr.  Since this is unnecessary progress
information for ng-dev usages, it should be suppressed instead.

PR Close #39503
2020-11-02 16:41:47 -08:00
Joey Perrott d331e09b71 refactor(dev-infra): create ng-dev executable locally in the repo (#39089)
Rather than running ng-dev via ts-node, going forward ng-dev is generated and run
locally via node.  Additionally, the generated file is tested on each commit to
ensure that the local generated version stays up to date.

PR Close #39089
2020-10-22 13:36:14 -07:00
Joey Perrott 767fdccf59 feat(dev-infra): prompt caretaker to confirm the merge branches on merge (#39333)
Perviously, it was not immediately clear what branches a PR would merge
into during the merge process.  This prompt allows for caretakers to
understand and acknowledge where the PR will merge to.

PR Close #39333
2020-10-19 12:06:16 -07:00
George Kalpakas 6947ceaf44 refactor(dev-infra): several code style and typo fixes (#39135)
This commit addresses comments from [my review][1] on PR #38656 (which
was merged without comments addressed). The changes are mostly related
to code style and typos.

[1]: https://github.com/angular/angular/pull/38656#pullrequestreview-482129333

PR Close #39135
2020-10-12 10:47:13 -07:00
Greg Magolan 42a164f522 build: upgrade angular build, integration/bazel and @angular/bazel package to rule_nodejs 2.2.0 (#39182)
Updates to rules_nodejs 2.2.0. This is the first major release in 7 months and includes a number of features as well
as breaking changes.

Release notes: https://github.com/bazelbuild/rules_nodejs/releases/tag/2.0.0

Features of note for angular/angular:

* stdout/stderr/exit code capture; this could be potentially be useful

* TypeScript (ts_project); a simpler tsc rule that ts_library that can be used in the repo where ts_library is too
  heavy weight

Breaking changes of note for angular/angular:

* loading custom rules from npm packages: `ts_library` is no longer loaded from `@npm_bazel_typescript//:index.bzl`
  (which no longer exists) but is now loaded from `@npm//@bazel/typescript:index.bzl`

* with the loading changes above, `load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")` is
  no longer needed in the WORKSPACE which also means that yarn_install does not need to run unless building/testing
  a target that depends on @npm. In angular/angular this is a minor improvement as almost everything depends on @npm.

* @angular/bazel package is also updated in this PR to support the new load location; Angular + Bazel users that
  require it for ng_package (ng_module is no longer needed in OSS with Angular 10) will need to load from
  `@npm//@angular/bazel:index.bzl`. I investigated if it was possible to maintain backward compatability for the old
  load location `@npm_angular_bazel` but it is not since the package itself needs to be updated to load from
  `@npm//@bazel/typescript:index.bzl` instead of `@npm_bazel_typescript//:index.bzl` as it depends on ts_library
  internals for ng_module.

* runfiles.resolve will now throw instead of returning undefined to match behavior of node require

Other changes in angular/angular:

* integration/bazel has been updated to use both ng_module and ts_libary with use_angular_plugin=true.
  The latter is the recommended way for rules_nodejs users to compile Angular 10 with Ivy. Bazel + Angular ViewEngine is
  supported with @angular/bazel <= 9.0.5 and Angular <= 8. There is still Angular ViewEngine example on rules_nodejs
  https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular_view_engine on these older versions but users
  that want to update to Angular 10 and are on Bazel must switch to Ivy and at that point ts_library with
  use_angular_plugin=true is more performant that ng_module. Angular example in rules_nodejs is configured this way
  as well: https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular. As an aside, we also have an
  example of building Angular 10 with architect() rule directly instead of using ts_library with angular plugin:
  https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular_bazel_architect.

NB: ng_module is still required for angular/angular repository as it still builds ViewEngine & @angular/bazel
also provides the ng_package rule. ng_module can be removed in the future if ViewEngine is no longer needed in
angular repo.

* JSModuleInfo provider added to ng_module. this is for forward compat for future rules_nodejs versions.

PR Close #39182
2020-10-08 11:54:59 -07:00
Joey Perrott c214cad2b4 Revert "build: upgrade angular build, integration/bazel and @angular/bazel package to rule_nodejs 2.2.0 (#37727)" (#39097)
This reverts commit db56cf18ba.

PR Close #39097
2020-10-02 10:56:53 -07:00
Greg Magolan db56cf18ba build: upgrade angular build, integration/bazel and @angular/bazel package to rule_nodejs 2.2.0 (#37727)
Updates to rules_nodejs 2.2.0. This is the first major release in 7 months and includes a number of features as well
as breaking changes.

Release notes: https://github.com/bazelbuild/rules_nodejs/releases/tag/2.0.0

Features of note for angular/angular:

* stdout/stderr/exit code capture; this could be potentially be useful

* TypeScript (ts_project); a simpler tsc rule that ts_library that can be used in the repo where ts_library is too
  heavy weight

Breaking changes of note for angular/angular:

* loading custom rules from npm packages: `ts_library` is no longer loaded from `@npm_bazel_typescript//:index.bzl`
  (which no longer exists) but is now loaded from `@npm//@bazel/typescript:index.bzl`

* with the loading changes above, `load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")` is
  no longer needed in the WORKSPACE which also means that yarn_install does not need to run unless building/testing
  a target that depends on @npm. In angular/angular this is a minor improvement as almost everything depends on @npm.

* @angular/bazel package is also updated in this PR to support the new load location; Angular + Bazel users that
  require it for ng_package (ng_module is no longer needed in OSS with Angular 10) will need to load from
  `@npm//@angular/bazel:index.bzl`. I investigated if it was possible to maintain backward compatability for the old
  load location `@npm_angular_bazel` but it is not since the package itself needs to be updated to load from
  `@npm//@bazel/typescript:index.bzl` instead of `@npm_bazel_typescript//:index.bzl` as it depends on ts_library
  internals for ng_module.

* runfiles.resolve will now throw instead of returning undefined to match behavior of node require

Other changes in angular/angular:

* integration/bazel has been updated to use both ng_module and ts_libary with use_angular_plugin=true.
  The latter is the recommended way for rules_nodejs users to compile Angular 10 with Ivy. Bazel + Angular ViewEngine is
  supported with @angular/bazel <= 9.0.5 and Angular <= 8. There is still Angular ViewEngine example on rules_nodejs
  https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular_view_engine on these older versions but users
  that want to update to Angular 10 and are on Bazel must switch to Ivy and at that point ts_library with
  use_angular_plugin=true is more performant that ng_module. Angular example in rules_nodejs is configured this way
  as well: https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular. As an aside, we also have an
  example of building Angular 10 with architect() rule directly instead of using ts_library with angular plugin:
  https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/angular_bazel_architect.

NB: ng_module is still required for angular/angular repository as it still builds ViewEngine & @angular/bazel
also provides the ng_package rule. ng_module can be removed in the future if ViewEngine is no longer needed in
angular repo.

* JSModuleInfo provider added to ng_module. this is for forward compat for future rules_nodejs versions.
  @josephperrott, this touches `packages/bazel/src/external.bzl` which will make the sync to g3 non-trivial.

PR Close #37727
2020-10-01 15:34:36 -07:00
Joey Perrott c8d757624b refactor(dev-infra): use common git client for git environment reset (#39051)
For rebase tooling, use the `GitClient`'s `checkout` method rather than a custom
function doing the same task.

PR Close #39051
2020-09-30 09:36:01 -04:00
Paul Gschwendtner 9dccaa9570 refactor(dev-infra): move common versioning tooling to shared location (#38656)
We initially added logic for determining active release trains into
the merge script. Given we now build more tools that rely on this
information, we move the logic into a more general "versioning" folder
that can contain common logic following the versioning document for the
Angular organization.

PR Close #38656
2020-09-28 16:11:40 -04:00
Paul Gschwendtner c1b47bcfaa refactor(dev-infra): expose logic for dealing with LTS branches (#38656)
Exposes logic for dealing with LTS branches, so that the release
tool can re-use it for cutting LTS patch releases.

Eventually, we can move all of this logic to a more dedicated
folder instead of having it inside the merge folder.

PR Close #38656
2020-09-28 16:11:40 -04:00
Paul Gschwendtner d7ff8d765c refactor(dev-infra): use shared github repo interface (#38656)
Instead of maintaining multiple interface for grouping
owner name and repo name, we expose a shared interface
describing a Github repository.

One unfortunate downside is that the GraphQL Github
and Rest API diverge slightly with the key for the
repository name. i.e. rest uses `repo` for the name
of a repository, while GraphQL uses `name` for the name.

If that would be consistent, we could use the rest operator
to pass a repository to the Octokit REST or GraphQL API. This
does not work, so we have a small manual overhead as seen
in the `branches.ts` file.

PR Close #38656
2020-09-28 16:11:40 -04:00
Paul Gschwendtner b041c118e3 refactor(dev-infra): expose version for determined release trains (#38656)
Previously, the logic for determing the active release trains did not
return the resolved version of a release train. With the publish script
being created, we need this information and can just pass it through,
so that we do not need to fetch and parse the package.json of given
branches multiple times.

PR Close #38656
2020-09-28 16:11:39 -04:00