Skip to content

Commit

Permalink
Merge pull request #38 from reportportal/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
HardNorth authored Mar 20, 2023
2 parents 8e0347b + c56b89d commit a345a2c
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 96 deletions.
33 changes: 16 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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:
Expand All @@ -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)
2 changes: 1 addition & 1 deletion .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 20 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand All @@ -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: '[email protected]'
Expand All @@ -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
Expand All @@ -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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion README_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
}
Expand Down
51 changes: 17 additions & 34 deletions src/main/java/com/epam/reportportal/spock/NodeInfoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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<BlockKind, String> BLOCK_NAMES = synchronizedMap(Maps.newEnumMap(BlockKind.class));
private static final Map<BlockKind, String> BLOCK_NAMES = new ConcurrentHashMap<>();

private static final Predicate<BlockInfo> 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<BlockInfo> 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() {
}
Expand Down Expand Up @@ -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("; "));
}

Expand All @@ -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());
}
}

Expand All @@ -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);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<FinishTestItemRQ> finishCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
verify(client).finishTestItem(eq(methodId), finishCaptor.capture());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<FinishTestItemRQ> finishSpecCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
verify(client).finishTestItem(eq(classId), finishSpecCaptor.capture());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<FinishTestItemRQ> finishSpecCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
verify(client).finishTestItem(eq(classId), finishSpecCaptor.capture());
Expand Down
Loading

0 comments on commit a345a2c

Please sign in to comment.