Commit Graph

41 Commits

Author SHA1 Message Date
George Kalpakas a01acec7fe fix(docs-infra): use correct parameters for paginated requests to GitHub (#25671)
As it turns out, in GitHub API paginated requests, page numbering is
1-based. (https://developer.github.com/v3/#pagination)

Starting at page 0 (which returns the first page), results in making the
same request twice and logging incorrect numbers (since the first 100
items are listed twice).

PR Close #25671
2018-09-26 15:26:19 -07:00
George Kalpakas 021f4344b1 fix(docs-infra): fix preview server periodic clean-up (#25671)
Includes the following fixes:

- Fix cron entry format for clean-up script.
  Crontabs in `/etc` should not have a user field. No idea why it used
  to work before, but it started giving errors recently:
  `/bin/sh: root: not found`.

- Set required env variable in clean-up script. (Broken in cc6f36a9d.)
  This was producing the following error:
  `ERROR: Missing required environment variable 'AIO_CIRCLE_CI_TOKEN'!`

- Use the correct path for downloads to be removed. (Broken in cc6f36a9d.)

PR Close #25671
2018-09-26 15:26:19 -07:00
George Kalpakas f113b49909 test(docs-infra): remove unnecessary test helpers (#25671)
`supertest.Request` extends `Promise` and can be used directly without
"promisifying".

PR Close #25671
2018-09-26 15:26:19 -07:00
George Kalpakas 6d6b0ff1ad feat(docs-infra): add API endpoint for checking if PR can have preview (#25671)
There several reasons why PRs cannot have (public) previews:
- The PR did not affect any relevant files (e.g. non-spec files in
  `aio/` or `packages/`).
- The PR cannot be automatically verified as "trusted" (based on its
  author or labels).

Note:
The endpoint does not check whether there currently is a (public)
preview for the specified PR; only whether there can be one.

PR Close #25671
2018-09-26 15:26:19 -07:00
George Kalpakas f378454c92 fix(docs-infra): correctly check PR files on preview server (#25671)
According to the docs, the response of GitHub's [PR files API][1]
_"includes a maximum of 300 files"_. This means that if a PR contains
more files, it is possible that not all files are retrieved (which
could, for example, give a false negative for the "significant files
touched" check - not likely but possible).

This commit fixes it by using paginated requests to retrieve all changed
files.

[1]: https://developer.github.com/v3/pulls/#list-pull-requests-files

PR Close #25671
2018-09-26 15:26:19 -07:00
George Kalpakas c8c8436e58 test(docs-infra): fix test for preview server's `GithubPullRequests` (#25671)
PR Close #25671
2018-09-26 15:26:19 -07:00
George Kalpakas b31c8b6063 test(docs-infra): fix test for preview server's `BuildCleaner` completing prematurely (#25671)
PR Close #25671
2018-09-26 15:26:19 -07:00
George Kalpakas 897261efdc test(docs-infra): fix preview server unit tests on Windows (#25671)
Some tests where comparing actual with expected paths, without taking
into account that paths will be different on Windows.

This commit uses `path.resolve()` to convert expected paths to their
OS-specific form.

PR Close #25671
2018-09-26 15:26:19 -07:00
George Kalpakas fc0a7959a4 refactor(docs-infra): use mockable logger (#25671)
Related discussion:
https://github.com/angular/angular/pull/23576#discussion_r187925949.

PR Close #25671
2018-09-26 15:26:19 -07:00
George Kalpakas e2bc0ad6c2 build(docs-infra): upgrade preview server dependencies (#25671)
PR Close #25671
2018-09-26 15:26:19 -07:00
Pete Bacon Darwin 68bfe686d8 ci(docs-infra): rename 'upload-server' to 'preview-server'
The server no longer has files uploaded to it. Instead it is more
accurate to refer to it as dealing with "previews" of PRs.
2018-08-16 10:26:13 +01:00
Pete Bacon Darwin 36c4c8daa9 ci(docs-infra): improve preview-server logging 2018-08-16 10:26:13 +01:00
Pete Bacon Darwin cc6f36a9d7 ci(docs-infra): change AIO preview server stuff to pull builds from CircleCI
Previously, Travis pushed the build artitfacts to the preview server.
This required us to use JWT to secure the POST request from Travis, to
ensure we couldn't receive malicious builds.

JWT has been deprecated and we are moving our builds to CircleCI.

This commit rewrites the TypeScript part of the preview server that
handles converting build artifact into hosted previews of the docs.
2018-08-16 10:26:13 +01:00
George Kalpakas 620407720c build(aio): upgrade all preview server dependencies 2017-09-25 12:01:22 -07:00
Georgios Kalpakas 06faac8b5c fix(aio): skip PWA test when redeploying non-public commit 2017-08-10 15:59:00 -07:00
Georgios Kalpakas 20556346a3 feat(aio): add API endpoint for notifying about PR updates
This commit adds an API endpoint for notifying the preview server about PR
updates (`/pr-updated`). According to the update, the preview server can take
several actions. Currently, it will only check and (if necessary) update the
PR's preview visibility (but more actions could be supported in the future).
The API can be used with an automatic trigger (e.g. a GitHub webhook) to
instantly update a PR's preview visibility when it changes.

Fixes #16526
2017-07-10 12:30:45 +01:00
Georgios Kalpakas 5a417b8514 feat(aio): implement a way to check and update a PR\'s preview visibility
Previously, `BuildCreator#changePrVisibility()` would throw an error if the PR's
visibility was already up-to-date or if the PR directory did not exist (e.g. was
removed). This method was only used from inside `BuildCreator#create()`, which
had already checked for the existence of the directories.

This commit renames `changePrVisibility()` to `updatePrVisibility()` and makes
it more "forgiving" (i.e. it will only throw if both public and non-public
directories exist). This allows it to be used on events that may or may not have
caused the PR's visibility to change (e.g. a GitHub webhook triggered whenever a
PR's labels change).
2017-07-10 12:30:45 +01:00
Georgios Kalpakas 8cfc2e2ec0 refactor(aio): unify error messages for invalid requests to upload-server
Previously, there was a distinction between GET requests to invalid URLs and all
other requests. This was mainly because the upload-server only accepts GET
requests, but that is not a hard limitation and may change in the future.

Thus, it makes sense to return a 404 response for requests to invalid URLs
regardless of the method used.
2017-07-10 12:30:45 +01:00
Georgios Kalpakas 4268c82898 feat(aio): use shorter URLs for previews
Use the 7 first characters of the 40-chars long SHAs for shorter/cleaner URLs.
The collision probability is extremely low (since all SHAs are further
"namespaced" under the corresponding PR). In case of a collision, the second PR
will not be deployed, in order to avoid overwriting the original build.

(This is a design decision to keep the implementation simple. It can be changed
later if necessary.)
2017-06-29 09:35:22 -07:00
Georgios Kalpakas 3c4eef99be fix(aio): clean up non-public previews
The previous clean-up code for PR directories on the preview server assumed that
all directories were named after the PR number. With the changes introduced
in #17640 it is possible to have PR directories that do not follow that naming
convention (e.g. "non-public" directories).

This PR ensures that both public and non-public directories are removed when
cleaning up.
2017-06-29 09:35:22 -07:00
Georgios Kalpakas 8ae0eec230 feat(aio): enable previews for any PR
This commit introduces the ability to show previews for PRs by any author. It works as follows:

- The build artifacts of all PRs are uploaded to the preview server.
- Automatically verified PRs (i.e. from trusted authors or having a specific label) are deployed and
  publicly accessible as usual.
- PRs that could not be automatically verified are stored for later use (after re-verification).
- A PR can be marked as "trusted" and make its preview publicly accessible by adding the GitHub
  label specified in the `AIO_TRUSTED_PR_LABEL` env var of the preview server.

At the moment, there is no automatic mechanism for notifying the preview server about changes to the
PR's verification status. The PR's "visibility" will be checked and updated every time a new build
is uploaded.
2017-06-23 11:54:20 -07:00
Georgios Kalpakas 0fe685102f refactor(aio): simplify preview server build events 2017-06-23 11:54:20 -07:00
Georgios Kalpakas a98440bb85 test(aio): add missing unit test for preview server 2017-06-23 11:54:20 -07:00
Georgios Kalpakas 3112311134 test(aio): fix preview server tests on Windows 2017-06-23 11:54:20 -07:00
Georgios Kalpakas 1b13bdea4b build(aio): upgrade preview server dependencies 2017-06-23 11:54:20 -07:00
George Kalpakas 14b7dfa007 fix(aio): create a proper commit link on preview comments (#15941)
Previously, only a few characters of the SHA would appear on the preview link
comment posted on the PR. This was usually enough for GitHub to create a link to
the corresponding commit, but it was possible to have collisions with other
commits with the same first characters (which prevented GitHub from identifying
the correct commit and create a link.)

This commit fixes this issue by including the full SHA on the commentso GitHub
can identify the correct commit and create the link. GitHub will automatically
truncate the link text (by default to 7 chars unless more are necessary to
uniquely identify the commit).
2017-04-13 11:55:33 -07:00
Georgios Kalpakas d263595c63 ci(aio): do not fail when re-deploying preview for the same PR/SHA
Previously, when trying to upload the build artifacts for a PR/SHA that was
already successfully deployed (e.g. when re-running a Travis job), the preview
server would return a 403 and the build would fail.

Since we have other mechanisms to verify that the PR author is trusted and the
artifacts do indeed come from the specified PR and since the new artifacts
should be the same with the already deployed ones (same SHA), there is no reason
to fail the build. The preview server will reject the request with a special
HTTP status code (409 - Conflict), which the `deploy-preview` script will
recognize and exit with 0.
2017-04-13 11:26:21 +01:00
Georgios Kalpakas 0c5f893f6e test(aio): improve test description and expectations 2017-03-13 10:30:49 -07:00
George Kalpakas fa1920a02b feat(aio): enable deep-linking on deployed apps (until prerendering is done) (#15049) 2017-03-13 09:35:16 -07:00
Georgios Kalpakas 174d4c8ef7 ci(aio): do not deploy PR if preconditions not met
This avoids incorrectly failing the build if the PR author is not a member of one of the whitelisted GitHub teams.
2017-03-07 18:24:45 -08:00
Georgios Kalpakas 03a5fd01c9 fix(aio): do not hardcode the domain in preview link comments 2017-03-07 18:24:45 -08:00
Georgios Kalpakas 0e9277b4c3 style(aio): change mock value for consistency 2017-03-07 18:24:45 -08:00
Georgios Kalpakas 2796790c7d feat(aio): verify uploaded builds based on JWT from Travis 2017-03-07 18:24:45 -08:00
Georgios Kalpakas 3ed1f64d43 feat(aio): implement `BuildVerifier` 2017-03-07 18:24:45 -08:00
Georgios Kalpakas 96f11dad18 feat(aio): implement `GithubTeams` 2017-03-07 18:24:45 -08:00
Georgios Kalpakas 060d02eb82 fix(aio): remove unnecessary `repoSlug` parameter from `GithubApi` 2017-03-07 18:24:45 -08:00
Georgios Kalpakas 951e653b0c feat(aio): implement `GithubApi.getPaginated()` 2017-03-07 18:24:45 -08:00
Georgios Kalpakas 37348989f0 feat(aio): make `githubToken` mandatory for `GithubApi` 2017-03-07 18:24:45 -08:00
Georgios Kalpakas c5644e5a0d refactor(aio): add `assertNotMissingOrEmpty()` helper 2017-03-07 18:24:45 -08:00
Georgios Kalpakas 8a8d4fe24f test(aio): fix typos (repoSlag --> repoSlug) 2017-03-07 18:24:45 -08:00
Georgios Kalpakas 115164033b ci(aio): add initial implementation for aio-builds setup 2017-03-07 18:24:45 -08:00