NUcore is usually deployed from a school-specific repo containing customized branding
and functionality. There are situations where you may need to bring changes
from the nucore-open
repo into a school-specific repo, or the other way around.
In order to move commits between the repos you'll need to set up remote
repositories on each side.
You can either bring over all the new changes with a latest_from_open_MMDDYYYY
branch,
or just a few commits with a cherry-picked branch.
- Start in the directory of the school repo (for example,
nucore-nu
) - Open a new branch (for more details see the sections on creating a latest_from_open or cherry-picked branch below)
- Merge the PR (not squash) once it has been approved and CI is green (see below)
- For a production release, create a Github release (see below)
- Deploy the new code using capistrano or Github Actions (see below)
- Perform any release/deployment related tasks (e.g. add new env variables, run one-off rake task, etc.)
- Check the site in a browser and confirm new functionality is there
You can cherry-pick commits from upstream
/nucore-open
to create more focused PRs.
This can be useful for features that have more risk or dependencies and should be deployed
and tested separately (ruby upgrades, etc). In the school repo (for example, nucore-nu
):
git co -b upgrade_ruby_2_6_6
git fetch upstream
git cherry-pick XXXXX
To keep each school in sync with nucore-open
, the latest changes from nucore-open
are merged in on a regular basis.
While in your school-specific repo's directory
- Add a new remote called
upstream
that points to thenucore-open
repo (you should only need to do this once):git remote add upstream [email protected]:tablexi/nucore-open.git
- Create a new branch with the name
latest_from_open_MMDDYYYY
(reflecting the current date). - Whenever you want to bring the latest changes from open/master into your branch:
git fetch upstream
and thengit merge upstream/master
- Run
bin/merge_describer
which generates a helpful description you can copy/paste into your PR. It contains the commit messages and links to the merged branches since the last merge to master. You can also pass in other branch names or tags to target for the comparison. - Push up your new branch to GitHub, and paste the output from
bin/merge_describer
into the PR description. For clarity it's best to sort commits into 3 groups: features, fixes, and tech tasks.
You can use the bin/latest_from_open
script to create a new latest_from_open_MMDDYYYY
branch instead of using the steps above. Add the upstream
remote, then run bin/latest_from_open 04012021
.
When merging in changes from the open source repo, differences in scehma.rb
and Gemfile.lock
tend to be the trickiest to resolve. Run bundle
and rails db:migrate
locally to ensure any conflicts have been resolved as expected.
Before merging “latest from open” PRs, make sure that the related PR against nucore-open has deployed successfully.
The bin/merge_describer
script only describes commits which include the parenthesized branch number.
On github, squash commits include a parenthesized branch number like (#45)
in the commit title by default, except when the PR only includes 1 commit. Merge commits do not include the parenthesized branch number in the title. So...
- Use Squash for feature PRs, and copy the PR description into the squash merge message. Make sure the parenthesized branch number is in the commit title so the squash commit will get described later on in the GitHub release and release notes.
- Use Merge commits for
latest_from_open_MMDDYYYY
branch PRs. Make sure that the related PR against nucore-open has deployed successfully before merging.
For feature PRs, the PR title will become the squash commit message. These appear later in the bin/merge_describer
and bin/release_describer
output, which is used in thelatest_from_open_MMDDYYYY
PR description, github release, and release notes. Try to write feature PR titles that focus on user outcomes rather than technical details - "Fix ability to download CSV" is preferred over "Resolve issues with JSON parsing".
PR Titles that include “Shared Dev” or “Tech Task”, or start with “Security:” or “Fix:” will be automatically sorted by bin/release_describer
.
- Check out the commit you want to release and tag it:
git tag v2021-02-18
- Use
bin/merge_describer v2021-01-28
to list all commits since the previous release tag - Organize the output into features, fixes and tech tasks
- Create a new release in Github using this list of commits for the description
- Specify the new tag (
v2021-02-18
) for the release tag version, target, and release title
This doesn't come up as often, but sometimes you may need to bring a view hook or feature flag into open in order to support a school-specific customization.
The best way to bring the changes from a school-specific repo is by checking out a branch from nucore-open
and cherry-picking the desired school-specific commits. For this reason, it's best to develop on nucore-open
to start with, or to squash the commits in your branch so you only need to bring one commit.
For example, to bring changes from nucore-nu
into nucore-open
:
While in the nucore-open
directory
git remote add nu [email protected]:tablexi/nucore-nu.git
git fetch nu
git cherry-pick XXXXX
Deploy process will vary depending on the hosting setup. Github Actions is used to trigger deploys for cloud-hosting setups (ECS and Azure). Capistrano is used for legacy-hosting setups.
Merging to master
will trigger a stage deployment.
Create a Github Release with a tag starting with v
to trigger a production deployment.
From the root of your school-specific repo:
bundle exec cap [staging_name] deploy
staging_name
should be stage
, staging
, or development
. Check the name of the .rb
files in config/deploy/[staging_name].rb
.
Prod releases need to be scheduled ahead of time with each school, and are typically done after hours.
From the root of your school-specific repo:
REVISION=[tag_to_release] bundle exec cap [prod_name] deploy
prod_name
should be prod
or production
. check the name of the .rb
files in config/deploy/[prod_name].rb
.
tag_to_release
should be created in Github, for example v2021-03-01
.