diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67b4785..17696d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,9 @@ -# Copyright 2021 EPAM Systems +# Copyright 2022 EPAM Systems # Licensed 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 +# https://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, @@ -19,9 +19,9 @@ on: - '*' - '!master' paths-ignore: - - README.md - - README_TEMPLATE.md - - CHANGELOG.md + - README.md + - README_TEMPLATE.md + - CHANGELOG.md pull_request: branches: @@ -33,18 +33,17 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v3 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 + - name: Set up JDK 1.8 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '8' - - name: Grant execute permission for gradlew - run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew build - - name: Build with Gradle - run: ./gradlew build - - - name: Codecov upload - run: bash <(curl -s https://codecov.io/bash) + - name: Codecov upload + run: bash <(curl -s https://codecov.io/bash) diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml index 8d63ab8..1780720 100644 --- a/.github/workflows/promote.yml +++ b/.github/workflows/promote.yml @@ -53,7 +53,7 @@ jobs: jar -cvf ${BUNDLE_FILE} "${files[@]}" echo 'Bundle upload' - curl -u ${{ secrets.SONATYPE_USER }}:${{ secrets.SONATYPE_PASSWORD }} -L \ + curl -f -u ${{ secrets.SONATYPE_USER }}:${{ secrets.SONATYPE_PASSWORD }} -L \ --request POST '${{ env.UPSTREAM_REPOSITORY_URL }}/service/local/staging/bundle_upload' \ --form "file=@${BUNDLE_FILE}" >response.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d11a746..0633b18 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,9 @@ -# Copyright 2021 EPAM Systems +# Copyright 2022 EPAM Systems # Licensed 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 +# https://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, @@ -18,17 +18,17 @@ on: branches: - master paths-ignore: + - '.github/**' - README.md - README_TEMPLATE.md - - gradle.properties - CHANGELOG.md env: VERSION_FILE: gradle.properties VERSION_EXTRACT_PATTERN: '(?<=version=).+' - REPOSITORY_URL: 'https://maven.pkg.github.com/' CHANGE_LOG_FILE: CHANGELOG.md CHANGE_LOG_TMP_FILE: CHANGELOG_updated.md + REPOSITORY_URL: 'https://maven.pkg.github.com/' README_FILE: README.md README_TEMPLATE_FILE: README_TEMPLATE.md README_VERSION_PLACEHOLDER: $LATEST_VERSION @@ -38,25 +38,23 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Generate versions - uses: HardNorth/github-version-generate@v1.1.1 + uses: HardNorth/github-version-generate@v1 with: version-source: file version-file: ${{ env.VERSION_FILE }} version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }} - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + uses: actions/setup-java@v3 with: - java-version: 1.8 - - - name: Grant execute permission for gradlew - run: chmod +x gradlew + distribution: 'temurin' + java-version: '8' - name: Setup git credentials - uses: oleksiyrudenko/gha-git-credentials@v2 + uses: oleksiyrudenko/gha-git-credentials@v2.1.1 with: name: 'reportportal.io' email: 'support@reportportal.io' @@ -68,16 +66,13 @@ jobs: ./gradlew release -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${{ env.RELEASE_VERSION }} \ -Prelease.newVersion=${{ env.NEXT_VERSION }} -PpublishRepo=${{ env.REPOSITORY_URL }}${{ github.repository }} \ -PgithubUserName=${{ github.actor }} -PgithubToken=${{ secrets.GITHUB_TOKEN }} \ - -PgpgPassphrase=${{ secrets.GPG_PASSPHRASE }} -PgpgPrivateKey="$(cat <<'EOF' - ${{ secrets.GPG_PRIVATE_KEY }} - EOF - )" + -PgpgPassphrase=${{ secrets.GPG_PASSPHRASE }} -PgpgPrivateKey="${{ secrets.GPG_PRIVATE_KEY }}" - name: Update README.md id: readmeUpdate run: | - sed 's/${{env.README_VERSION_PLACEHOLDER}}/${{env.RELEASE_VERSION}}/g' ${{env.README_TEMPLATE_FILE}} > ${{env.README_FILE}} - git add ${{env.README_FILE}} + sed 's/${{ env.README_VERSION_PLACEHOLDER }}/${{ env.RELEASE_VERSION }}/g' ${{ env.README_TEMPLATE_FILE }} > ${{ env.README_FILE }} + git add ${{ env.README_FILE }} git commit -m "Readme update" - name: Update CHANGELOG.md @@ -96,35 +91,29 @@ jobs: - name: Read changelog Entry id: readChangelogEntry - uses: mindsers/changelog-reader-action@v1.3.1 + uses: mindsers/changelog-reader-action@v2 with: version: ${{ env.RELEASE_VERSION }} path: ./${{ env.CHANGE_LOG_FILE }} - name: Create Release id: createRelease - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: ncipollo/release-action@v1 with: - tag_name: ${{ env.RELEASE_VERSION }} - release_name: Release ${{ env.RELEASE_VERSION }} - body: ${{ steps.readChangelogEntry.outputs.log_entry }} - draft: false - prerelease: false + tag: ${{ env.RELEASE_VERSION }} + name: Release ${{ env.RELEASE_VERSION }} + body: ${{ steps.readChangelogEntry.outputs.changes }} - name: Checkout develop branch - if: ${{ github.ref }} == 'master' - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: 'develop' fetch-depth: 0 - name: Merge release branch into develop id: mergeIntoDevelop - if: ${{ github.ref }} == 'master' run: | git merge -m 'Merge master branch into develop after a release' origin/master git status | (! grep -Fq 'both modified:') || git status | grep -F 'both modified:' \ | { echo -e 'Unable to merge master into develop, merge conflicts:'; (! grep -Eo '[^ ]+$') } - git push + git push origin develop diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c46025..04df51e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## [Unreleased] +### Changed +- Client version updated on [5.1.16](https://github.com/reportportal/client-java/releases/tag/5.1.16), by @HardNorth +- `NodeInfoUtils` class refactored to not use synchronized Map, by @HardNorth ## [5.1.0] ### Added diff --git a/README.md b/README.md index 4500c28..4ff075e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/agent-java-spock.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.epam.reportportal%22%20AND%20a:%22agent-java-spock%22) [![CI Build](https://github.com/reportportal/agent-java-spock/actions/workflows/ci.yml/badge.svg)](https://github.com/reportportal/agent-java-spock/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/reportportal/agent-java-spock/branch/develop/graph/badge.svg?token=Vnk338Rigx)](https://codecov.io/gh/reportportal/agent-java-spock) -[![Join Slack chat!](https://reportportal-slack-auto.herokuapp.com/badge.svg)](https://reportportal-slack-auto.herokuapp.com) +[![Join Slack chat!](https://slack.epmrpp.reportportal.io/badge.svg)](https://slack.epmrpp.reportportal.io/) [![stackoverflow](https://img.shields.io/badge/reportportal-stackoverflow-orange.svg?style=flat)](http://stackoverflow.com/questions/tagged/reportportal) [![Build with Love](https://img.shields.io/badge/build%20with-❤%EF%B8%8F%E2%80%8D-lightgrey.svg)](http://reportportal.io?style=flat) diff --git a/README_TEMPLATE.md b/README_TEMPLATE.md index 2f5329d..0bc83b7 100644 --- a/README_TEMPLATE.md +++ b/README_TEMPLATE.md @@ -7,7 +7,7 @@ [![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/agent-java-spock.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.epam.reportportal%22%20AND%20a:%22agent-java-spock%22) [![CI Build](https://github.com/reportportal/agent-java-spock/actions/workflows/ci.yml/badge.svg)](https://github.com/reportportal/agent-java-spock/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/reportportal/agent-java-spock/branch/develop/graph/badge.svg?token=Vnk338Rigx)](https://codecov.io/gh/reportportal/agent-java-spock) -[![Join Slack chat!](https://reportportal-slack-auto.herokuapp.com/badge.svg)](https://reportportal-slack-auto.herokuapp.com) +[![Join Slack chat!](https://slack.epmrpp.reportportal.io/badge.svg)](https://slack.epmrpp.reportportal.io/) [![stackoverflow](https://img.shields.io/badge/reportportal-stackoverflow-orange.svg?style=flat)](http://stackoverflow.com/questions/tagged/reportportal) [![Build with Love](https://img.shields.io/badge/build%20with-❤%EF%B8%8F%E2%80%8D-lightgrey.svg)](http://reportportal.io?style=flat) diff --git a/build.gradle b/build.gradle index 19e6780..7edb195 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ repositories { } dependencies { - api "com.epam.reportportal:client-java:5.1.11" + api "com.epam.reportportal:client-java:5.1.16" api "com.epam.reportportal:commons-model:5.0.0" api "org.spockframework:spock-core:${spock_version}" api 'com.google.code.findbugs:jsr305:3.0.2' @@ -54,7 +54,7 @@ dependencies { testImplementation "org.mockito:mockito-inline:${mockito_version}" testImplementation "org.mockito:mockito-junit-jupiter:${mockito_version}" testImplementation 'ch.qos.logback:logback-classic:1.2.11' - testImplementation 'com.epam.reportportal:logger-java-logback:5.1.1' + testImplementation 'com.epam.reportportal:logger-java-logback:5.1.3' testImplementation ("org.junit.platform:junit-platform-runner:${junit5_launcher_version}") { exclude module: 'junit' } diff --git a/src/main/java/com/epam/reportportal/spock/NodeInfoUtils.java b/src/main/java/com/epam/reportportal/spock/NodeInfoUtils.java index 1aeac67..b5f0d6d 100644 --- a/src/main/java/com/epam/reportportal/spock/NodeInfoUtils.java +++ b/src/main/java/com/epam/reportportal/spock/NodeInfoUtils.java @@ -15,21 +15,20 @@ */ package com.epam.reportportal.spock; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Strings; -import com.google.common.collect.Iterables; -import com.google.common.collect.Maps; +import org.apache.commons.lang3.StringUtils; import org.spockframework.runtime.model.*; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.IntStream; import static java.lang.String.format; -import static java.util.Collections.synchronizedMap; +import static java.util.Optional.ofNullable; import static org.spockframework.runtime.model.BlockKind.WHERE; /** @@ -39,24 +38,16 @@ * @author Dzmitry Mikhievich */ final class NodeInfoUtils { - - @VisibleForTesting static final String INHERITED_FIXTURE_NAME_TEMPLATE = "%s:%s"; private static final String LINE_SEPARATOR = System.getProperty("line.separator"); private static final String BLOCK_SPLITTER = ": "; private static final String CONJUNCTION_KEYWORD = "And"; - private static final Map BLOCK_NAMES = synchronizedMap(Maps.newEnumMap(BlockKind.class)); + private static final Map BLOCK_NAMES = new ConcurrentHashMap<>(); - private static final Predicate SKIP_BLOCK_CONDITION = info -> { - if (info != null) { - boolean isWhereBlock = WHERE.equals(info.getKind()); - if (isWhereBlock) { - return Iterables.all(info.getTexts(), Strings::isNullOrEmpty); - } - } - return false; - }; + private static final Predicate SKIP_BLOCK_CONDITION = info -> ofNullable(info).filter(i -> WHERE.equals(i.getKind())) + .map(i -> i.getTexts().stream().allMatch(StringUtils::isBlank)) + .orElse(Boolean.FALSE); private NodeInfoUtils() { } @@ -128,7 +119,7 @@ private static String unrollIterationDescription(IterationInfo iterationInfo, St Object[] dataValues = iterationInfo.getDataValues(); if (!parameterNames.isEmpty() && dataValues != null) { iterationDescription += "\n" + IntStream.range(0, parameterNames.size()) - .mapToObj(i -> parameterNames.get(i) + ": " + String.valueOf(dataValues[i])) + .mapToObj(i -> parameterNames.get(i) + ": " + dataValues[i]) .collect(Collectors.joining("; ")); } @@ -144,7 +135,10 @@ private static void appendBlockInfo(StringBuilder featureDescription, BlockInfo } // append conjunction blocks while (textsIterator.hasNext()) { - featureDescription.append(LINE_SEPARATOR).append(CONJUNCTION_KEYWORD).append(BLOCK_SPLITTER).append(textsIterator.next()); + featureDescription.append(LINE_SEPARATOR) + .append(CONJUNCTION_KEYWORD) + .append(BLOCK_SPLITTER) + .append(textsIterator.next()); } } @@ -155,20 +149,9 @@ private static void appendBlockInfo(StringBuilder featureDescription, BlockInfo * @return capitalized block kind name */ private static String formatBlockKind(BlockKind blockKind) { - if (BLOCK_NAMES.containsKey(blockKind)) { - return BLOCK_NAMES.get(blockKind); - } else { - char[] initialChars = blockKind.name().toCharArray(); - char[] buffer = new char[initialChars.length]; - buffer[0] = initialChars[0]; - // iterate over characters excluding the first one - for (int i = 1; i < initialChars.length; i++) { - char ch = initialChars[i]; - buffer[i] = Character.toLowerCase(ch); - } - String blockName = new String(buffer); - BLOCK_NAMES.put(blockKind, blockName); - return blockName; - } + return BLOCK_NAMES.computeIfAbsent(blockKind, b -> { + String blockName = b.name(); + return blockName.charAt(0) + blockName.substring(1).toLowerCase(Locale.US); + }); } } diff --git a/src/test/groovy/com/epam/reportportal/spock/fixtures/TestParametersSetupFixtureFailureIntegrity.java b/src/test/groovy/com/epam/reportportal/spock/fixtures/TestParametersSetupFixtureFailureIntegrity.java index 17d467b..7f54e1c 100644 --- a/src/test/groovy/com/epam/reportportal/spock/fixtures/TestParametersSetupFixtureFailureIntegrity.java +++ b/src/test/groovy/com/epam/reportportal/spock/fixtures/TestParametersSetupFixtureFailureIntegrity.java @@ -103,7 +103,10 @@ public void verify_setup_fixture_failure_correct_reporting_parameterized_feature finishNestedItems.forEach(i -> assertThat(i.getEndTime(), notNullValue())); finishNestedItems.stream() .filter(i -> ItemStatus.SKIPPED.name().equals(i.getStatus())) - .forEach(i -> assertThat(i.getIssue(), sameInstance(Launch.NOT_ISSUE))); + .forEach(i -> { + assertThat(i.getIssue(), notNullValue()); + assertThat(i.getIssue().getIssueType(), equalTo(Launch.NOT_ISSUE.getIssueType())); + }); ArgumentCaptor finishCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class); verify(client).finishTestItem(eq(methodId), finishCaptor.capture()); diff --git a/src/test/groovy/com/epam/reportportal/spock/fixtures/TestSetupFixtureFailureIntegrity.java b/src/test/groovy/com/epam/reportportal/spock/fixtures/TestSetupFixtureFailureIntegrity.java index 1bceea3..1f430c3 100644 --- a/src/test/groovy/com/epam/reportportal/spock/fixtures/TestSetupFixtureFailureIntegrity.java +++ b/src/test/groovy/com/epam/reportportal/spock/fixtures/TestSetupFixtureFailureIntegrity.java @@ -82,7 +82,10 @@ public void verify_setup_fixture_failure_correct_reporting() { finishItems.forEach(i -> assertThat(i.getEndTime(), notNullValue())); finishItems.stream() .filter(i -> ItemStatus.SKIPPED.name().equals(i.getStatus())) - .forEach(i -> assertThat(i.getIssue(), sameInstance(Launch.NOT_ISSUE))); + .forEach(i -> { + assertThat(i.getIssue(), notNullValue()); + assertThat(i.getIssue().getIssueType(), equalTo(Launch.NOT_ISSUE.getIssueType())); + }); verify(client).finishTestItem(eq(classId), any()); //noinspection unchecked diff --git a/src/test/groovy/com/epam/reportportal/spock/fixtures/TestSetupSpecFixtureFailureIntegrity.java b/src/test/groovy/com/epam/reportportal/spock/fixtures/TestSetupSpecFixtureFailureIntegrity.java index 489c071..10e95a8 100644 --- a/src/test/groovy/com/epam/reportportal/spock/fixtures/TestSetupSpecFixtureFailureIntegrity.java +++ b/src/test/groovy/com/epam/reportportal/spock/fixtures/TestSetupSpecFixtureFailureIntegrity.java @@ -81,7 +81,10 @@ public void verify_setup_spec_failure_correct_reporting() { finishItems.forEach(i -> assertThat(i.getEndTime(), notNullValue())); finishItems.stream() .filter(i -> ItemStatus.SKIPPED.name().equals(i.getStatus())) - .forEach(i -> assertThat(i.getIssue(), sameInstance(Launch.NOT_ISSUE))); + .forEach(i -> { + assertThat(i.getIssue(), notNullValue()); + assertThat(i.getIssue().getIssueType(), equalTo(Launch.NOT_ISSUE.getIssueType())); + }); ArgumentCaptor finishSpecCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class); verify(client).finishTestItem(eq(classId), finishSpecCaptor.capture()); diff --git a/src/test/groovy/com/epam/reportportal/spock/fixtures/TestSetupSpecFixtureFailureParametersUnrollIntegrity.java b/src/test/groovy/com/epam/reportportal/spock/fixtures/TestSetupSpecFixtureFailureParametersUnrollIntegrity.java index a038f28..6238d2d 100644 --- a/src/test/groovy/com/epam/reportportal/spock/fixtures/TestSetupSpecFixtureFailureParametersUnrollIntegrity.java +++ b/src/test/groovy/com/epam/reportportal/spock/fixtures/TestSetupSpecFixtureFailureParametersUnrollIntegrity.java @@ -82,7 +82,10 @@ public void verify_setup_spec_failure_parameters_unroll_correct_reporting() { finishItems.forEach(i -> assertThat(i.getEndTime(), notNullValue())); finishItems.stream() .filter(i -> ItemStatus.SKIPPED.name().equals(i.getStatus())) - .forEach(i -> assertThat(i.getIssue(), sameInstance(Launch.NOT_ISSUE))); + .forEach(i -> { + assertThat(i.getIssue(), notNullValue()); + assertThat(i.getIssue().getIssueType(), equalTo(Launch.NOT_ISSUE.getIssueType())); + }); ArgumentCaptor finishSpecCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class); verify(client).finishTestItem(eq(classId), finishSpecCaptor.capture()); diff --git a/src/test/groovy/com/epam/reportportal/spock/fixtures/TestUnrollParametersSetupFixtureFailureIntegrity.java b/src/test/groovy/com/epam/reportportal/spock/fixtures/TestUnrollParametersSetupFixtureFailureIntegrity.java index 14e0488..d021481 100644 --- a/src/test/groovy/com/epam/reportportal/spock/fixtures/TestUnrollParametersSetupFixtureFailureIntegrity.java +++ b/src/test/groovy/com/epam/reportportal/spock/fixtures/TestUnrollParametersSetupFixtureFailureIntegrity.java @@ -46,7 +46,9 @@ public class TestUnrollParametersSetupFixtureFailureIntegrity { private final String classId = CommonUtils.namedId("class_"); - private final List methodIds = Stream.generate(() -> CommonUtils.namedId("method_")).limit(6).collect(Collectors.toList()); + private final List methodIds = Stream.generate(() -> CommonUtils.namedId("method_")) + .limit(6) + .collect(Collectors.toList()); private final ReportPortalClient client = mock(ReportPortalClient.class); @@ -54,7 +56,11 @@ public class TestUnrollParametersSetupFixtureFailureIntegrity { public void setupMock() { TestUtils.mockLaunch(client, null, classId, methodIds); TestUtils.mockBatchLogging(client); - TestExtension.listener = new ReportPortalSpockListener(ReportPortal.create(client, standardParameters(), testExecutor())); + TestExtension.listener = new ReportPortalSpockListener(ReportPortal.create( + client, + standardParameters(), + testExecutor() + )); } @Test @@ -91,9 +97,10 @@ public void verify_setup_fixture_failure_correct_reporting_unrolled_feature() { ItemStatus.SKIPPED.name() )); finishItems.forEach(i -> assertThat(i.getEndTime(), notNullValue())); - finishItems.stream() - .filter(i -> ItemStatus.SKIPPED.name().equals(i.getStatus())) - .forEach(i -> assertThat(i.getIssue(), sameInstance(Launch.NOT_ISSUE))); + finishItems.stream().filter(i -> ItemStatus.SKIPPED.name().equals(i.getStatus())).forEach(i -> { + assertThat(i.getIssue(), notNullValue()); + assertThat(i.getIssue().getIssueType(), equalTo(Launch.NOT_ISSUE.getIssueType())); + }); verify(client).finishTestItem(eq(classId), any()); //noinspection unchecked