PikaCourse / homiehomie

3 stars 0 forks source link

GitHub collaboration and CI workflow intro #16

Open William-An opened 3 years ago

William-An commented 3 years ago

Branch introduction

Structure

  1. main and dev branch
  2. Open new branch when developing a new feature
  3. Open pull request and do code review
  4. Perform test
  5. Merge back to dev branch

Development cycle

  1. On local machine, create a feature branch via git checkout -b FEATURE_BRANCH_NAME
  2. In case someone do not know how to add and commit files (like @kimonazj), use the following commands to add your code to local repo
    1. Add any files under the current directory: git add .
    2. Commit changes to repo: git commit -m "COMMENT_MSG"
      1. In case you want to make changes to your commit, you can readd any files or remove them from stashed (git add) via git rm --cache PATH/TO/FILES
      2. Then use git commit --amend to reset the commit and commit message
      3. Note: do not use git commit --amend after you push to remote, doing so will result in some unpleasant issue
  3. Finish the feature and any testing related to it (at least make sure it is compilable Okay?)
  4. Push the feature branch to cloud via git push -u origin FEATURE_BRANCH_NAME and create a pull request with base as dev
    1. If you complete a feature, please add [deploy] to commit message and create the pull request so that the change will be deployed to test server
  5. Wait until me @William-An or @MARX1108 to review your code and permit the pull request, DO NOT authorize it by yourself unless you have told us in advance
    1. First request me @William-An for coding standard
    2. After @William-An finishes, he will request @MARX1108 for functionality check
  6. After permit the pull request and merge it back to the dev branch, we will delete the remote feature branch
  7. On your local machine, perform the following:
    1. Checkout back to dev branch: git checkout dev
    2. Sync with remote repo: git pull
    3. Delete your local feature branch: git branch -d FEATURE_BRANCH_NAME
  8. Repeat the process for new feature

For dev and main branches

  1. Do not commit any feature on these two branches
  2. The only allow commits are bug fixes or minor document changes as well as small portion code fix (less than 10 lines)

GitHub Action CI

Now we have set up a workflow for automatically test the backend and frontend and push the repo to remote server for deployment. The process of the workflow is as follows:

  1. Test backend
    1. Install necessary packages
    2. Run unittest for django
    3. Generate coverage report according to .coveragerc
    4. Upload report to codecov.io
  2. Test frontend (parallel with backend test)
    1. Now only has a dummy step which just echo NOT IMPLEMENTED
  3. Deploy to dokku
    1. Deploy to test server
    2. Required that previous jobs are correct (i.e. pass tests for backend and frontend)
    3. Can use the keyword [deploy] to actually deploy to test server

TODO

  1. [ ] Linter test?