Command Line Developer Tools - department-of-veterans-affairs/caseflow GitHub Wiki

With the release of APPEALS-51865, new git commands have been created to help Caseflow developers catch failing tests on their development branches. The current commands are git clean-pr, git clean-push, and git codeclimate

Setup git commands

  1. Go to your .bashrc or .zshrc file and add the following path: export PATH=$PATH:/<<your-directory-here>>/git-commands
  2. Source the git commands directory by running: source ~/.bashrc or source ~/.zshrc depending on step 1.

git clean-pr

git clean-pr is a command line dev tool that runs the following relevant tests based on files changed within the git in-flight commits:

  1. Ruby spec test
  2. Ruby feature tests
  3. Rubocop
  4. fasterer
  5. scss-lint
  6. jest
  7. lint:fix
  8. prettier
  9. Codeclimate (optional)

Tests will only be run if relevant for the file type (ex: Ruby files will run spec, feature, rubocop etc. while Javascript files will run Jest/Lint/etc. tests).

The syntax for the command is git clean-pr [branch-name] -- [codeclimate] [autofix]

The options for the command are:

  1. branch-name option: by default, the command runs tests for differences in the base branch and in-flight commits. If a branch is passed, tests will be run for files that are different between the base branch and the branch-name passed in.
  2. codeclimate option: if this option is passed in, the command will run git codeclimate for each file in the in-flight commit.
  3. autofix option: if this option is passed, the test will attempt to autofix failures for these following tests:
  • Rubocop
  • Jest snapshots

To run options with the command a -- separator is mandatory to run the options without issues.

git clean-push

The git clean-push command runs git clean-pr in conjuncture with a single line push command to the base branch. The syntax for the command is: git clean-push [commit-message] -- [codeclimate] [autofix]

The options for the command are:

  1. commit-message option (mandatory): a mandatory commit message needs to be run with the command in order for a commit to be created. The command returns an error message if a commit isn't passed. The string value needs to be wrapped in either single or double quotes.
  2. codeclimate option: see codeclimate option
  3. autofix option: see autofix option above

Once the test suite is finished running, git clean-pr will prompt the user if they want to push their changes. If the user enters y or Y, the changes will be pushed, and if the user enters n or N, the command will exit. Similar to git clean-pr, options need to be run with a -- separator in order for the command to run successfully.

git codeclimate

The git codeclimate command pulls down a CodeClimate CLI docker image and runs the Caseflow CodeClimate suite of tests for each file changed in the in-flight commits log. The syntax for the command is git codeclimate [path-to-file-here] If no file path is passed, the command will run codeclimate analyze on the entire Caseflow repository. Due to the extensive time it takes to run tests for the entire project, the command sets the timeout for 1 hour (overriding the default 15 minute timeout) when testing the entire project.