Skip to content

Conversation

@Naramsim
Copy link
Member

@Naramsim Naramsim commented Apr 25, 2020

PRs are ready, I would start by reading this one and then moving to PokeAPI/deploy#10


This PR will be used to describe major changes in the way we update our application pokeapi.co seen as a whole (API+frontpage+docs).

Right now to deploy the API we need to run a script on our PCs and then merge a PR. The script requires docker, takes a long time and when it's done will open a PR towards PokeAPI/api-data with the new data. The new data there is actually impossible to visualize since thousands of files were probably updated. So this PR proposes two solutions to our two problems:

  • Running the updater-script somewhere else, not on our PCs, and in an automatic manner
  • Enabling a staging environment to check what we are going to deploy
  • (bonus) Having a way to deploy a PR without merging it to the master branch

How?

Part of this PR adds a way to update productive data effortlessly. It uses the old updater bot and runs it in CircleCI, then pushes the new data to a PokeAPI/api-data branch (called staging) and opens a Pull Request in the api-data repository, asking to merge staging into master.

The workflow is:

  1. A PR on PokeAPI/pokeapi is merged in the master branch, thus the master is pushed/committed
  2. CircleCI is notified and runs the tests and a new special script Resources/scripts/updater.sh
  3. This updater.sh script is substantially a glue-script of the old https://github.com/PokeAPI/api-data/blob/master/updater/cmd.bash written by @sargunv.
    Basically the two scripts generate new data using the updated master branch of PokeAPI/pokeapi and push it to PokeAPI/api-data's staging branch, the push is done by the new pokeapi-machine-user. A cool thing is that the new machine user will keep us updated about how things are going inside CircleCI. It is programmed to send some messages to the recently merged PR.
  4. The script creates also a new PR in PokeAPI/api-data from the staging branch into the master one. This is cool because the staging branch will be deployed in a new Firebase staging environment thanks to the other PRs linked down below. So we will be able to check how our updated application as a whole (API+frontpage+docs) will look like.
  5. Then, if that PR is merged, the new data will be deployed automatically to the productive Firebase environments. If you want to see how a sample PR from staging into master looks like you have it here: API data update from PokeAPI/pokeapi#488 api-data#41, over there I forced a staging deployment of PokeAPI/pokeapi's circleci-hook branch even though it should have run only on the master branch, but it was only for testing. Normally the deployment will be done only if the master gets pushed.

I think this workflow works well because it takes completely away the hassle of generating the data manually and the risk of deploying broken stuff.

An additional workflow allows us to deploy in the staging environment the content of a PR that hasn't been merged yet. In fact whenever PokeAPI/pokeapi or PokeAPI/pokeapi.co's staging branches get pushed a new staging deployment will be triggered. So suppose an external user sends us a PR, we will just need to push it to the staging branch and in 45 minutes we will have the staging environment reflecting the new changes that PR brings in.


This PR is linked to the following PRs:

When PokeAPI/deploy#10 will be merged we need to change Resources/scripts/updater.sh#90 and .circleci/config.yml#43

This PR should be merged after PokeAPI/deploy#10 and PokeAPI/api-data#42

@Naramsim Naramsim added the wip Work in progress, don't merge label May 2, 2020
@PokeAPI PokeAPI deleted a comment from pokeapi-machine-user May 2, 2020
@PokeAPI PokeAPI deleted a comment from pokeapi-machine-user May 2, 2020
@PokeAPI PokeAPI deleted a comment from pokeapi-machine-user May 2, 2020
@PokeAPI PokeAPI deleted a comment from pokeapi-machine-user May 2, 2020
@Naramsim Naramsim changed the title Update data automatically Update data automatically and enable staging deployment May 2, 2020
@Naramsim Naramsim removed the request for review from tdmalone May 2, 2020 22:14
@PokeAPI PokeAPI deleted a comment from pokeapi-machine-user May 3, 2020
@PokeAPI PokeAPI deleted a comment from pokeapi-machine-user May 3, 2020
@Naramsim Naramsim added ready Ready to be reviewed and removed wip Work in progress, don't merge labels May 7, 2020
@Naramsim Naramsim requested review from a team, cmmartti, phalt and tdmalone May 7, 2020 17:49
@Naramsim Naramsim merged commit d5b4363 into master May 13, 2020
@Naramsim Naramsim deleted the circleci-hook branch May 13, 2020 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants