Skip to content

Commit

Permalink
Merge pull request #20 from reportportal/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
HardNorth authored Jan 6, 2023
2 parents 89d0213 + 0a56845 commit 864df61
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 102 deletions.
36 changes: 19 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 @@ -16,31 +16,33 @@ name: CI Build
on:
push:
branches:
- '*'
- '!main'
- '*'
- '!main'
paths-ignore:
- README.md
- README_TEMPLATE.md
- CHANGELOG.md
- README.md
- README_TEMPLATE.md
- CHANGELOG.md

pull_request:
branches:
- main
- main

jobs:
build:
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: 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)
41 changes: 19 additions & 22 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:
- main
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,22 +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.2.0
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
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 @@ -70,8 +71,8 @@ jobs:
- 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 @@ -90,25 +91,21 @@ 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
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: 'develop'
fetch-depth: 0
Expand All @@ -119,4 +116,4 @@ jobs:
git merge -m 'Merge main branch into develop after a release' origin/main
git status | (! grep -Fq 'both modified:') || git status | grep -F 'both modified:' \
| { echo -e 'Unable to merge main into develop, merge conflicts:'; (! grep -Eo '[^ ]+$') }
git push
git push origin develop
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog

## [Unreleased]
### Fixed
- Common field duplication in child class, by @HardNorth
### Changed
- Client version updated on [5.1.15](https://github.com/reportportal/client-java/releases/tag/5.1.15), by @HardNorth
- Some refactoring, by @HardNorth
- `utils-java-formatting` library version updated on version [5.1.4](https://github.com/reportportal/utils-java-formatting/releases/tag/5.1.4), by @HardNorth

## [5.2.1]
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/logger-java-rest-assured.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.epam.reportportal%22%20AND%20a:%22logger-java-rest-assured%22)
[![CI Build](https://github.com/reportportal/logger-java-rest-assured/actions/workflows/ci.yml/badge.svg)](https://github.com/reportportal/logger-java-rest-assured/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/reportportal/logger-java-rest-assured/branch/develop/graph/badge.svg?token=W3MTDF607A)](https://codecov.io/gh/reportportal/logger-java-rest-assured)
[![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 @@ -3,7 +3,7 @@
[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/logger-java-rest-assured.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.epam.reportportal%22%20AND%20a:%22logger-java-rest-assured%22)
[![CI Build](https://github.com/reportportal/logger-java-rest-assured/actions/workflows/ci.yml/badge.svg)](https://github.com/reportportal/logger-java-rest-assured/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/reportportal/logger-java-rest-assured/branch/develop/graph/badge.svg?token=W3MTDF607A)](https://codecov.io/gh/reportportal/logger-java-rest-assured)
[![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 @@ -38,13 +38,13 @@ repositories {
}

dependencies {
api 'com.epam.reportportal:client-java:5.1.11'
api 'com.epam.reportportal:client-java:5.1.15'
api 'com.google.code.findbugs:jsr305:3.0.2'
api 'com.epam.reportportal:commons-model:5.0.0'
api ('io.rest-assured:rest-assured:5.1.1') {
exclude module: 'commons-codec'
}
api 'com.epam.reportportal:utils-java-formatting:5.1.2'
api 'com.epam.reportportal:utils-java-formatting:5.1.4'
implementation 'commons-codec:commons-codec:1.15'

testImplementation('com.github.reportportal:agent-java-test-utils:236a68c')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
import java.util.function.Function;
import java.util.function.Predicate;

import static com.epam.reportportal.formatting.http.Constants.BODY_TYPE_MAP;
import static com.epam.reportportal.formatting.http.Constants.DEFAULT_PRETTIERS;

/**
* REST Assured Request/Response logging filter for Report Portal.
* <p>
Expand All @@ -64,10 +61,6 @@ public class ReportPortalRestAssuredLoggingFilter extends AbstractHttpFormatter<

private final int order;

private Map<String, Function<String, String>> contentPrettiers = DEFAULT_PRETTIERS;

private Map<String, BodyType> bodyTypeMap = BODY_TYPE_MAP;

/**
* Create an ordered REST Assured filter with the log level and different converters.
*
Expand All @@ -89,8 +82,7 @@ public ReportPortalRestAssuredLoggingFilter(int filterOrder, @Nonnull LogLevel d
@Nullable Function<Header, String> partHeaderConvertFunction,
@Nullable Function<Cookie, String> cookieConvertFunction,
@Nullable Function<String, String> uriConverterFunction) {
super(
defaultLogLevel,
super(defaultLogLevel,
headerConvertFunction,
partHeaderConvertFunction,
cookieConvertFunction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Calendar;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

import static com.epam.reportportal.formatting.http.HttpFormatUtils.getBodyType;
import static com.epam.reportportal.formatting.http.HttpFormatUtils.getMimeType;
Expand All @@ -49,6 +49,56 @@
*/
public class HttpEntityFactory {

@Nonnull
private static List<HttpPartFormatter> toParts(@Nonnull FilterableRequestSpecification request,
@Nonnull Map<String, BodyType> bodyTypeMap, @Nullable Function<Header, String> partHeaderConverter) {
return ofNullable(request.getMultiPartParams()).map(params -> params.stream().map(it -> {
String partMimeType = ofNullable(it.getMimeType()).orElse(ContentType.APPLICATION_OCTET_STREAM.getMimeType());
try {
Object body = it.getContent();
HttpPartFormatter.PartType partType;
if (BodyType.TEXT == getBodyType(partMimeType, bodyTypeMap)) {
partType = HttpPartFormatter.PartType.TEXT;
} else {
partType = HttpPartFormatter.PartType.BINARY;
}

Object content;
if (body instanceof File) {
TypeAwareByteSource file = Utils.getFile((File) body);
byte[] data = file.read();
if (partType == HttpPartFormatter.PartType.TEXT) {
content = ofNullable(data).map(d -> {
try {
return new String(d, ofNullable(it.getCharset()).orElse(StandardCharsets.UTF_8.name()));
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
}).orElse("");
} else {
content = data;
}
} else {
content = body;
}
HttpPartFormatter.Builder partBuilder = new HttpPartFormatter.Builder(partType, partMimeType, content);
ofNullable(it.getHeaders()).ifPresent(headers -> headers.forEach((key, value) -> partBuilder.addHeader(
new Header(key, value))));
partBuilder.controlName(it.getControlName());
partBuilder.charset(it.getCharset());
partBuilder.fileName(it.getFileName());
partBuilder.headerConverter(partHeaderConverter);
return partBuilder.build();
} catch (IOException e) {
ReportPortal.emitLog("Unable to read file: " + e.getMessage(),
"ERROR",
Calendar.getInstance().getTime()
);
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toList())).orElse(Collections.emptyList());
}

@Nonnull
public static HttpRequestFormatter createHttpRequestFormatter(
@Nonnull FilterableRequestSpecification requestSpecification,
Expand Down Expand Up @@ -88,54 +138,7 @@ public static HttpRequestFormatter createHttpRequestFormatter(
builder.bodyParams(requestSpecification.getFormParams());
break;
case MULTIPART:
ofNullable(requestSpecification.getMultiPartParams()).ifPresent(params -> params.forEach(it -> {
String partMimeType = ofNullable(it.getMimeType()).orElse(ContentType.APPLICATION_OCTET_STREAM.getMimeType());
HttpPartFormatter.Builder partBuilder;
try {
Object body = it.getContent();
HttpPartFormatter.PartType partType;
if (BodyType.TEXT == getBodyType(partMimeType, bodyTypeMap)) {
partType = HttpPartFormatter.PartType.TEXT;
} else {
partType = HttpPartFormatter.PartType.BINARY;
}

Object content;
if (body instanceof File) {
TypeAwareByteSource file = Utils.getFile((File) body);
byte[] data = file.read();
if (partType == HttpPartFormatter.PartType.TEXT) {
content = ofNullable(data).map(d -> {
try {
return new String(d,
ofNullable(it.getCharset()).orElse(StandardCharsets.UTF_8.name())
);
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
}).orElse("");
} else {
content = data;
}
} else {
content = body;
}
partBuilder = new HttpPartFormatter.Builder(partType, partMimeType, content);

ofNullable(it.getHeaders()).ifPresent(headers -> headers.forEach((key, value) -> partBuilder.addHeader(
new Header(key, value))));
partBuilder.controlName(it.getControlName());
partBuilder.charset(it.getCharset());
partBuilder.fileName(it.getFileName());
partBuilder.headerConverter(partHeaderConverter);
builder.addBodyPart(partBuilder.build());
} catch (IOException e) {
ReportPortal.emitLog("Unable to read file: " + e.getMessage(),
"ERROR",
Calendar.getInstance().getTime()
);
}
}));
toParts(requestSpecification, bodyTypeMap, partHeaderConverter).forEach(builder::addBodyPart);
break;
default:
builder.bodyBytes(mimeType, requestSpecification.getBody());
Expand Down

0 comments on commit 864df61

Please sign in to comment.