Skip to content

Commit

Permalink
Create maven.yml (#63)
Browse files Browse the repository at this point in the history
* Create maven.yml

* Update maven.yml

* Update maven.yml

* Update maven.yml

* Update Maven plugin versions in pom.xml

Upgraded various Maven plugins to their latest versions to improve compatibility and leverage new features. The plugins updated include maven-javadoc-plugin, maven-gpg-plugin, maven-release-plugin, maven-surefire-plugin, maven-failsafe-plugin, maven-deploy-plugin, and maven-jar-plugin.

* Enhance type checking using instanceof pattern matching

Replaced traditional instanceof checks with pattern matching in multiple classes to streamline and modernize type checks. Also updated the GitHub Actions workflow to use JDK 17 instead of JDK 11. These changes improve the readability and efficiency of the codebase.

* Update Maven plugin and CI configuration

Added the maven-compiler-plugin to pom.xml for better compatibility and upgraded the GitHub Actions workflow to use 'mvn verify'. Removed the now redundant Travis CI configuration file as the build process is fully managed by GitHub Actions.

* Add JUnit report publishing and adjust formatting

Implemented JUnit report publishing in the Maven workflow to improve test visibility. Adjusted YAML and editor configurations for better consistency and readability.

* badge

---------

Co-authored-by: Konstantin Pavlov <[email protected]>
  • Loading branch information
kpavlov and kpavlov authored Oct 28, 2024
1 parent faaab17 commit 09aa8da
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 86 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ ij_smart_tabs = false
ij_visual_guides =
ij_wrap_on_typing = false

[{*.yml,*.yaml}]
tab_width = 2
indent_size = 2

[*.java]
ij_java_align_consecutive_assignments = false
ij_java_align_consecutive_variable_declarations = false
Expand Down
30 changes: 15 additions & 15 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Maven Package

on:
release:
types: [created]
types: [ created ]

jobs:
build:
Expand All @@ -16,19 +16,19 @@ jobs:
packages: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
37 changes: 37 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B verify

- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure()
with:
report_paths: '**/TEST-*.xml'
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fixio - FIX Protocol Support for Netty [![Build Status](https://travis-ci.org/kpavlov/fixio.png?branch=master)](https://travis-ci.org/kpavlov/fixio) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7a6c7475813e44c5a96abe915ed60e73)](https://www.codacy.com/app/kpavlov/fixio?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=kpavlov/fixio&amp;utm_campaign=Badge_Grade)
fixio - FIX Protocol Support for Netty [![Java CI with Maven](https://github.com/kpavlov/fixio/actions/workflows/maven.yml/badge.svg)](https://github.com/kpavlov/fixio/actions/workflows/maven.yml) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7a6c7475813e44c5a96abe915ed60e73)](https://www.codacy.com/app/kpavlov/fixio?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=kpavlov/fixio&amp;utm_campaign=Badge_Grade)
=====

# Overview #
Expand Down
16 changes: 8 additions & 8 deletions core/src/main/java/fixio/fixprotocol/FixMessageBuilderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ public String getString(int tagNum) {
if (item == null) {
return null;
}
if (item instanceof StringField) {
return ((StringField) item).getValue();
if (item instanceof StringField stringField) {
return stringField.getValue();
} else {
throw new IllegalArgumentException("Tag " + tagNum + " is not a Field.");
}
Expand Down Expand Up @@ -253,8 +253,8 @@ public Character getChar(int tagNum) {
if (field == null) {
return null;
}
if (field instanceof CharField) {
return ((CharField) field).getValue();
if (field instanceof CharField charField) {
return charField.getValue();
} else {
throw new IllegalArgumentException("Tag " + tagNum + " is not a Field.");
}
Expand All @@ -263,8 +263,8 @@ public Character getChar(int tagNum) {
@Override
public Integer getInt(int tagNum) {
FixMessageFragment field = getFirst(tagNum);
if (field instanceof IntField) {
return ((IntField) field).getValue();
if (field instanceof IntField intField) {
return intField.getValue();
}
return null;
}
Expand Down Expand Up @@ -319,8 +319,8 @@ public void setMessageType(String messageType) {

public List<Group> getGroups(int tagNum) {
FixMessageFragment fragment = getFirst(tagNum);
if (fragment instanceof GroupField) {
return ((GroupField) fragment).getGroups();
if (fragment instanceof GroupField groupField) {
return groupField.getGroups();
}
return null;
}
Expand Down
22 changes: 9 additions & 13 deletions core/src/main/java/fixio/fixprotocol/FixMessageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@

package fixio.fixprotocol;

import fixio.fixprotocol.fields.AbstractField;
import fixio.fixprotocol.fields.CharField;
import fixio.fixprotocol.fields.FieldFactory;
import fixio.fixprotocol.fields.IntField;
import fixio.fixprotocol.fields.StringField;
import fixio.fixprotocol.fields.*;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -91,8 +87,8 @@ public String getString(int tagNum) {
if (item == null) {
return null;
}
if (item instanceof StringField) {
return ((StringField) item).getValue();
if (item instanceof StringField stringField) {
return stringField.getValue();
} else {
throw new IllegalArgumentException("Tag " + tagNum + " is not a Field.");
}
Expand Down Expand Up @@ -130,8 +126,8 @@ public Character getChar(int tagNum) {
if (field == null) {
return null;
}
if (field instanceof CharField) {
return ((CharField) field).getValue();
if (field instanceof CharField charField) {
return charField.getValue();
} else {
throw new IllegalArgumentException("Tag " + tagNum + " is not a Field.");
}
Expand All @@ -140,8 +136,8 @@ public Character getChar(int tagNum) {
@Override
public Integer getInt(int tagNum) {
FixMessageFragment field = getFirst(tagNum);
if (field instanceof IntField) {
return ((IntField) field).getValue();
if (field instanceof IntField intField) {
return intField.getValue();
}
return null;
}
Expand Down Expand Up @@ -175,8 +171,8 @@ public int getChecksum() {

public List<Group> getGroups(int tagNum) {
FixMessageFragment fragment = getFirst(tagNum);
if (fragment instanceof GroupField) {
return ((GroupField) fragment).getGroups();
if (fragment instanceof GroupField groupField) {
return groupField.getGroups();
}
return null;
}
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/fixio/handlers/FixApplicationAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public class FixApplicationAdapter extends MessageToMessageDecoder<Object> imple
@Override
protected void decode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception {
try {
if (msg instanceof FixMessage) {
onMessage(ctx, (FixMessage) msg, out);
} else if (msg instanceof LogonEvent) {
onLogon(ctx, (LogonEvent) msg);
} else if (msg instanceof LogoutEvent) {
onLogout(ctx, (LogoutEvent) msg);
if (msg instanceof FixMessage message) {
onMessage(ctx, message, out);
} else if (msg instanceof LogonEvent event) {
onLogon(ctx, event);
} else if (msg instanceof LogoutEvent event) {
onLogout(ctx, event);
}
} finally {
ReferenceCountUtil.release(msg);
Expand Down
14 changes: 4 additions & 10 deletions core/src/main/java/fixio/netty/codec/FixMessageEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@

package fixio.netty.codec;

import fixio.fixprotocol.FixConst;
import fixio.fixprotocol.FixMessageBuilder;
import fixio.fixprotocol.FixMessageFragment;
import fixio.fixprotocol.FixMessageHeader;
import fixio.fixprotocol.Group;
import fixio.fixprotocol.GroupField;
import fixio.fixprotocol.*;
import fixio.fixprotocol.fields.AbstractField;
import fixio.fixprotocol.fields.DateTimeFormatterWrapper;
import io.netty.buffer.ByteBuf;
Expand Down Expand Up @@ -137,10 +132,9 @@ private static int fillBodyBuf(final ByteBuf payloadBuf,

private static void encodeMessageFragment(ByteBuf payloadBuf,
FixMessageFragment messageFragment) {
if (messageFragment instanceof AbstractField) {
writeField(messageFragment.getTagNum(), (AbstractField) messageFragment, payloadBuf);
} else if (messageFragment instanceof GroupField) {
GroupField groupField = (GroupField) messageFragment;
if (messageFragment instanceof AbstractField field) {
writeField(messageFragment.getTagNum(), field, payloadBuf);
} else if (messageFragment instanceof GroupField groupField) {
writeField(groupField.getTagNum(), Integer.toString(groupField.getGroupCount()), payloadBuf);
for (Group c : groupField.getValue()) {
List<FixMessageFragment> contents = c.getContents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@
package fixio.netty.pipeline;

import fixio.events.LogoutEvent;
import fixio.fixprotocol.FieldType;
import fixio.fixprotocol.FixMessage;
import fixio.fixprotocol.FixMessageBuilder;
import fixio.fixprotocol.FixMessageBuilderImpl;
import fixio.fixprotocol.FixMessageHeader;
import fixio.fixprotocol.MessageTypes;
import fixio.fixprotocol.*;
import fixio.fixprotocol.session.FixSession;
import fixio.handlers.FixApplication;
import fixio.validator.BusinessRejectException;
Expand Down Expand Up @@ -141,8 +136,8 @@ protected void decode(ChannelHandlerContext ctx, FixMessage msg, List<Object> ou

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (cause instanceof BusinessRejectException) {
FixMessageBuilderImpl businessMessageReject = createBusinessReject((BusinessRejectException) cause);
if (cause instanceof BusinessRejectException exception) {
FixMessageBuilderImpl businessMessageReject = createBusinessReject(exception);
ctx.channel().writeAndFlush(businessMessageReject);
} else {
super.exceptionCaught(ctx, cause);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
public class TestRequestHandler extends MessageToMessageDecoder<FixMessage> {

public boolean acceptInboundMessage(Object msg) {
return (msg instanceof FixMessage
&& MessageTypes.TEST_REQUEST.equals(((FixMessage) msg).getMessageType()));
return (msg instanceof FixMessage fm
&& MessageTypes.TEST_REQUEST.equals(fm.getMessageType()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;

import static fixio.netty.codec.DecodingTestHelper.decodeOne;
Expand All @@ -28,7 +27,7 @@ public FixMessageDecoderSmokeTest(String message) {

@Parameterized.Parameters(name = "msg: {0}")
public static Object[] data() throws IOException, URISyntaxException {
Path path = Paths.get(Objects.requireNonNull(FixMessageDecoderSmokeTest.class.getClassLoader()
Path path = Path.of(Objects.requireNonNull(FixMessageDecoderSmokeTest.class.getClassLoader()
.getResource("example-messages.txt")).toURI());

return Files.lines(path)
Expand Down
Loading

0 comments on commit 09aa8da

Please sign in to comment.