-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Branch Deploys #98
base: master
Are you sure you want to change the base?
Feature Branch Deploys #98
Conversation
9773dbc
to
dbb89d2
Compare
@@ -1,7 +1,13 @@ | |||
#!/bin/bash | |||
set -e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set -e makes it immediately exit if there's a non-zero status
…nto feature/add-run-populate-for-feature-branch-deploys
Codecov Report
@@ Coverage Diff @@
## master #98 +/- ##
===========================================
+ Coverage 97.35% 100.00% +2.64%
===========================================
Files 16 16
Lines 265 218 -47
Branches 73 39 -34
===========================================
- Hits 258 218 -40
+ Misses 5 0 -5
+ Partials 2 0 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
A couple of comments:
|
…nto feature/add-run-populate-for-feature-branch-deploys
We will need to adjust one of the workflows because we don't just want to deploy when the PR is created, but rather update the deployment configuration whenever the PR is updated. Switching from pr-open-based to push-based, we should limit feature branch deploys to branches prefixed with The nuke job may not need to be adjusted, as the yaml generated from it will likely be the same as the last feature branch deployment from the last commit on that PR. |
Also, haven't figured out how to comment the feature branch deploy link(s) because sometimes there ARE no accessible links, and sometimes there are multiple. This is more product specific, so oh well. Will figure it out. Worst case scenario, you just see how the github actions succeeded and you manually go to the link yourself (<- This is kind of like a staging vibes so honestly might as well make a |
TODO: need to handle building & publishing the docker images. Still haven't figured out the desired behavior for that: should it make a new docker image suffixed with the PR number, and then delete that image when the PR closes? That seems like a reasonable way but making temporary docker images is not very clean. Alternatively, something like staging could handle build & published docker images, and we can just use the original one for feature branch deploys :D |
cdk/kraken/src/deploy.ts
Outdated
@@ -73,6 +73,11 @@ export class DeployJob extends CheckoutJob { | |||
{ | |||
id: "synth", | |||
name: "Synth cdk8s manifests", | |||
...(fullConfig.isFeatureDeploy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving the check for PR number earlier to skip feature branch deploy job as a whole
…nto feature/add-run-populate-for-feature-branch-deploys
cdk/kraken/src/deploy.ts
Outdated
|
||
# Get repo name (by removing owner/organization) | ||
export DEPLOY_TO_FEATURE_BRANCH=true | ||
export RELEASE_NAME=${"${REPOSITORY#*/}-pr-${{ steps.pr.outputs.pull_request_number }}"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may be wondering, "Joy, why are you doing this dumb thing RELEASE_NAME=${"${REPOSITORY#*/}}
? Couldn't you just escape it using RELEASE_NAME=\${REPOSITORY#*/}
The answer is that ts-dedent
is clowning me. I spent too much time trying to figure out what is going on. This is a bug, so I'm using this very sad format to do it. Hopefully someday they fix it and I'll use the clean way.
Design Consideration: Announcing Feature Branch DeploysRight now, we deploy feature branches to MethodSolution 1. Send "Successful Deployment" message for each commit pushed (Current)Pros:
Solution 2. Send 1 singular message at the first time the PR is opened.Pros:
Solution 3. Change the PR descriptions once to include the link.Pros:
What does Vercel do?Vercel offers something similar for Github Actions. With Vercel, you give it the End solutionSolution 2 |
Overview
On PRs, deploy a version of the product to something like pr-xyz.domain.com using a sqlite db. This is important for testing site behavior prior to merging to main.
This PR details the infrastructure level changes to enable feature branch deploys. After this PR is merged, additional changes may be necessary to configure feature branch deploys for each product.
Desired Behavior
Feature branch deploys are separate from production deploys in the following:
IS_FEATURE_BRANCH
env variable will be set for any additional configurations on the application-side.When are feature branch deploys created? They are created when you open a PR AND the name of that PR branch starts with feature (e.g.
feat/add-search-bar
). These feature branch deploys should be updated whenever there is a change made within that PR, and then nuked when the PR is closed.Usage
To use feature branch deploys, set
enableFeatureBranchDeploy = true
in yourLabsApplicationStack
insidekraken
. This will add additional configuration to yourbuild-and-deploy
workflow and create an additional workflow file that nuke feature branch deploys when PRs closes.Infra
Kraken changes
TLDR: For the
LabsApplicationStack
, add a custom field enabling feature branch deploy workflows to be generated.This PR also introduces a
NukeJob
, which... nukes stuff >:))On PR Open
Generate a new set of deployment config with the staging set-up. *Note: might need to adjust because this is not just on PR open but also whenever the feature PR is being updated
IS_FEATURE_BRANCH
to truePR_NUMBER
to${{ github.event.number }}
RELEASE_NAME
topenn-clubs-pr-xx
On PR Close or Merge.
Kill everything specified in the deployment config (make sure to test this)
TODOs
MAKESUREs
Testing & Clean-up
Backend
Add env variable check to populate database for feature branch deploys
This change is necessary to accommodate for feature branch deploys.
Currently, we run the migrations such that the database exists, but for feature branch deploys we want to fill it with dummy data for testing purposes. This can be done by checking for a
RUN_POPULATE
env variable in the django base & follow-up changes in using the django base.Misc
Penn Courses now uses postgresql even in development, so will need to accommodate for that.
There are also other things that the backend of products use (v1 ignoring specific services? S3 bucket makes sense, but things like twilio doesn't really belong in feature branch deploys/staging anyways)
Frontend
Frontend Changes
On the application side (NOT handled by this PR):
DOMAIN
is updated.Adoption:
feat/
so randoms can't open a feature branch and deploy vulnerable code.