Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement GitHub Actions CI #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path

name: Maven Package

on:
release:
types: [created]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 18
uses: actions/setup-java@v4
with:
java-version: '18'
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: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
39 changes: 39 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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 18
uses: actions/setup-java@v4
with:
java-version: '18'
distribution: 'temurin'
cache: maven
- name: Build and test with Maven
run: mvn -B package --file pom.xml
- run: mkdir staging && cp target/*.jar staging
- uses: actions/upload-artifact@v4
with:
name: Package
path: staging
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
# - name: Update dependency graph
# uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
137 changes: 73 additions & 64 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.uic.barcode</groupId>
<artifactId>org.uic.barcode</artifactId>
<version>1.4.12</version>
<groupId>org.uic</groupId>
<artifactId>barcode</artifactId>
<version>1.4.13</version>
<packaging>jar</packaging>
<name>UIC barcode</name>
<name>UIC Barcode</name>
<description>Encoding and decoding of Aztec barcode content according to UIC IRS 90918-9</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>1.80</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencies>
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>1.80</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>src/main/java</sourceDirectory>
Expand All @@ -43,50 +45,57 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
<configuration>
<locales>en_gb</locales>
<outputDirectory>${project.build.directory}/site</outputDirectory>
<relativizeDecorationLinks>false</relativizeDecorationLinks>
</configuration>
</plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
<configuration>
<locales>en_gb</locales>
<outputDirectory>${project.build.directory}/site</outputDirectory>
<relativizeDecorationLinks>false</relativizeDecorationLinks>
</configuration>
</plugin>
</plugins>

</build>



<distributionManagement>
<repository>
<id>github</id>
<name>GitHub UIC Apache Maven Packages</name>
<url>https://maven.pkg.github.com/UnionInternationalCheminsdeFer/UIC-barcode</url>
</repository>
</distributionManagement>

<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
</project>
</project>
39 changes: 19 additions & 20 deletions src/test/java/org/uic/barcode/test/DynamicContentCoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
Expand Down Expand Up @@ -47,13 +49,10 @@ public class DynamicContentCoderTest {
g.setLongitude( 12345L);
g.setLatitude( 56789L);
content.setGeoCoordinate(g);

try {
//needs to be before 28.2. to keep the test stable in year with febuary 29.
content.setTimeStamp(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.02.04-12:30" ));
} catch (ParseException e2) {
//
}

//needs to be before 28.2. to keep the test stable in year with febuary 29.
Date date = new Date(1612438200000L);
content.setTimeStamp(date);

}

Expand All @@ -79,39 +78,39 @@ public class DynamicContentCoderTest {


String encoding = "7C170F0E1262089437000230390300DDD504017A20C6D0C2D8D8CADCCECA40E6E8E4D2DCCE2F8F461D9B32EECF96FE5F1D32EEE7A77EEBFA72310282DA05E1A37EECA0507B409C30F3E60509B42F8F461D9B32EECF96FE5F1D32EEE7A77EEBFA72310282DA";
IUicDynamicContent content = DynamicContentCoder.decode(UperEncoder.bytesFromHexString(encoding));
IUicDynamicContent testContent = DynamicContentCoder.decode(UperEncoder.bytesFromHexString(encoding));


assert("appID".equals(content.getAppId()));
assert("appID".equals(testContent.getAppId()));

assert("challenge string".equals(content.getChallengeString()));
assert("challenge string".equals(testContent.getChallengeString()));

IExtension e1 = content.getExtension();
IExtension e1 = testContent.getExtension();
assert(UperEncoder.hexStringFromBytes(e1.getBinarydata()).equals("82DA"));
assert(e1.getId().equals("challenge_extension_id1"));


assert(content.getChallengeString().equals("challenge string"));
assert(testContent.getChallengeString().equals("challenge string"));

byte[] ce = null;
for (IExtension e : content.getDynamicContentResponseList()) {
for (IExtension e : testContent.getDynamicContentResponseList()) {
if (e.getId().equals("challenge_extension_id1")) {
ce = e.getBinarydata();
}
}
assert(UperEncoder.hexStringFromBytes(ce).equals("82DA"));

assert(UperEncoder.hexStringFromBytes(content.getPhoneIdHash()).equals("83DA"));
assert(UperEncoder.hexStringFromBytes(testContent.getPhoneIdHash()).equals("83DA"));

assert(UperEncoder.hexStringFromBytes(content.getPassIdHash()).equals("84DA"));
assert(UperEncoder.hexStringFromBytes(testContent.getPassIdHash()).equals("84DA"));

assert(content.getGeoCoordinate() != null);
assert(content.getGeoCoordinate().getLongitude() == 12345L);
assert(content.getGeoCoordinate().getLatitude() == 56789L);
assert(testContent.getGeoCoordinate() != null);
assert(testContent.getGeoCoordinate().getLongitude() == 12345L);
assert(testContent.getGeoCoordinate().getLatitude() == 56789L);

assert(content.getTimeStamp() != null);
assert(testContent.getTimeStamp() != null);

assert(content.getTimeStamp().toString().contains("04 12:30:00 CET"));
assert(testContent.getTimeStamp().getTime() == 1738668600000L);


}
Expand Down
Loading