Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
xtermi2 committed Nov 13, 2023
2 parents 4d1d251 + 9dd38e5 commit 9018898
Show file tree
Hide file tree
Showing 43 changed files with 1,100 additions and 314 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ updates:
versions:
- 7.17.x
- 8.x
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
73 changes: 55 additions & 18 deletions .github/workflows/maven-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ on:
paths-ignore:
- '*.md'
schedule:
# * is a special character in YAML so you have to quote this string
# * is a special character in YAML, so you have to quote this string
- cron: '11 16 * * 4'

env:
MVN_CMD: "./mvnw --settings .cicd.settings.xml -e -B -V"
GPG_EXECUTABLE: gpg

jobs:
build-and-test-with-jdk:
build-with-jdk:
strategy:
matrix:
java: [ 8, 11, 17, 18, 19 ]
java: [ 8, 11, 17, 21 ]
fail-fast: false
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
Expand All @@ -37,16 +37,16 @@ jobs:
- name: Build and test with Maven
run: $MVN_CMD install

build-and-test-with-es-version:
build-with-es:
strategy:
matrix:
elasticsearchVersion: [ "8.6.1", "8.5.3", "8.4.3", "8.3.3", "8.2.3", "8.1.3", "8.0.1", "7.17.9", "7.16.3", "7.15.2", "7.14.2",
"7.13.4", "7.12.1", "7.11.2", "7.10.2", "7.9.3", "7.8.1", "7.7.1", "7.6.2", "7.5.2" ]
elasticsearchVersion: [ "8.11.1", "8.10.4", "8.9.2", "8.8.2", "8.7.1", "8.6.2", "8.5.3", "8.4.3", "8.3.3", "8.2.3", "8.1.3", "8.0.1",
"7.17.15", "7.5.2" ]
fail-fast: false
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand All @@ -57,16 +57,53 @@ jobs:
- name: elasticsearch test version ${{ matrix.elasticsearchVersion }}
run: $MVN_CMD --file ./tests/pom.xml clean verify -Delasticsearch.version=${{ matrix.elasticsearchVersion }}

## on github actions Linux containers (LCOW) are not supported:
## https://stackoverflow.com/questions/66077884/testcontainers-in-windows-environment-on-github-actions-could-not-find-a-valid
## https://github.com/actions/runner-images/issues/252
## https://github.com/actions/runner-images/issues/2216
# build-with-windows:
# runs-on: windows-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Set up JDK 8
# uses: actions/setup-java@v3
# with:
# distribution: zulu
# ja# - name: Set up Docker
# uses: crazy-max/ghaction-setup-docker@v1
# with:
# version: 23.0.1va-version: 8
# - name: Build and test with Maven
# run: .\mvnw.cmd --settings .cicd.settings.xml -e -B -V install

# macos builds are very flaky :/
# build-with-macos:
# runs-on: macos-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Set up JDK 8
# uses: actions/setup-java@v3
# with:
# distribution: zulu
# java-version: 8
# - name: Install Docker
# # docker is not installed by default https://github.com/actions/runner-images/issues/17
# uses: docker-practice/actions-setup-docker@master
# timeout-minutes: 12
# - name: Build and test with Maven
# run: $MVN_CMD install

release-dry-run:
# this will just build like the real release job, but not do a release (dry run)
needs: [ build-and-test-with-jdk, build-and-test-with-es-version ]
if: ${{ github.ref != 'refs/heads/release' }}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Import GPG key to sign maven build artifacts
uses: crazy-max/ghaction-import-gpg@v4
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_SECRET_KEYS }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
Expand All @@ -90,14 +127,14 @@ jobs:

release:
# Release to maven central and create Github release
needs: [ build-and-test-with-jdk, build-and-test-with-es-version ]
needs: [ build-with-jdk, build-with-es ]
if: ${{ github.repository == 'senacor/elasticsearch-evolution' && github.event_name == 'push' && github.ref == 'refs/heads/release' }}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Import GPG key to sign maven build artifacts
uses: crazy-max/ghaction-import-gpg@v4
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_SECRET_KEYS }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Quality analysis
name: 'Quality analysis'

on:
push:
Expand All @@ -18,12 +18,12 @@ env:

