Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into feature/#34
Browse files Browse the repository at this point in the history
  • Loading branch information
ilchudov committed Feb 24, 2025
2 parents c56ebbd + cd65201 commit 5f0bb44
Show file tree
Hide file tree
Showing 15 changed files with 490 additions and 29 deletions.
131 changes: 109 additions & 22 deletions .github/workflows/maven-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,45 @@

# This GitHub Actions workflow is designed to be triggered when a release is marked as a full release.
# The workflow performs the following tasks:
# - Extract Release Version: Extracts the tag name and removes the leading 'v' character to get the release version.
# - Update pom.xml: Updates the version in the pom.xml file using the extracted release version.
# - Publish to Maven: Publishes the artifact to the Maven repository using the updated pom.xml.
# 1. Checks if the tag already exists.
# 2. Updates the version in the pom.xml file.
# 3. Commits the changes to the repository.
# 4. Builds the project using Maven.
# 5. Runs tests.
# 6. Tags the commit with the release version.
# 7. Deploys the artifact to the Maven repository.
# 8. Builds and publishes a Docker image.
# 9. Creates a GitHub release.

name: Release And Upload to Maven Central
# To make it work for your project, you need to adjust the pom.xml and add configuration file for GitHub release.
# Please find detailed instructions:
# https://github.com/Netcracker/qubership-workflow-hub?tab=readme-ov-file#maven-project-release-workflow

name: Release And Deploy Maven Artifact

on:
workflow_dispatch:
inputs:
version:
required: true
default: '2025.1-1.0.0'
default: '1.0.0'
type: string
description: 'Release version (e.g., 2025.1-1.0.0)'
java_version:
description: 'Release version (e.g., 1.0.0)'
java-version:
required: false
type: string
default: "21"
description: 'Java version (e.g., 21)'
build-docker:
required: false
type: boolean
default: true
description: 'Release docker image if there is Docker file'
dry-run:
required: false
type: boolean
default: false
description: 'Dry run'

jobs:
check-tag:
Expand All @@ -29,7 +49,7 @@ jobs:
- name: Input parameters
run: |
echo "Version: ${{ github.event.inputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "Java version: ${{ github.event.inputs.java_version }}" >> $GITHUB_STEP_SUMMARY
echo "Java version: ${{ github.event.inputs.java-version }}" >> $GITHUB_STEP_SUMMARY
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -57,35 +77,102 @@ jobs:
update-pom-version:
needs: [check-tag]
runs-on: ubuntu-latest
outputs:
artifact_id: ${{ steps.config.outputs.artifact_id }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Update pom.xml
uses: Netcracker/qubership-workflow-hub/actions/pom-updater@main
id: config
uses: netcracker/qubership-workflow-hub/actions/pom-updater@main
with:
new_value: ${{ github.event.inputs.version }}

- name: Commit Changes
uses: Netcracker/qubership-workflow-hub/actions/commit-and-push@main
uses: netcracker/qubership-workflow-hub/actions/commit-and-push@main
with:
commit_message: "Update pom.xml version to ${{ github.event.inputs.version }}"

upload_to_maven_central:
mvn-package:
needs: [update-pom-version]
uses: Netcracker/qubership-workflow-hub/.github/workflows/maven-publish.yml@main
uses: netcracker/qubership-workflow-hub/.github/workflows/maven-publish.yml@main
with:
maven_command: "--batch-mode deploy"
java_version: ${{ github.event.inputs.java_version }}
version: ${{ github.event.inputs.version }}
maven-command: "--batch-mode package"
java-version: ${{ github.event.inputs.java-version }}
upload-artifact: true
artifact-id: ${{ needs.update-pom-version.outputs.artifact_id }}
secrets:
maven_username: ${{ secrets.MAVEN_USER }}
maven_password: ${{ secrets.MAVEN_PASSWORD }}
maven_gpg_passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
maven_gpg_private_key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
maven-username: ${{ secrets.MAVEN_USER }}
maven-token: ${{ secrets.MAVEN_PASSWORD }}
gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}

tests:
needs: [mvn-package]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run tests
run: echo "Running tests here"

tag:
needs: [tests]
uses: netcracker/qubership-workflow-hub/.github/workflows/tag-creator.yml@main
with:
tag-name: ${{ github.event.inputs.version }}

