Skip to content

ci(aio): change AIO preview server stuff to use CircleCI#23576

Merged
petebacondarwin merged 11 commits intoangular:masterfrom
petebacondarwin:aio-circleci-builds
Aug 16, 2018
Merged

ci(aio): change AIO preview server stuff to use CircleCI#23576
petebacondarwin merged 11 commits intoangular:masterfrom
petebacondarwin:aio-circleci-builds

Conversation

@petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented Apr 27, 2018

The system now waits for a CircleCI webhook to tell the upload server that a build has completed.
The upload server then pulls down the build artifact and passes it along as before to the rest of the preview creation logic.

This means that there is no need to store a secret on CircleCI for pushing the artifacts to the upload server; which means that we no longer rely upon JWT.

The downloaded artifact is stored in a temp location; this is cleared out along with the actual preview builds by the periodic cleanup task.

There are some (self-serving) changes to the testing of components that were not significantly changed for this PR. This includes more use of async/await for managing async tests; and also making some API public (rather than protected). This allows us to unit test, while maintaining type safety. Previously, we had to cast to any which meant that changes to the API may not be passed through to the unit tests.

TODO:

  • check for CI success before processing
  • consider not downloading an artifact if it has been downloaded already
  • fix up / write more e2e tests
  • update the docs
  • consider renaming "upload server" to "preview server"
  • configure the rest of the environment variables for the new processing
  • ascertain whether we need a CircleCI access token for making the GET requests
  • work out how (and when) to run the PWA-score test; probably by the preview-server triggering a specific CircleCI job via API

@petebacondarwin petebacondarwin added state: WIP area: build & ci Related the build and CI infrastructure of the project comp: aio labels Apr 27, 2018
@petebacondarwin petebacondarwin requested a review from gkalpak April 27, 2018 13:56
Copy link
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at a high level this looks good. I'll let @gkalpak take a more thorough look through all the changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we call this file with a more specific name? maybe aio-snapshot.tgz?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about aio/aio-snapshot.tgz?

@petebacondarwin petebacondarwin force-pushed the aio-circleci-builds branch 2 times, most recently from 439f2d1 to d50ffdc Compare May 9, 2018 17:43
Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Half-way through (mostly reviewed anything outside scripts-js/).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT, destination needs to be kept in sync with AIO_ARTIFACT_PATH in preview server's Dockerfile. It is a good idea to add a comment about that too 😁

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because we want to test failures where the artifact is too large. Rather than having to create an enormous file, I just set this a "bit" lower :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why set it a "bit" lower (for tests)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the question. I set it lower because in the tests we now actually create a mock file that is returned from the mock CircleCI API. To test that the max-size check is working we would have to create a mock file that is larger than 20971520 bytes. What is the point of that when we can just set the limit to something smaller?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not alphabetical order 😭

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we jump to v10 instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see if we can

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the JS tests all pass so we should be fine with Node 10

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙅‍♂️

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still no good 🙅‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: These files are made executable on the preview server. So there is no need to have them executable here (unless you want to execute them outside of the docker container...which you probably shouldn't be doing 😛).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new scripts (dev.sh, run-tests.sh, test-env.sh) should be documented in overview--scripts-and-commands.md.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are actually documented in misc--debug-docker-container.md. I'll add a bit to overview--scripts-and-commands.md for good measure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel a littlevery uncomfortable having this on the production server 😱

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still feeling uncomfortable.
As discussed, we could have these scripts in a directory that is not included in the docker container by default, but could be explicitly attached (e.g. as a volume).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file no longer exists. It has been replaced by verify-setup-and-log, which no longer deletes anything:

aio-verify-setup
ls -t /var/log/aio/upload-server-verify* | head -1 | xargs cat

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this script? 😱 😱 😱

@petebacondarwin
Copy link
Contributor Author

@gkalpak I have addressed yourr comments and reordered the commits. But I still have some tidying up to do in the TypeScript files - later today.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the key change here is that we now must also clean the downloads folder, which is populated with artifacts downloaded from CircleCI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the specific GitHub API classes (like Teams and Pull Requests) now use this helper class by composition rather than inheritance. Therefore I had to make getPaginated a public method to expose it to these classes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why using composition over inheritance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Composition provides a number of benefits. We only need to create on instance of the underlying GithubApi service, we can test that service independently of the subclasses that use it; and the clients of this service get a clean public API to work against.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing and catching is simply to capture the stack trace to make debugging easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we need to use a Dependency Injection framework here? :-P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I converted these methods to static because really creating an instance of this class was unnecessary - there is not state in the class. The only reason I didn't pull them out into independent exported functions is that it is nice to have them in a container so that it is simple to spy/mock them for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the meat of the change to this file - the new handler for the circle-build request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe I made any substantive change to the pr-updated request handler, other than a sprinkling of await.

@petebacondarwin petebacondarwin force-pushed the aio-circleci-builds branch 5 times, most recently from c0012b4 to 2c4fc68 Compare May 11, 2018 14:55
@petebacondarwin petebacondarwin added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: WIP labels May 11, 2018
@mary-poppins
Copy link

You can preview 2c4fc68 at https://pr23576-2c4fc68.ngbuilds.io/.

@petebacondarwin petebacondarwin merged commit 92c8752 into angular:master Aug 16, 2018
@petebacondarwin petebacondarwin deleted the aio-circleci-builds branch August 31, 2018 18:35
gkalpak added a commit to gkalpak/angular that referenced this pull request Sep 26, 2018
gkalpak added a commit to gkalpak/angular that referenced this pull request Sep 26, 2018
kara pushed a commit that referenced this pull request Sep 26, 2018
kara pushed a commit that referenced this pull request Sep 26, 2018
…anges (#25671)

Mostly (but not exclusively) a follow-up to #23576.

PR Close #25671
kara pushed a commit that referenced this pull request Sep 26, 2018
kara pushed a commit that referenced this pull request Sep 26, 2018
…anges (#25671)

Mostly (but not exclusively) a follow-up to #23576.

PR Close #25671
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: build & ci Related the build and CI infrastructure of the project cla: yes target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants