Spell check on commit message support for CI

- This commit would add the codespell package while
  building the base container.

- The intention is that, we maintain two dictionaries
  1. That comes directly with codespell
    - We should also download the latest dictionary while
      while building the base container.
  2. An openbmc spellings dictionary
    - We should be able to add words and spellings that are
      openbmc related in this dictionary over time.

- When the commit message have words that the dictionary does not have,
the CI proceeds further without any rejection. The CI only scores a -1 if
it sees a word wrongly spelled from it knowledge from the dictionary.

Tested by:

1. when commit message have mistakes: It breaks & scores a -1
   It also highlights the spelling mistake and the correct spelling
   to be used.

2. when commit message does not have mistakes : it does not break &
   proceeds further for compilation.

Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: I87278597876b6e2b0a59e297cde020631491b5fd
diff --git a/scripts/build-unit-test-docker b/scripts/build-unit-test-docker
index 8b0740c..4313753 100755
--- a/scripts/build-unit-test-docker
+++ b/scripts/build-unit-test-docker
@@ -822,6 +822,7 @@
 RUN pip3 install jsonschema
 RUN pip3 install meson==0.57.1
 RUN pip3 install protobuf
+RUN pip3 install codespell
 """
 
 # Build the base and stage docker images.
diff --git a/scripts/format-code.sh b/scripts/format-code.sh
index d8ef389..65f3dac 100755
--- a/scripts/format-code.sh
+++ b/scripts/format-code.sh
@@ -10,10 +10,21 @@
 # Input parmameter must be full path to git repo to scan
 
 DIR=$1
-cd "${DIR}"
 
 set -e
 
+echo "Running spelling check on Commit Message"
+
+# Run the codespell with openbmc spcific spellings on the patchset
+echo "openbmc-dictionary - misspelling count >> "
+codespell -D openbmc-spelling.txt -d --count "${DIR}"/.git/COMMIT_EDITMSG
+
+# Run the codespell with generic dictionary on the patchset
+echo "generic-dictionary - misspelling count >> "
+codespell --builtin clear,rare,en-GB_to_en-US -d --count "${DIR}"/.git/COMMIT_EDITMSG
+
+cd "${DIR}"
+
 echo "Formatting code under $DIR/"
 
 if [[ -f "setup.cfg" ]]; then