jobs:
code-analysis:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
COVERALLS_REPO_TOKEN_EXISTS: ${{ secrets.COVERALLS_REPO_TOKEN != '' }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up JDK 8
# build with JDK 8 because of issue https://github.com/trautonen/coveralls-maven-plugin/issues/112
uses: actions/setup-java@v3
Expand All @@ -37,6 +37,12 @@ jobs:
languages: 'java'
- name: Build and test with Maven
run: $MVN_CMD install
- name: upload test results
uses: actions/upload-artifact@v3 # upload test results
if: success() || failure() # run this step even if previous step failed
with:
name: test-results
path: '**/target/*-reports/TEST-*.xml'
- name: Execute Maven coveralls Plugin
if: ${{ env.COVERALLS_REPO_TOKEN_EXISTS == 'true' }}
env:
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Test Report'
on:
workflow_run:
# runs after Quality analysis workflow
workflows: [ 'Quality analysis' ]
types:
- completed
jobs:
report:
runs-on: ubuntu-latest
steps:
- uses: dorny/test-reporter@v1
with:
artifact: test-results
name: JUnit Tests
path: '**/*.xml'
reporter: java-junit
Binary file modified .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Successful executed migration scripts will not be executed again!

## 2 Features

- tested on Java 8, 11, 17, 18 and 19
- runs on Spring-Boot 2.1, 2.2, 2.3, 2.4, 2.5, 2.6 and 2.7 (and of course without Spring-Boot)
- runs on Elasticsearch version 7.5.x - 8.6.x
- tested on Java 8, 11, 17, and 21
- runs on Spring-Boot 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0 and 3.1 (and of course without Spring-Boot)
- runs on Elasticsearch version 7.5.x - 8.11.x
- runs on Opensearch version 1.x and 2.x
- highly configurable (e.g. location(s) of your migration files, migration files format pattern)
- placeholder substitution in migration scripts
Expand All @@ -31,11 +31,12 @@ Successful executed migration scripts will not be executed again!
- ready to use default configuration
- line comments in migration files

| Compatibility | Spring Boot | Elasticsearch | Opensearch |
|----------------------------------|-----------------------------------|----------------------|------------|
| elasticsearch-evolution >= 0.4.0 | 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7 | 7.5.x - 8.6.x | 1.x - 2.x |
| elasticsearch-evolution 0.3.x | 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7 | 7.5.x - 7.17.x | |
| elasticsearch-evolution 0.2.x | 1.5, 2.0, 2.1, 2.2, 2.3, 2.4 | 7.0.x - 7.4.x, 6.8.x | |
| Compatibility | Spring Boot | Elasticsearch | Opensearch |
|----------------------------------|---------------------------------------------|----------------------|------------|
| elasticsearch-evolution >= 0.4.2 | 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1 | 7.5.x - 8.11.x | 1.x - 2.x |
| elasticsearch-evolution >= 0.4.0 | 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7 | 7.5.x - 8.6.x | 1.x - 2.x |
| elasticsearch-evolution 0.3.x | 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7 | 7.5.x - 7.17.x | |
| elasticsearch-evolution 0.2.x | 1.5, 2.0, 2.1, 2.2, 2.3, 2.4 | 7.0.x - 7.4.x, 6.8.x | |

NOTE: When you run on Java 11 and using spring-boot 2.2 or 2.3 and you hit [this issue](https://github.com/ronmamo/reflections/issues/279), you have 2 options:

Expand All @@ -52,7 +53,7 @@ First add the latest version of Elasticsearch-Evolution spring boot starter as a
<dependency>
<groupId>com.senacor.elasticsearch.evolution</groupId>
<artifactId>spring-boot-starter-elasticsearch-evolution</artifactId>
<version>0.4.1</version>
<version>0.4.2</version>
</dependency>
```

Expand All @@ -76,7 +77,7 @@ First add the latest version of Elasticsearch-Evolution core as a dependency:
<dependency>
<groupId>com.senacor.elasticsearch.evolution</groupId>
<artifactId>elasticsearch-evolution-core</artifactId>
<version>0.4.1</version>
<version>0.4.2</version>
</dependency>
```

Expand Down Expand Up @@ -167,7 +168,7 @@ The filename has to follow a pattern:
- followed by a description which can be any text your filesystem supports
- ended with `esMigrationSuffixes` which is by default `.http` and is configurable and case-insensitive.

Elasticsearch-Evolution uses the version for ordering your scripts and enforces strict ordered execution of your scripts. Out-of-Order execution is not supported.
Elasticsearch-Evolution uses the version for ordering your scripts and enforces strict ordered execution of your scripts, by default. Out-of-Order execution is supported, but disabled by default.
Elasticsearch-Evolution interprets the version parts as Integers, so each version part must be between 1 (inclusive) and 2,147,483,647 (inclusive).

Here is an example which indicates the ordering: `1.0.1` &lt; `1.1` &lt; `1.2.1` &lt; (`2.0.0` == `2`).
Expand Down Expand Up @@ -195,6 +196,7 @@ Elasticsearch-Evolution can be configured to your needs:
- **validateOnMigrate** (default=true): Whether to fail when a previously applied migration script has been modified after it was applied.
- **baselineVersion** (default=1.0): Version to use as a baseline. versions lower than it will not be applied.
- **lineSeparator** (default=\n): Line separator, used only temporary between reading raw migration file line-by-line and parsing it later. Only needed for backward compatibility / checksum stability! Should be one of `\n`, `\r` or `\r\n`
- **outOfOrder** (default=false): Allows migrations to be run "out of order". If you already have versions 1.0 and 3.0 applied, and now a version 2.0 is found, it will be applied too instead of being rejected.

### 5.1 Spring Boot

Expand Down Expand Up @@ -289,7 +291,17 @@ ElasticsearchEvolution.configure()

## 6 changelog

### v0.4.2-SNAPSHOT
### v0.4.3

- support out of order migration execution.
- version updates (spring-boot 2.7.17)
- added regression tests against OpenSearch 2.6.0
- drop older Elasticsearch and OpenSearch versions in regression tests. Only test against the last 3 minor versions of the latest major release.
- added regression tests on JDK 21
- added regression tests for spring boot 3.1
- update org.reflections:reflections from 0.9.12 to 0.10.2 [#233](https://github.com/senacor/elasticsearch-evolution/pull/233) thanks @RiVogel

### v0.4.2

- bugfix ([#182](https://github.com/senacor/elasticsearch-evolution/issues/182)): checksum calculation was based on system dependent line separators which lead to different checksums on different operating systems (e.g. windows vs linux). The default is now `\n`. For backward compatibility you can set other line separator via `lineSeparator` config property.
- version updates (spring-boot 2.7.8)
Expand Down
8 changes: 7 additions & 1 deletion elasticsearch-evolution-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.senacor.elasticsearch.evolution</groupId>
<artifactId>elasticsearch-evolution-parent</artifactId>
<version>0.4.2</version>
<version>0.4.3</version>
<relativePath>../</relativePath>
</parent>
<artifactId>elasticsearch-evolution-core</artifactId>
Expand Down Expand Up @@ -105,6 +105,12 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!-- support JDK 21 -->
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ protected MigrationService createMigrationService() {
getRestClient(),
ContentType.parse(getConfig().getDefaultContentType()),
getConfig().getEncoding(),
getConfig().getValidateOnMigrate(),
getConfig().getBaselineVersion());
getConfig().isValidateOnMigrate(),
getConfig().getBaselineVersion(),
getConfig().isOutOfOrder());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ public class ElasticsearchEvolutionConfig {
*/
private String baselineVersion = "1.0";

/**
* Allows migrations to be run “out of order”.
* <p>
* If you already have versions 1.0 and 3.0 applied, and now a version 2.0 is found,
* it will be applied too instead of being rejected.
*/
private boolean outOfOrder = false;

/**
* Loads this configuration into a new ElasticsearchEvolution instance.
*
Expand Down Expand Up @@ -147,11 +155,13 @@ public ElasticsearchEvolutionConfig validate() throws IllegalStateException, Nul
}
requireNotBlank(historyIndex, "historyIndex must not be empty");
requireCondition(historyMaxQuerySize, size -> size > 0, "historyMaxQuerySize value '%s' must be greater than 0", historyMaxQuerySize);
final MigrationVersion baseline;
try {
MigrationVersion.fromVersion(baselineVersion);
baseline = MigrationVersion.fromVersion(baselineVersion);
} catch (RuntimeException e) {
throw new IllegalArgumentException("baselineVersion is invalid", e);
}
requireCondition(baseline, version -> version.isAtLeast("1"), "baselineVersion '%s' must be at least 1", baseline);
}
return this;
}
Expand Down Expand Up @@ -273,7 +283,15 @@ public ElasticsearchEvolutionConfig setHistoryMaxQuerySize(int historyMaxQuerySi
return this;
}

/**
* @deprecated use {@link #isValidateOnMigrate()} instead
*/
@Deprecated
public boolean getValidateOnMigrate() {
return isValidateOnMigrate();
}

public boolean isValidateOnMigrate() {
return validateOnMigrate;
}

Expand All @@ -291,6 +309,15 @@ public ElasticsearchEvolutionConfig setBaselineVersion(String baselineVersion) {
return this;
}

public boolean isOutOfOrder() {
return outOfOrder;
}

public ElasticsearchEvolutionConfig setOutOfOrder(boolean outOfOrder) {
this.outOfOrder = outOfOrder;
return this;
}

@Override
public String toString() {
return "ElasticsearchEvolutionConfig{" +
Expand All @@ -309,6 +336,7 @@ public String toString() {
", historyMaxQuerySize=" + historyMaxQuerySize +
", validateOnMigrate=" + validateOnMigrate +
", baselineVersion='" + baselineVersion + '\'' +
", outOfOrder='" + outOfOrder + '\'' +
'}';
}
}
Loading

0 comments on commit 9018898

Please sign in to comment.