0-readme edit

git-usage  edit

Git Process & Walkthrough
Branch Overview
  • prod - Deploys to the live Prod site (https://www.wm.edu). Gets pushed to GitLab then manually deployed from GitLab
  • test - Deploys to the Test site (https://test-www.wm.edu) automatically when pushed to GitLab. Used to accurately review pending updates to the Prod site. Needs to be (ideally) identical to prod + the feature to be reviewed.
  • atomic-docs-dev - This entire Atomic Docs app and W&M test site is also on the creative-test server so features can be reviewed without needing to merge/deploy to the Test site. It used to deploy automatically when pushed but that is currently broken so I have been manually uploading to the server using SFTP.
  • development branches - Created as-needed for work on updates or features, see Development Steps
Development Steps

I highly, highly recommend the VS Code extension GitLens.

  1. Create a new feature/update/bugfix branch
    1. Start on prod branch. Make sure you have the latest code: git pull origin prod

    2. Use this code to create a new branch and check it out at the same time.
      git checkout -b tempDevBranch

      Tip: I name my branches this way:
      mmdd-parentBranch-taskDescriptionUsingVerb
      for example: 0218-prod-updateHeadingSpacing

  2. Make updates on new branch
    1. If coming from another branch, switch to the new one first: git checkout tempDevBranch
    2. Commit any time you have completed a cohesive " chunk" of work. Committing frequently makes it easier to go back and fix things if necessary.

      DO NOT commit the prod/main.css or prod/main.css.map files.
      These files tend to cause the most conflicts when merging and get rewritten by Scout when switching to a new branch anyways. Only commit them after a merge into test or prod so they will get deployed.

      To keep them from being commited, unstage them, then commit the rest. When leaving to switch to another branch, they can safely be discarded since they will be created again by Scout when switching back to the branch.

      To add all changed files and commit them all at the same time:
      git commit -am "short description of work done"

      If you have made multiple changes that should go in different commits, you can add them separately and then commit.
      git add path/to/file path/to/another/file
      git commit -m "Message for this commit"
      or you could use the awesome VS Code GitLens extension and add/commit using that.

    3. (Recommended) At the end of each work day push your dev branch(es) to GitLab. That way there is a record of your work off of your computer in case something were to happen. Both the dev branch and remote dev branch can be deleted when they are no longer needed.
  3. Review changes on Test site or Atomic Docs Dev site
    • Test site

      The test and prod branches deploy to AWS. There is generally not a caching issue, but if there is you can go into /_theme/formats/head_base and change the query number on the link to the main.css stylesheet and then publish head_base.
      git checkout test
      git merge tempDevBranch
      Resolve any conflicts and QA locally, if necessary.
      git push origin test
      You can go to Atomic Doc GitLab Pipelines to watch the deploy status.

    • Upload to Creative Test site (optional)

      If necessary, for code review outside of a Cascade server, you can manually upload to the creative-test server:
      sftp://uwad-php72-00.it.wm.edu/var/www/creative-test.wm.edu/public_html/atomic-docs-dev.

  4. Once approved, send changes to Prod
    • To update the live site, we start by merging the test branch into prod and deploying.

    • git checkout prod
      git merge test
      Resolve any conflicts and QA locally, if necessary.
      git push origin prod
    • Go to Atomic Doc GitLab Pipelines and click on Skipped -> Deploy, to deploy to Prod site.
    • QA Prod site
      When something is caught by QA, create a temporary branch off of prod to fix, then use that branch to repeat these steps from the start (merging into test, etc).
  5. Delete the temporary development branch

    git branch -d tempDevBranch

GitLab

Configuration of how the code gets deployed in Gitlab is set up in the /gitlab-ci.yml file. IT can help with this, if needed.

Git Conflicts

Sometimes you will run into a conflict with the main css file. It will look somethink like this:

example of git conflict

This happens when the css has been saved in a different format, expanded vs compressed for example. The solution is to add a space in a scss file and save which will cause Scout to recompile the files. Then git commit -am "css conflict fix" will fix it.

Most of the time, however, I simply don't include the main.css and .map files when commiting on branches other than test and prod.

Copy
Edit
<!-- components/0-readme/git-usage.php --> <div class="wm-ad-docs"> <h5>Git Process & Walkthrough</h5> <h6>Branch Overview</h6> <ul> <li><code>prod</code> - Deploys to the live Prod site (<a href="https://www.wm.edu/temp/page-examples/content-page/index.php" target="_blank">https://www.wm.edu</a>). Gets pushed to GitLab then manually deployed from GitLab</li> <li><code>test</code> - Deploys to the Test site (<a href="https://test-www.wm.edu/temp/page-examples/content-page/index.php" target="_blank">https://test-www.wm.edu</a>) automatically when pushed to GitLab. Used to accurately review pending updates to the Prod site. Needs to be (ideally) <strong> identical to <code>prod</code> + the feature to be reviewed</strong>. </li> <li><code>atomic-docs-dev</code> - This entire Atomic Docs app and W&M test site is also on the <a href="https://creative-test.wm.edu/atomic-docs-dev/wm/atomic-core/index-wm.php?url=components/9-Content-Types/Content-Page.php" target="_blank">creative-test server</a> so features can be reviewed without needing to merge/deploy to the Test site. It used to deploy automatically when pushed but that is currently broken so I have been manually uploading to the server using SFTP.</li> <li>development branches - Created as-needed for work on updates or features, see Development Steps</li> </ul> <h6>Development Steps </h6> <p>I highly, highly recommend the VS Code extension GitLens.</p> <ol> <li> <strong>Create a new feature/update/bugfix branch</strong> <ol> <li> <p> Start on <code>prod</code> branch. Make sure you have the latest code: <code>git pull origin prod</code> </p> </li> <li> <p>Use this code to create a new branch and check it out at the same time.<BR> <code>git checkout -b tempDevBranch</code> </p> <p> <em>Tip: I name my branches this way: <BR> </em>mmdd-parentBranch-taskDescriptionUsingVerb<BR> <em>for example: </em> 0218-prod-updateHeadingSpacing </p> </li> </ol> </li> <li> <strong>Make updates on new branch</strong> <ol> <li><em>If coming from another branch, switch to the new one first</em>: <code>git checkout tempDevBranch</code></li> <li> <p> <strong>Commit</strong> any time you have completed a cohesive " chunk" of work. Committing frequently makes it easier to go back and fix things if necessary. </p> <p class="alert" style="background-color: pink;"> <strong>DO NOT commit the prod/main.css or prod/main.css.map files.</strong><BR>These files tend to cause the most conflicts when merging and get rewritten by Scout when switching to a new branch anyways. Only commit them after a merge into test or prod so they will get deployed. </p> <p>To keep them from being commited, unstage them, then commit the rest. When leaving to switch to another branch, they can safely be discarded since they will be created again by Scout when switching back to the branch.</p> <p> <em>To add all changed files and commit them all at the same time:</em> <BR> <code>git commit -am "short description of work done"</code> </p> <p><em> If you have made multiple changes that should go in different commits, you can add them separately and then commit. </em><BR> <code>git add path/to/file path/to/another/file</code><BR> <code>git commit -m "Message for this commit"</code><BR> <em>or you could use the awesome VS Code GitLens extension and add/commit using that.</em> </p> </li> <li>(Recommended) At the end of each work day push your dev branch(es) to GitLab. That way there is a record of your work off of your computer in case something were to happen. Both the dev branch and remote dev branch can be deleted when they are no longer needed.</li> </ol> </li> <li> <strong>Review changes on Test site or Atomic Docs Dev site</strong> <ul> <li><strong>Test site</strong> <p>The <code>test</code> and <code>prod</code> branches deploy to AWS. There is generally not a caching issue, but if there is you can go into /_theme/formats/head_base and change the query number on the link to the main.css stylesheet and then publish head_base.<br> <code>git checkout test</code><br> <code>git merge tempDevBranch</code><BR> Resolve any conflicts and QA locally, if necessary.<BR> <code>git push origin test</code><BR> You can go to <a href="https://code.wm.edu/uwd/atomic-docs/-/pipelines" target="_blank">Atomic Doc GitLab Pipelines</a> to watch the deploy status. </p> </li> <li><strong>Upload to Creative Test site (optional)</strong> <p>If necessary, for code review outside of a Cascade server, you can manually upload to the creative-test server: <BR>sftp://uwad-php72-00.it.wm.edu/var/www/creative-test.wm.edu/public_html/atomic-docs-dev.</p> </li> </ul> </li> <li><strong>Once approved, send changes to Prod</strong> <ul> <li> <p>To update the live site, we start by merging the <code>test</code> branch into <code>prod</code> and deploying.</p> </li> <li> <code>git checkout prod</code><br> <code>git merge test</code><BR> Resolve any conflicts and QA locally, if necessary.<BR> <code>git push origin prod</code> </li> <li>Go to <a href="https://code.wm.edu/uwd/atomic-docs/-/pipelines" target="_blank">Atomic Doc GitLab Pipelines</a> and click on Skipped -> Deploy, to deploy to Prod site.</li> <li>QA Prod site<BR> When something is caught by QA, create a temporary branch off of <code>prod</code> to fix, then use that branch to repeat these steps from the start (merging into <code>test</code>, etc).</li> </ul> </li> <li><strong>Delete the temporary development branch</strong><BR> <p><code>git branch -d tempDevBranch</code><br> </p> </li> </ol> <h5>GitLab</h5> <p>Configuration of how the code gets deployed in Gitlab is set up in the /gitlab-ci.yml file. <a href="mailto:unix@wm.edu">IT</a> can help with this, if needed.</p> <h5 id="gitconflicts">Git Conflicts</h5> <p>Sometimes you will run into a conflict with the main css file. It will look somethink like this:</p> <img src="images/git_conflict.png" alt="example of git conflict"> <BR><BR> <p>This happens when the css has been saved in a different format, expanded vs compressed for example. The solution is to add a space in a scss file and save which will cause Scout to recompile the files. Then <code>git commit -am "css conflict fix"</code> will fix it.</p> <p>Most of the time, however, I simply don't include the main.css and .map files when commiting on branches other than <code>test</code> and <code>prod</code>.</p> </div>
Copy
Copy
Edit
/* scss/0-readme/_git-usage.scss */