LUCENE-9792: add testRegressions task that downloads and runs hunspell regression tests. (#2407)

diff --git a/.github/workflows/hunspell.yml b/.github/workflows/hunspell.yml
new file mode 100644
index 0000000..65ab047
--- /dev/null
+++ b/.github/workflows/hunspell.yml
@@ -0,0 +1,36 @@
+name: Hunspell regression tests
+
+on:
+  pull_request:
+    branches:
+      - 'master'
+    paths:
+      - '.github/workflows/hunspell.yml'
+      - 'lucene/analysis/common/**'
+
+jobs:
+  test:
+    name: Run Hunspell regression tests
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: Set up JDK 11
+      uses: actions/setup-java@v1
+      with:
+        java-version: 11
+    - name: Grant execute permission for gradlew
+      run: chmod +x gradlew
+    - uses: actions/cache@v2
+      with:
+        path: |
+          ~/.gradle/caches
+        key: ${{ runner.os }}-gradle-solrj-${{ hashFiles('versions.lock') }}
+        restore-keys: |
+          ${{ runner.os }}-gradle-solrj-
+          ${{ runner.os }}-gradle-
+    - name: Initialize gradle settings
+      run: ./gradlew localSettings
+    - name: Run regular and regression tests
+      run: ./gradlew -p lucene/analysis/common check testRegressions
diff --git a/lucene/analysis/common/build.gradle b/lucene/analysis/common/build.gradle
index 24c949f..6fba70a 100644
--- a/lucene/analysis/common/build.gradle
+++ b/lucene/analysis/common/build.gradle
@@ -24,6 +24,49 @@
   testImplementation project(':lucene:test-framework')
 }
 
+// Fetch the data and enable regression tests against woorm/ libreoffice dictionaries.
+task checkoutHunspellRegressionRepos() {
+  ext {
+    checkoutDir = file("${buildDir}/hunspell-regressions")
+  }
+
+  outputs.dir checkoutDir
+  doFirst {
+    // Clone the repositories we need if they don't exist.
+    [
+        "libreoffice": "https://github.com/LibreOffice/dictionaries",
+        "woorm": "https://github.com/wooorm/dictionaries"
+    ].each { name, repo ->
+      if (!file("${checkoutDir}/${name}").exists()) {
+        checkoutDir.mkdirs()
+        // This will work only if git is available, but I assume it is.
+        project.exec {
+          executable "git"
+          ignoreExitValue false
+          workingDir checkoutDir
+          args = [ "clone", "--depth=1", repo, name ]
+        }
+      }
+    }
+  }
+}
+
+task testRegressions(type: Test) {
+  group "Verification"
+  description "Run Hunspell regression tests against Woorm/ LibreOffice git repositories."
+
+  dependsOn checkoutHunspellRegressionRepos
+
+  failFast = true
+  include "**/TestAllDictionaries*"
+
+  systemProperty "hunspell.dictionaries", checkoutHunspellRegressionRepos.checkoutDir
+
+  doFirst {
+    logger.lifecycle("Running Hunspell regression tests...")
+  }
+}
+
 // Pass all hunspell-tests-specific project properties to tests as system properties.
 tasks.withType(Test) {
   [
@@ -37,4 +80,4 @@
       systemProperty it, val
     }
   }
-}
\ No newline at end of file
+}