Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HSEARCH-4947 Make sure that nested jars can be read on Windows #3730

Merged
merged 10 commits into from
Sep 22, 2023
42 changes: 36 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ concurrency:
group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'hibernate/hibernate-search' }}

defaults:
run:
shell: bash

env:
MAVEN_ARGS: "-e -B --settings .github/mvn-settings.xml --fail-at-end"

jobs:
build:
name: ${{matrix.os.name}}
Expand All @@ -51,13 +56,26 @@ jobs:
runs-on: 'ubuntu-latest',
java: {
version: 17
},
maven: {
args: ''
}
}
# We can't start Linux containers on GitHub Actions' Windows VMs,
# so we can't run Elasticsearch tests.
# See https://github.com/actions/runner-images/issues/1143#issuecomment-972929995
# For some reason docker-maven-plugin will error out with "All pipe instances are busy"
# on GitHub Actions' Windows VMs (when using Bash?),
# so we also explicitly disable docker-maven-plugin.
# See https://github.com/fabric8io/docker-maven-plugin/issues/548#issuecomment-255477600
- {
name: "Windows JDK 17",
runs-on: 'windows-latest',
java: {
version: 17
},
maven: {
args: '-Dtest.elasticsearch.skip=true -Dtest.containers.run.skip=true'
}
}
steps:
Expand Down Expand Up @@ -86,22 +104,34 @@ jobs:
- name: Docker cleanup
run: ./ci/docker-cleanup.sh
- name: Building code and running unit tests and basic checks
run: ./mvnw $MAVEN_ARGS install -Pjqassistant -Pdist -Pci-sources-check -DskipITs
run: |
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} install \
-Pjqassistant -Pdist -Pci-sources-check -DskipITs
- name: Running integration tests in the default environment
run: |
./mvnw $MAVEN_ARGS verify \
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} verify \
-DskipSurefireTests -Pskip-checks -Pci-rebuild \
${{ github.event.pull_request.base.ref && format('-Dincremental -Dgib.referenceBranch=refs/remotes/origin/{0}', github.event.pull_request.base.ref) || '' }}
- name: Docker cleanup
if: always()
run: ./ci/docker-cleanup.sh
- name: Omit produced artifacts from build cache
run: rm -r ~/.m2/repository/org/hibernate/search
# Workaround for https://github.com/actions/upload-artifact/issues/240
- name: List build reports to upload (if build failed)
if: ${{ failure() || cancelled() }}
# The weird syntax is because we're setting a multiline environment variable
# See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string
run: |
{
echo 'buildReportPaths<<EOF'
find . -path '**/*-reports'
echo EOF
} >> "$GITHUB_ENV"
- name: Upload build reports (if build failed)
uses: actions/upload-artifact@v3
if: ${{ failure() || cancelled() }}
with:
name: ${{ format('build-reports-{0}', github.job) }}
path: |
./**/*-reports/
retention-days: 2
name: ${{ format('build-reports-{0}', matrix.os.name ) }}
path: ${{ env.buildReportPaths }}
retention-days: 7
28 changes: 28 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ and run unit tests and integration tests.
./mvnw clean install
```

Note: on Windows, you will need a Docker install able to run Linux containers.
If you don't have that, you can skip the Elasticsearch tests and all container startups:
`./mvnw clean install -Dtest.elasticsearch.skip=true -Dtest.containers.run.skip=true`.

Note: the produced JARs are compatible with Java 8 and later,
regardless of the JDK used to build Hibernate Search.

Expand Down Expand Up @@ -302,6 +306,17 @@ Or more simply, if the newer JDK you want to test against is newer than 17 and i
./mvnw clean install -Djava-version.test.release=18
```

### Lucene

The Lucene integration tests do not, by themselves,
require any external setup.

If you are not interested in Lucene integration tests (e.g. you only want to test Elasticsearch),
you can skip all Lucene tests with:

```bash
./mvnw clean install -Dtest.lucene.skip=true
```
### Elasticsearch

