[ci] Check Vendoring is up to Date

This adds a step to the CI to check whether the vendored versions of
repositories have been fully committed. If it hasn't, running
`vendor.py` (without `--update`), will cause changes to the repo which
`git diff` will show.

The intention here is to catch when someone has not committed all the
changes that an update to a vendor file may have caused.

This CI step uses the `--check-patches` option to ensure any patches
apply cleanly.

Signed-off-by: Sam Elliott <selliott@lowrisc.org>
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 5255c5e..f63e2ac 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -122,6 +122,25 @@
     condition: eq(variables['Build.Reason'], 'PullRequest')
     displayName: Check commit metadata
   - bash: |
+      # Here we look for all *.vendor.hjson files in the repo to re-vendor them.
+      # We exclude the following:
+      # - Any in 'hw/vendor/lowrisc_ibex', because that directory is vendored.
+      # - `./sw/vendor/riscv_compliance.vendor.hjson`, because it has whitespace
+      #   issues in the repository that we cannot easily solve.
+      find . \
+        -not \( -path './hw/vendor/lowrisc_ibex' -prune \) \
+        -not \( -name 'riscv_compliance.vendor.hjson' \) \
+        -name '*.vendor.hjson' \
+        | xargs -n1 util/vendor.py --verbose \
+        && git diff --exit-code
+      if [[ $? != 0 ]]; then
+        echo -n "##vso[task.logissue type=error]"
+        echo "Vendored repositories not up-to-date. Run util/vendor.py to fix."
+        exit 1
+      fi
+    condition: always()
+    displayName: Check vendored directories are up-to-date
+  - bash: |
       only_doc_changes=0
       if [[ "$(Build.Reason)" = "PullRequest" ]]; then
         # Conservative way of checking for documentation-only changes.