diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..86a63dc --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..ae7194d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,10 @@ +# Auto detect text files and perform LF normalization +* text=auto +*.txt text +*.sh text eol=lf +*.html text eol=lf diff=html +*.css text eol=lf +*.js text eol=lf +*.jpg -text +*.pdf -text +*.java text diff=java diff --git a/.github/workflows/branch-ci.yml b/.github/workflows/branch-ci.yml new file mode 100644 index 0000000..5787348 --- /dev/null +++ b/.github/workflows/branch-ci.yml @@ -0,0 +1,37 @@ +name: Branch CI + +on: + push: + paths-ignore: + - '.github/workflows/**' + - '*.md' + - '*.txt' + branches-ignore: + - 'release*' + +jobs: + build: + name: Branch CI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: zulu + server-id: github + server-username: GITHUB_ACTOR + server-password: GITHUB_TOKEN + - name: Maven Build + run: mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true -B -V + env: + GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }} + - name: Maven Verify + run: mvn verify -B diff --git a/.github/workflows/pre-release-ci.yml b/.github/workflows/pre-release-ci.yml new file mode 100644 index 0000000..5221d62 --- /dev/null +++ b/.github/workflows/pre-release-ci.yml @@ -0,0 +1,59 @@ +name: Pre-release CI + +on: + release: + types: [ prereleased ] + +jobs: + build: + name: Pre-release CI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Set up Java for publishing to GitHub Packages + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: zulu + server-id: github + server-username: GITHUB_ACTOR + server-password: GITHUB_TOKEN + - name: Deploy pre-release version to GitHub Packages + run: | + pre_release_version=${{ github.event.release.tag_name }} + echo Pre-release version $pre_release_version + mvn versions:set -DnewVersion=$pre_release_version -DgenerateBackupPoms=false + mvn versions:commit + mvn clean deploy -Pdeploy2Github -B -V + env: + GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }} + - name: Set up Java for publishing to Maven Central Repository + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: zulu + server-id: central + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE + - name: Deploy pre-release version to Maven Central Repository + run: | + pre_release_version=${{ github.event.release.tag_name }} + echo Pre-release version $pre_release_version + mvn versions:set -DnewVersion=$pre_release_version -DgenerateBackupPoms=false + mvn versions:commit + mvn deploy -Pdeploy2Maven -DskipTests -B -V + env: + MAVEN_USERNAME: ${{ secrets.SONATYPE_CENTRAL_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + - name: Rollback pre-release (remove tag) + if: failure() + run: git push origin :refs/tags/${{ github.event.release.tag_name }} diff --git a/.github/workflows/release-ci.yml b/.github/workflows/release-ci.yml new file mode 100644 index 0000000..b2216dc --- /dev/null +++ b/.github/workflows/release-ci.yml @@ -0,0 +1,82 @@ +name: Release CI + +on: + release: + types: [ released ] + +jobs: + build: + name: Release CI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: git checkout ${{ github.event.release.target_commitish }} + - uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Set up Java for publishing to GitHub Packages + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: zulu + server-id: github + server-username: GITHUB_ACTOR + server-password: GITHUB_TOKEN + - name: Maven Build + run: mvn clean install -DskipTests=true -B -V + env: + GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }} + - name: Maven Verify + run: mvn verify -B + - name: Configure git + run: | + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git config --global user.name "${GITHUB_ACTOR}" + - name: Prepare release + id: prepare_release + run: | + mvn -B build-helper:parse-version release:prepare \ + -DreleaseVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.incrementalVersion} \ + -Darguments="-DskipTests=true" + echo release_tag=$(git describe --tags --abbrev=0) >> $GITHUB_OUTPUT + - name: Perform release to GitHub Packages + run: mvn -B release:perform -Pdeploy2Github -Darguments="-DskipTests=true -Pdeploy2Github" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }} + - name: Set up Java for publishing to Maven Central Repository + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: zulu + server-id: central + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE + - name: Deploy release version to Maven Central Repository + run: | + release_version=$(echo ${{ steps.prepare_release.outputs.release_tag }} | sed "s/release-//") + echo release version $release_version + mvn versions:set -DnewVersion=$release_version -DgenerateBackupPoms=false + mvn versions:commit + mvn deploy -Pdeploy2Maven -DskipTests -B -V + env: + MAVEN_USERNAME: ${{ secrets.SONATYPE_CENTRAL_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + - name: Rollback release + if: failure() + run: | + mvn release:rollback || echo "nothing to rollback" + git push origin :refs/tags/${{ github.event.release.tag_name }} + if [ ! -z "${{ steps.prepare_release.outputs.release_tag }}" ] + then + git tag -d ${{ steps.prepare_release.outputs.release_tag }} + git push origin :refs/tags/${{ steps.prepare_release.outputs.release_tag }} + fi diff --git a/.gitignore b/.gitignore index 524f096..4be3a6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,24 +1,14 @@ -# Compiled class file -*.class - -# Log file +.* +!.gitignore +!.gitattributes +!.github +!.editorconfig +!.*.yml +!.env.example +**/target/ +*.iml +**/logs/*.log +*.db +*.csv *.log - -# BlueJ files -*.ctxt - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* -replay_pid* +!.helmignore diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..f43e7a0 --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,17 @@ +extends: default +rules: + document-start: + present: false + truthy: disable + comments: + min-spaces-from-content: 1 + line-length: + max: 150 + braces: + min-spaces-inside: 0 + max-spaces-inside: 0 + brackets: + min-spaces-inside: 0 + max-spaces-inside: 0 + indentation: + indent-sequences: consistent diff --git a/LICENSE b/LICENSE.txt similarity index 99% rename from LICENSE rename to LICENSE.txt index 261eeb9..d645695 100644 --- a/LICENSE +++ b/LICENSE.txt @@ -1,3 +1,4 @@ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ diff --git a/checkstyle-suppressions.xml b/checkstyle-suppressions.xml new file mode 100644 index 0000000..dbd0fdb --- /dev/null +++ b/checkstyle-suppressions.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..7bb5350 --- /dev/null +++ b/pom.xml @@ -0,0 +1,149 @@ + + 4.0.0 + + + io.scalecube + scalecube-parent + 0.3.12 + + + scalecube-test-support + 0.1.0-SNAPSHOT + ${project.artifactId} + + + + github + GitHub Packages + https://maven.pkg.github.com/scalecube/packages + + false + + + + + false + + oss.jfrog + jfrog + https://oss.jfrog.org/libs-release + + + + false + + bintray + bintray + https://jcenter.bintray.com + + + + false + + central + central + https://repo1.maven.org + + + + + https://github.com/scalecube/scalecube-test-support + scm:git:https://github.com/scalecube/scalecube-test-support.git + scm:git:https://github.com/scalecube/scalecube-test-support.git + + HEAD + + + + 5.13.4 + 5.19.0 + 1.3 + 2024.0.8 + 1.7.36 + 2.17.2 + + https://maven.pkg.github.com/scalecube/scalecube-test-support + + checkstyle-suppressions.xml + + + + + + + io.projectreactor + reactor-bom + ${reactor.version} + pom + import + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.apache.logging.log4j + log4j-bom + ${log4j.version} + pom + import + + + + + org.junit + junit-bom + ${junit.version} + pom + import + + + org.mockito + mockito-core + ${mockito.version} + + + org.mockito + mockito-junit-jupiter + ${mockito.version} + + + + + + + org.junit.jupiter + junit-jupiter-api + + + org.junit.jupiter + junit-jupiter-engine + + + org.junit.jupiter + junit-jupiter-params + + + io.projectreactor + reactor-test + + + org.slf4j + slf4j-api + + + org.apache.logging.log4j + log4j-slf4j-impl + + + org.apache.logging.log4j + log4j-core + + + + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..bd6f234 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests==2.32.4 diff --git a/src/main/java/io/scalecube/test/support/LoggingExtension.java b/src/main/java/io/scalecube/test/support/LoggingExtension.java new file mode 100644 index 0000000..9ced2ab --- /dev/null +++ b/src/main/java/io/scalecube/test/support/LoggingExtension.java @@ -0,0 +1,51 @@ +package io.scalecube.test.support; + +import java.lang.reflect.Method; +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A JUnit5 Extension, merely writes the test's name at start and finish. Make sure to start JAVA + * with -Djunit.jupiter.extensions.autodetection.enabled=true to activate this + * extension + */ +public class LoggingExtension + implements AfterEachCallback, BeforeEachCallback, AfterAllCallback, BeforeAllCallback { + + private static final Logger LOGGER = LoggerFactory.getLogger(LoggingExtension.class); + + @Override + public void beforeAll(ExtensionContext context) { + LOGGER.info( + "***** Setup: {} *****", context.getTestClass().map(Class::getSimpleName).orElse("")); + } + + @Override + public void afterEach(ExtensionContext context) { + LOGGER.info( + "***** Test finished: {}.{}.{} *****", + context.getTestClass().map(Class::getSimpleName).orElse(""), + context.getTestMethod().map(Method::getName).orElse(""), + context.getDisplayName()); + } + + @Override + public void beforeEach(ExtensionContext context) { + LOGGER.info( + "***** Test started: {}.{}.{} *****", + context.getTestClass().map(Class::getSimpleName).orElse(""), + context.getTestMethod().map(Method::getName).orElse(""), + context.getDisplayName()); + } + + @Override + public void afterAll(ExtensionContext context) { + LOGGER.info( + "***** TearDown: {} *****", context.getTestClass().map(Class::getSimpleName).orElse("")); + } +} diff --git a/src/main/resources/META-INF/services/org.junit.jupiter.api.extension.Extension b/src/main/resources/META-INF/services/org.junit.jupiter.api.extension.Extension new file mode 100644 index 0000000..0d8d261 --- /dev/null +++ b/src/main/resources/META-INF/services/org.junit.jupiter.api.extension.Extension @@ -0,0 +1 @@ +io.scalecube.test.support.LoggingExtension diff --git a/src/main/resources/junit-platform.properties b/src/main/resources/junit-platform.properties new file mode 100644 index 0000000..6efc0d5 --- /dev/null +++ b/src/main/resources/junit-platform.properties @@ -0,0 +1 @@ +junit.jupiter.extensions.autodetection.enabled=true diff --git a/src/test/java/io/scalecube/test/support/SampleTest.java b/src/test/java/io/scalecube/test/support/SampleTest.java new file mode 100644 index 0000000..ae1684c --- /dev/null +++ b/src/test/java/io/scalecube/test/support/SampleTest.java @@ -0,0 +1,11 @@ +package io.scalecube.test.support; + +import org.junit.jupiter.api.Test; + +public class SampleTest { + + @Test + public void doNothing() { + // ignore + } +} diff --git a/src/test/resources/log4j2-test.xml b/src/test/resources/log4j2-test.xml new file mode 100644 index 0000000..2b87667 --- /dev/null +++ b/src/test/resources/log4j2-test.xml @@ -0,0 +1,20 @@ + + + + + %level{length=1} %d{ISO8601} %c{1.} %m [%t]%n + + + + + + + + + + + + + + +