The Elasticsearch integration tests run against one single version of Elasticsearch at a time,
Expand All @@ -324,6 +339,19 @@ For available versions of [OpenSearch](https://www.opensearch.org/) distribution

For Amazon OpenSearch Serverless, the version must be unset (set to an empty string).

When necessary (e.g. you don't have Docker, or are on Windows and can't run Linux containers),
you can skip all Elasticsearch tests (and thus the Elasticsearch container startup) with:

```bash
./mvnw clean install -Dtest.elasticsearch.skip=true
```

On Windows, you might need to also skip all docker container features:

```bash
./mvnw clean install -Dtest.elasticsearch.skip=true -Dtest.containers.run.skip=true
```

Alternatively, you can prevent the build from launching an Elasticsearch server automatically
and run Elasticsearch-related tests against your own server using the
`test.elasticsearch.connection.uris` property:
Expand Down
18 changes: 14 additions & 4 deletions build/parents/build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,27 @@
<!-- Containers executions tests properties -->
<test.containers.run.skip>false</test.containers.run.skip>

<!-- Lucene tests properties -->

<!-- To skip all Lucene tests from the CLI -->
<test.lucene.skip>false</test.lucene.skip>

<!-- Elasticsearch tests properties -->

<!-- To skip all Elasticsearch tests from the CLI -->
<test.elasticsearch.skip>false</test.elasticsearch.skip>

<!-- Control how an Elasticsearch instance is run automatically during tests -->
<!-- By default, the plugin is not skipped, but each container (elastic, opensearch, etc.) is skipped;
Maven profiles will re-enable the right container depending on configuration.
-->
<test.elasticsearch.run.skip>true</test.elasticsearch.run.skip>

<!-- If an external connection url is defined this property will be true -->
<!-- See elasticsearch-run and elasticsearch-do-not-run profiles -->
<test.elasticsearch.connection.uris.defined></test.elasticsearch.connection.uris.defined>
<!-- This is set to true automatically when the Elasticsearch instance should not be started
even for modules that include Elasticsearch tests,
be it because Elasticsearch tests are disabled
or because an Elasticsearch instance is provided externally.
See elasticsearch-run, elasticsearch-test-skip and elasticsearch-do-not-run profiles -->
<test.elasticsearch.run.skip.forRelevantModules>false</test.elasticsearch.run.skip.forRelevantModules>

<!--
These properties are transparently passed as system properties to integration tests,
Expand Down
17 changes: 15 additions & 2 deletions build/parents/integrationtest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@
</activation>
<properties>
<test.elasticsearch.connection.uris>http://localhost:9200</test.elasticsearch.connection.uris>
<test.elasticsearch.connection.uris.defined>false</test.elasticsearch.connection.uris.defined>
</properties>
</profile>
<!-- Profile enabled when an Elasticsearch instance must NOT be run by Maven -->
Expand All @@ -480,7 +479,21 @@
</property>
</activation>
<properties>
<test.elasticsearch.connection.uris.defined>true</test.elasticsearch.connection.uris.defined>
<test.elasticsearch.run.skip.forRelevantModules>true</test.elasticsearch.run.skip.forRelevantModules>
</properties>
</profile>
<!-- Profile enabled when Elasticsearch tests are skipped -->
<profile>
<id>elasticsearch-test-skip</id>
<activation>
<!-- Activate if test.elasticsearch.connection.uris has been defined explicitly -->
<property>
<name>test.elasticsearch.skip</name>
<value>true</value>
</property>
</activation>
<properties>
<test.elasticsearch.run.skip.forRelevantModules>true</test.elasticsearch.run.skip.forRelevantModules>
</properties>
</profile>

Expand Down
4 changes: 3 additions & 1 deletion documentation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<description>Hibernate Search reference documentation</description>

<properties>
<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
<test.database.run.skip>false</test.database.run.skip>

<asciidoctor.base-output-dir>${project.build.directory}/asciidoctor/</asciidoctor.base-output-dir>
Expand Down Expand Up @@ -128,6 +128,7 @@
<goal>integration-test</goal>
</goals>
<configuration>
<skip>${test.lucene.skip}</skip>
<reportNameSuffix>${surefire.reportNameSuffix}-lucene</reportNameSuffix>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.hibernate.search:hibernate-search-backend-elasticsearch</classpathDependencyExclude>
Expand All @@ -146,6 +147,7 @@
<goal>integration-test</goal>
</goals>
<configuration>
<skip>${test.elasticsearch.skip}</skip>
<reportNameSuffix>${surefire.reportNameSuffix}-elasticsearch</reportNameSuffix>
<classpathDependencyExcludes>
<classpathDependencyExclude>org.hibernate.search:hibernate-search-backend-lucene</classpathDependencyExclude>
Expand Down
3 changes: 2 additions & 1 deletion integrationtest/backend/elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<properties>
<surefire.module>elasticsearch</surefire.module>

<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
</properties>

<dependencies>
Expand Down Expand Up @@ -72,6 +72,7 @@
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.elasticsearch.skip}</skip>
<!-- WARNING: When using <dependenciesToScan>, be sure to set the Maven property surefire.module -->
<dependenciesToScan>
<dependency>${project.groupId}:hibernate-search-integrationtest-backend-tck</dependency>
Expand Down
1 change: 1 addition & 0 deletions integrationtest/backend/lucene/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.lucene.skip}</skip>
<!-- WARNING: When using <dependenciesToScan>, be sure to set the Maven property surefire.module -->
<dependenciesToScan>
<dependency>${project.groupId}:hibernate-search-integrationtest-backend-tck</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<description>Hibernate Search integration tests for Java 11+ modules</description>

