dwyl / mvp

📲 simplest version of the @dwyl app
https://mvp.fly.dev
GNU General Public License v2.0
84 stars 2 forks source link

PR: Create Review Apps #230

Closed SimonLab closed 1 year ago

SimonLab commented 1 year ago

Start documentation on how to create a Github action for review apps

codecov[bot] commented 1 year ago

Codecov Report

Merging #230 (29ddfbe) into main (302c079) will not change coverage. The diff coverage is n/a.

@@            Coverage Diff            @@
##              main      #230   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        13           
  Lines          309       309           
=========================================
  Hits           309       309           

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

SimonLab commented 1 year ago

For the mvp reivew apps to be able to run we need to add environment variables using Fly secrets: https://fly.io/docs/app-guides/minio/#secrets We have to set the ENCRYPTION_KEYS and AUTH_API_KEYS. To be able for the Github action scripts to set the values we need to store and pass them from the Github repository secrets:

image

SimonLab commented 1 year ago

Edit: All works, after updating the auth_api_key in Github secrets!

So I think the script to deploy a new Fly appication when a PR is created works. It creates a new application names: mvp-pr-#<pr-number>. However I don't think the script can work for application usingauth: I've added theAUTH_API_KEYas environment variables (copied from the mvp app) but this api key is unique to themvpname and doesn't work fromvp-pr-...` names:

image

For this to work, a new api key on auth needs to be created manually providing the correct url name: image

So to conclude I don't think we can have an automatic way of creating review apps. We can create one mvp-review-app application manually and deploy PRs manually to this application if we want to showcase the new code

SimonLab commented 1 year ago

I have a similar issue to https://community.fly.io/t/postgres-lingering-connection-after-deleting-fly-app/4771/3

I've deleted manually the review apps while testing the script. The database created by the script is not deleted and I'm now blocked when attempting to run flyctl postgres attach. The command fails (as the db already exists) and the DATABASE_URL is not set which break the deployement.

To remove the database: drop database <namedb> with (force); then remove the user drop user <nameuser>;

SimonLab commented 1 year ago

The script for deploying review apps is now ready, see https://mvp-pr-230.fly.dev/ for this current PR. I haven't tried yet to check the review app is removed when a PR is merged but this can be tested once this PR is merged.

nelsonic commented 1 year ago

@SimonLab Could you please confirm that the review app is deleted automatically when no longer needed?

https://mvp-pr-230.fly.dev/

image
SimonLab commented 1 year ago

The action has been triggered by the "closed" event when the PR has been merged and the script to "destroy" the application exited without error: image

On the Fly dasbhoard the mvp-pr-230 has been removed: image

nelsonic commented 1 year ago

Nice one. Thanks. 🙏