mvn-deploy:
needs: [update-pom-version, tag]
uses: netcracker/qubership-workflow-hub/.github/workflows/maven-publish.yml@main
with:
maven-command: ${{ (github.event.inputs.dry-run == 'true' && '--batch-mode package') || '--batch-mode deploy' }}
java-version: ${{ github.event.inputs.java-version }}
upload-artifact: false
artifact-id: ${{ needs.update-pom-version.outputs.artifact_id }}
server-id: "central"
secrets:
maven-username: ${{ secrets.MAVEN_USER }}
maven-token: ${{ secrets.MAVEN_PASSWORD }}
gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}

check-dockerfile:
runs-on: ubuntu-latest
needs: [update-pom-version, tag]
outputs:
dockerfile_exists: ${{ steps.check_dockerfile.outputs.df_exists }}
steps:
- uses: actions/checkout@v4
- name: "Check Dockerfile existence"
id: check_dockerfile
shell: bash
run: |
if [[ -f Dockerfile ]]; then
echo "df_exists=exists" >> "$GITHUB_OUTPUT"
else
echo "Dockerfile does not exist. Docker build stage will be skipped"
echo "df_exists=notexists" >> "$GITHUB_OUTPUT"
fi
echo "GITHUB_OUTPUT:"
cat "$GITHUB_OUTPUT"
docker-build-publish:
needs: [update-pom-version, tag, check-dockerfile]
if: ${{ github.event.inputs.build-docker == 'true' && needs.check-dockerfile.outputs.dockerfile_exists == 'exists' }}
uses: netcracker/qubership-workflow-hub/.github/workflows/docker-publish.yml@main
with:
ref: ${{ github.event.inputs.version }}
artifact-id: ${{ needs.update-pom-version.outputs.artifact_id }}
dry-run: ${{ inputs.dry-run }}

github-release:
needs: [upload_to_maven_central]
uses: Netcracker/qubership-workflow-hub/.github/workflows/release-drafter.yml@main
needs: [tag]
uses: netcracker/qubership-workflow-hub/.github/workflows/release-drafter.yml@main
with:
version: ${{ github.event.inputs.version }}
publish: false
publish: false
39 changes: 39 additions & 0 deletions .github/workflows/maven-snapshot-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
# The workflow to deploy snapshot artifact versions to GitHub packages
# Fill free to adjust java version and additional mvn command-line parameters
# The workflow will trigger on pushes into branches different from main and release
# Please make sure that the version in the pom.xml file has the SNAPSHOT postfix

name: Maven deploy snapshot

on:
push:
branches:
- "!main"
- "!**release*"

permissions:
packages: write

jobs:
mvn-deploy:
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "temurin"
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Display settings.xml
run: cat ~/.m2/settings.xml
- name: "Maven deploy"
run: |
mvn --batch-mode deploy -DaltDeploymentRepository=github::https://maven.pkg.github.com/${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USER: ${{ github.actor }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.qubership.integration.platform.engine.camel.components.directvm.ChainConsumerNotAvailableException;
import org.qubership.integration.platform.engine.camel.components.servlet.exception.annotations.ChainExceptionHandler;
import org.qubership.integration.platform.engine.camel.exceptions.IterationLimitException;
import org.qubership.integration.platform.engine.errorhandling.ChainExecutionTerminatedException;
import org.qubership.integration.platform.engine.errorhandling.ChainExecutionTimeoutException;
import org.qubership.integration.platform.engine.errorhandling.ResponseValidationException;
import org.qubership.integration.platform.engine.errorhandling.errorcode.ErrorCode;
import org.qubership.integration.platform.engine.errorhandling.ValidationException;
Expand Down Expand Up @@ -112,6 +114,16 @@ public void handleException(IterationLimitException exception, Exchange exchange
makeExceptionResponseInExchange(exchange, errorCode, extraParameters);
}

@ChainExceptionHandler(value = ChainExecutionTimeoutException.class, errorCode = ErrorCode.TIMEOUT_REACHED)
public void handleException(ChainExecutionTimeoutException exception, Exchange exchange, ErrorCode errorCode, Map<String, String> extraParameters) throws IOException {
makeExceptionResponseInExchange(exchange, errorCode, extraParameters);
}

@ChainExceptionHandler(value = ChainExecutionTerminatedException.class, errorCode = ErrorCode.FORCE_TERMINATED)
public void handleException(ChainExecutionTerminatedException exception, Exchange exchange, ErrorCode errorCode, Map<String, String> extraParameters) throws IOException {
makeExceptionResponseInExchange(exchange, errorCode, extraParameters);
}