<properties>
<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
<test.database.run.skip>false</test.database.run.skip>

<maven.compiler.release>11</maven.compiler.release>
Expand Down Expand Up @@ -89,6 +89,9 @@
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.elasticsearch.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
5 changes: 4 additions & 1 deletion integrationtest/java/modules/orm-elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<description>Hibernate Search integration tests for Java 11+ modules</description>

<properties>
<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
<test.database.run.skip>false</test.database.run.skip>

<maven.compiler.release>11</maven.compiler.release>
Expand Down Expand Up @@ -71,6 +71,9 @@
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.elasticsearch.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
3 changes: 3 additions & 0 deletions integrationtest/java/modules/orm-lucene/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.lucene.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<description>Hibernate Search integration tests for Java 11+ modules</description>

<properties>
<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
<test.database.run.skip>false</test.database.run.skip>

<maven.compiler.release>11</maven.compiler.release>
Expand Down Expand Up @@ -63,6 +63,9 @@
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.elasticsearch.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
3 changes: 3 additions & 0 deletions integrationtest/java/modules/pojo-standalone-lucene/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skip>${test.lucene.skip}</skip>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
2 changes: 1 addition & 1 deletion integrationtest/mapper/orm-batch-jsr352/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<description>Hibernate Search integration tests for the Batch JSR-352 integration</description>

<properties>
<test.elasticsearch.run.skip>${test.elasticsearch.connection.uris.defined}</test.elasticsearch.run.skip>
<test.elasticsearch.run.skip>${test.elasticsearch.run.skip.forRelevantModules}</test.elasticsearch.run.skip>
<test.database.run.skip>false</test.database.run.skip>

<surefire.jvm.args.module>
Expand Down
19 changes: 17 additions & 2 deletions integrationtest/mapper/orm-coordination-outbox-polling/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
</dependenciesToScan>
<includes>
<!-- Include all tests from this module -->
<include>%regex[org/hibernate/search/integrationtest/mapper/orm/coordination/outboxpolling/.*IT\.class]</include>
<include>%regex[org[/\\]hibernate[/\\]search[/\\]integrationtest[/\\]mapper[/\\]orm[/\\]coordination[/\\]outboxpolling[/\\].*IT\.class]</include>
<!-- Include tests from integrationtest-mapper-orm that are related to automatic indexing -->
<include>%regex[org/hibernate/search/integrationtest/mapper/orm/automaticindexing/.*IT\.class]</include>
<include>%regex[org[/\\]hibernate[/\\]search[/\\]integrationtest[/\\]mapper[/\\]orm[/\\]automaticindexing[/\\].*IT\.class]</include>
</includes>
<excludes>
<!-- Exclude tests from integrationtest-mapper-orm that just cannot work with the outbox polling strategy: -->
Expand Down Expand Up @@ -111,4 +111,19 @@
</plugins>
</build>

<profiles>
<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<!-- For some reason these outbox-polling tests don't seem to work on Windows -->
<skipITs>true</skipITs>
</properties>
</profile>
</profiles>

</project>
Loading
Loading