From 515a41dee97fd1929ae9d3ff132a5b9376c52983 Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Fri, 19 Feb 2021 21:13:40 +0100 Subject: [PATCH] LUCENE-9792: add testRegressions task that downloads and runs hunspell regression tests. (#2407) --- .github/workflows/hunspell.yml | 36 +++++++++++++++++++++++ lucene/analysis/common/build.gradle | 45 ++++++++++++++++++++++++++++- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/hunspell.yml diff --git a/.github/workflows/hunspell.yml b/.github/workflows/hunspell.yml new file mode 100644 index 00000000000..65ab047bdfc --- /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 24c949f3f8d..6fba70adb2c 100644 --- a/lucene/analysis/common/build.gradle +++ b/lucene/analysis/common/build.gradle @@ -24,6 +24,49 @@ dependencies { 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 @@ tasks.withType(Test) { systemProperty it, val } } -} \ No newline at end of file +}