private void makeExceptionResponseInExchange(Exchange exchange, ErrorCode errorCode, Map<String, String> extraParameters) throws IOException {
exchange.getMessage().removeHeaders("*");
exchange.getMessage().setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ private void logHttpTriggerRequestFinished(Exchange exchange, CamelDebuggerPrope
return; // Log only if it is info level OR session is failed
}

String started = exchange.getProperty(CamelConstants.Properties.START_TIME,
String.class);
String finished = LocalDateTime.now().toString();
long duration = Duration.between(LocalDateTime.parse(started),
LocalDateTime.parse(finished)).toMillis();
long started = exchange.getProperty(CamelConstants.Properties.START_TIME_MS,
Long.class);
long duration = System.currentTimeMillis() - started;

List<MessageHistory> messageHistory = (List<MessageHistory>) exchange.getAllProperties()
.getOrDefault(Exchange.MESSAGE_HISTORY, Collections.emptyList());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2024-2025 NetCracker Technology Corporation
*
* 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
*
* 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.
*/

package org.qubership.integration.platform.engine.camel.processors;

import lombok.extern.slf4j.Slf4j;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.qubership.integration.platform.engine.model.constants.CamelConstants.Properties;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class SplitAsyncProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
exchange.removeProperty(Properties.CHAIN_TIME_OUT_AFTER);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2024-2025 NetCracker Technology Corporation
*
* 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
*
* 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.
*/

package org.qubership.integration.platform.engine.errorhandling;

public class ChainExecutionTerminatedException extends RuntimeException {
public ChainExecutionTerminatedException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2024-2025 NetCracker Technology Corporation
*
* 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
*
* 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.
*/

package org.qubership.integration.platform.engine.errorhandling;

public class ChainExecutionTimeoutException extends RuntimeException {
public ChainExecutionTimeoutException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public enum ErrorCode {
RESPONSE_VALIDATION_ERROR("0112", HttpStatus.SC_INTERNAL_SERVER_ERROR,
"Response captured by one of the service calls has not passed configured validations",
"Chain failed due to receiving unexpected response from service"),
TIMEOUT_REACHED("0113", HttpStatus.SC_INTERNAL_SERVER_ERROR, "Chain timeout reached","Chain execution failed due to reaching execution timeout"),
FORCE_TERMINATED("0114", HttpStatus.SC_INTERNAL_SERVER_ERROR, "Chain session was shut down","Chain execution was stopped manually"),


// Deployment errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public final static class Properties {
public static final String STEPS = INTERNAL_PROPERTY_PREFIX + "steps";
public static final String EXCHANGES = INTERNAL_PROPERTY_PREFIX + "exchanges";
public static final String START_TIME = INTERNAL_PROPERTY_PREFIX + "startTime";
public static final String START_TIME_MS = INTERNAL_PROPERTY_PREFIX + "startTimeMs";
public static final String EXCHANGE_START_TIME_MS = INTERNAL_PROPERTY_PREFIX + "exchangeStartTimeMs";
public static final String IS_MAIN_EXCHANGE = INTERNAL_PROPERTY_PREFIX + "isMainExchange";
public static final String ELEMENT_FAILED = INTERNAL_PROPERTY_PREFIX + "elementFailed";
public static final String LAST_EXCEPTION = INTERNAL_PROPERTY_PREFIX + "lastException";
public static final String LAST_EXCEPTION_ERROR_CODE = INTERNAL_PROPERTY_PREFIX + "laseExceptionErrorCode";
Expand Down Expand Up @@ -148,6 +151,8 @@ public final static class Properties {
public static final String CORRELATION_ID_POSITION = "correlationIdPosition";
public static final String CORRELATION_ID_NAME = "correlationIdName";
public static final String IS_CHECKPOINT_TRIGGER_STEP = INTERNAL_PROPERTY_PREFIX + "isCheckpointTriggerStep";
public static final String CHAIN_TIMED_OUT = INTERNAL_PROPERTY_PREFIX + "chainSessionTimedOut";
public static final String CHAIN_TIME_OUT_AFTER = INTERNAL_PROPERTY_PREFIX + "chainSessionTimeoutAfter";

public static final String HTTP_TRIGGER_STEP_ID = "httpTriggerStepId";

Expand Down
Loading

0 comments on commit 5f0bb44

Please sign in to comment.