Skip to content

Commit

Permalink
Merge pull request #349 from smeup/release/1.2.0
Browse files Browse the repository at this point in the history
Release/1.2.0 merge into master
  • Loading branch information
mattiabonardi authored Nov 9, 2023
2 parents 1a6e6c4 + 0ca44c6 commit d0c42cf
Show file tree
Hide file tree
Showing 148 changed files with 4,139 additions and 1,030 deletions.
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ version: 2.0
jobs:
build:
docker:
- image: circleci/openjdk:8-jdk
- image: circleci/openjdk:11-jdk
steps:
- checkout
- run: ./gradlew ktlintCheck
- run: ./gradlew test
- run: ./gradlew check

8 changes: 3 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ jobs:

steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: Checking kotlin formatting
run: ./gradlew ktlintCheck
- name: Test
run: ./gradlew test
- name: Check
- name: Compiling and test
run: ./gradlew check
27 changes: 27 additions & 0 deletions .github/workflows/publish-smeup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy to internal smeup nexus
on:
push:
branches: ['master', 'develop']
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 11
# save private key to file (private.gpg)
- run: echo "${{ secrets.GPG_KEY_BASE64 }}" | base64 -d > ~/private.gpg
# create gradle.properties file
- run: |
mkdir -p ~/.gradle/
echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV
echo "signing.keyId=${{ secrets.GPG_KEY_ID }}" >> ~/.gradle/gradle.properties
echo "signing.password=${{ secrets.GPG_PASSPHRASE }}" >> ~/.gradle/gradle.properties
echo "signing.secretKeyRingFile=${HOME}/private.gpg" >> ~/.gradle/gradle.properties
echo "smeupUsername=${{ secrets.NEXUS_USER }}" >> ~/.gradle/gradle.properties
echo "smeupPassword=${{ secrets.NEXUS_PASSWORD }}" >> ~/.gradle/gradle.properties
# deploy
- uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: publishToSmeup
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
# save private key to file (private.gpg)
- run: echo "${{ secrets.GPG_KEY_BASE64 }}" | base64 -d > ~/private.gpg
# create gradle.properties file
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ bin/
**/.DS_Store
rpgJavaInterpreter-core/generated-src/
rpgJavaInterpreter-core/src/main/gen/
rpgJavaInterpreter-core/src/main/antlr/gen/
lib
*.tokens
/rpgJavaInterpreter-core/src/main/resources/META-INF/com.smeup.jariko/version.txt
24 changes: 23 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ buildscript {

plugins {
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id "org.ajoberstar.grgit" version "5.0.0-rc.3"
}

project.group = jarikoGroupId
Expand All @@ -48,7 +49,6 @@ project.version = jarikoVersion
subprojects {
apply plugin: 'kotlin'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'org.jlleitschuh.gradle.ktlint'
apply plugin: 'kotlinx-serialization'
Expand All @@ -75,6 +75,10 @@ subprojects {

// specifying what we want to sign
signing {
if (!project.hasProperty("signing.keyId")) {
println "$project.name - Signing disabled because signing.keyId property is not present, it is not an error!!!"
}
required { project.hasProperty("signing.keyId") }
sign configurations.archives
}

Expand All @@ -93,17 +97,35 @@ subprojects {
tasks.publishMavenJavaPublicationToSonatypeRepository{
dependsOn project.tasks.signArchives
}
tasks.publishMavenJavaPublicationToSmeupRepository{
dependsOn project.tasks.signArchives
}
tasks.publishMavenJavaPublicationToMavenLocal{
dependsOn project.tasks.signArchives
}
}
}

nexusPublishing {
// trick to bypass staging when we publishToSmeup, because smeup nexus does not support the staging features
// however take in account that this flag in the other cases must be true or false depending on the version name
useStaging = !(project.gradle.startParameter.taskNames.contains("publishToSmeup") || jarikoVersion.endsWith("SNAPSHOT"))
repositories {
sonatype {
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
username = findProperty("sonatypeUsername")
password = findProperty("sonatypePassword")
}
smeup {
nexusUrl = uri("https://repo.smeup.cloud/nexus/content/repositories/releases/")
//when useStaging=false it is always used snapshotRepositoryUrl
snapshotRepositoryUrl = jarikoVersion.endsWith("SNAPSHOT") ?
uri("https://repo.smeup.cloud/nexus/content/repositories/snapshots/"):
uri("https://repo.smeup.cloud/nexus/content/repositories/releases/")
username = findProperty("smeupUsername")
password = findProperty("smeupPassword")
}
}
}

Expand Down
54 changes: 50 additions & 4 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,63 @@ Usage:
./gradlew profileRpgProgram -PrpgProgram=path_to_rpg_program
```

## Enable experimental or new features
## Enabling experimental features

Jariko features are modeled by factories implementing: `com.smeup.rpgparser.interpreter.IFeaturesFactory`.
You can select a factory through system property: `-DfeaturesFactory=<factory.id>`.
### Try new features by implementing a new instance of IFeaturesFactory

Jariko features are modeled by a factory that implements: `com.smeup.rpgparser.interpreter.IFeaturesFactory`

You can select a factory through system property: `-Djariko.featuresFactory=<factory.id>`.
Where `<factory.id>` could be:
* default
* experimental
* Factory class implementation

Configuration for *default* and *experimental* factory is in: `META-INF/com.smeup.jariko/features.properties`
Configuration for _default_ and _experimental_ factory is in: `META-INF/com.smeup.jariko/features.properties`

### Try new features with feature flags

You can try new features also through the feature flags.
When you run jariko you will see in console something like this:

```
------------------------------------------------------------------------------------
Creating features factory: com.smeup.rpgparser.interpreter.StandardFeaturesFactory
------------------------------------------------------------------------------------
Feature flags status:
- jariko.features.UnlimitedStringTypeFlag: off
------------------------------------------------------------------------------------
```

This it means that jariko is using the default `IFeaturesFactory` implementation (creating features factory...),
but more relevant is the following part of the console message where it is displayed a list of available feature
flags and their status.
What you see it means that currently jariko provides one feature flag named:
`jariko.features.UnlimitedStringTypeFlag` and its status is `off`.

**how to switch on a feature flag at runtime**
Before to call jariko it is necessary set the system property like this:
```java
System.setProperty(featureFlagName, "on");
```
and for example if you want to try `jariko.features.UnlimitedStringTypeFlag` you can do:
```java
System.setProperty("jariko.features.UnlimitedStringTypeFlag", "on");
```

**how to switch on a feature flag via cli**
For example if you want to execute all tests trying the feature flag `jariko.features.UnlimitedStringTypeFlag`:
```
./gradlew -Djariko.features.UnlimitedStringTypeFlag=on test
```


**available feature flags and description**

| feature flag | description |
|-------------------------------------------|---------------------------------------------------------------------------------------------------|
| `jariko.features.UnlimitedStringTypeFlag` | when `on` you ask jariko to force the use of `UnlimitedStringType` for all rpg alphanumeric types |
|


## Creating a jar with all dependencies to run some examples
Expand Down
17 changes: 17 additions & 0 deletions docs/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The available channels are:
* **Performance:** measures the execution time.
* **Parsing:** measures parsing phase time.
* **Resolution:** provides information about the process to identify the routines or programs to invoke.
* **Error:** provides information about error event occurred during the whole cycle of program interpretation.

## Sample

Expand Down Expand Up @@ -68,6 +69,9 @@ resolution.output = console
parsing.level = off
parsing.output = console
error.level = off
error.output = console
```

The value specified in **logger.data.separator** is the character used to
Expand Down Expand Up @@ -236,3 +240,16 @@ of strategies used to locate a RPG/Java program.
15:09:46.960 TEST_06 80 RESL CALL "CALCFIB"
+-----------+-------------+--+---+---------- resolution -----------+
```

## Error Channel ERR
The error channel catches the error events (instances of `com.smeup.rpgparser.execution.ErrorEvent`).
These events are particularly meaningful during the program syntax checking, below we can see an example.
As you can see, the `ErrorEvent` is shown through its string representation.
```
12:24:28.735 ERROR02 6 ERR ErrorEvent(error=java.lang.IllegalStateException: token recognition error at: 'C ', errorEventSource=Parser, absoluteLine=6, sourceReference=SourceReference(sourceReferenceType=Program, sourceId=ERROR02, relativeLine=6, position=Position(start=Line 6, Column 6, end=Line 6, Column 6)), fragment= C EVAL x = 1 / n)
12:24:28.739 ERROR02 7 ERR ErrorEvent(error=java.lang.IllegalStateException: missing FREE_SEMI at 'C', errorEventSource=Parser, absoluteLine=7, sourceReference=SourceReference(sourceReferenceType=Program, sourceId=ERROR02, relativeLine=7, position=Position(start=Line 7, Column 5, end=Line 7, Column 5)), fragment= C SETON LR)
+-----------+-------------+--+---+---------- error ----------------+
```

For further information about the `ErrorEvent` see the kotlin-doc in [Configuration.kt](../rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/execution/Configuration.kt)

27 changes: 27 additions & 0 deletions docs/mute.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ This interpreter can process annotations in RPG code to be used to define assert

## Syntax

### MUTE file notation
The standard notation for a MUTE file follows the structure `MUTEnn_mmk` where:
- `nn` is a two-digit number that identifies the test domain (e.g. API, Element, etc)
- `mm` is a two-digit sequential number, used to enumerate the tests of a given domain.
- `k` is a letter and indicates a MUTE subtest that is called by the main MUTE test (with identical name but without `k`).

A list of the meanings of the MUTE code-names (note that the prefix represent the domain, `nn` values, while the suffix represent the domain tests, `mm` value):

| CODE | DOMAIN TESTS |
|:----------:|------------------------------|
| **MUTE01** | **Element** |
| **MUTE02** | **List** |
| **MUTE03** | **DS** |
| **MUTE05** | **Expressions** |
| **MUTE06** | **Data Access** |
| **MUTE07** | **Opcodes** |
| **MUTE08** | **Application functions** |
| **MUTE09** | **Validation Functions** |
| **MUTE10** | **Performance Functions** |
| **MUTE11** | **Plugin gateway and tests** |
| **MUTE12** | **Data type package** |
| **MUTE13** | **BIF and Opcodes** |
| **MUTE14** | **/COPY** |
| **MUTE15** | **Procedures** |
| **MUTE16** | **Reload** |
| **MUTE18** | **/API directive** |

### Assertions that compare two values
The Mute annotations that compare two values looks like this:

Expand Down
25 changes: 22 additions & 3 deletions examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,23 @@ buildscript {

dependencies {
implementation project(":rpgJavaInterpreter-core")
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlinVersion".toString()
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion".toString()
testCompile 'junit:junit:4.12'
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion"
testImplementation 'junit:junit:4.12'
}

task javadocJar(type: Jar) {
archiveClassifier.set("javadoc")
from javadoc
}

task sourcesJar(type: Jar) {
archiveClassifier.set("sources")
from sourceSets.main.allSource
}

artifacts {
archives javadocJar, sourcesJar
}

// deploy
Expand Down Expand Up @@ -60,4 +74,9 @@ publishing {
}
}
}
}

java {
withJavadocJar()
withSourcesJar()
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2019 Sme.UP S.p.A.
*
* 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
*
* 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,
* 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 com.jariko.samples.java;

import com.smeup.rpgparser.execution.CommandLineParms;
Expand All @@ -8,33 +24,39 @@
import com.smeup.rpgparser.interpreter.StringValue;
import com.smeup.rpgparser.interpreter.Value;
import com.smeup.rpgparser.jvminterop.JavaSystemInterface;
import com.smeup.rpgparser.logging.LoggingKt;
import com.smeup.rpgparser.rpginterop.DirRpgProgramFinder;
import com.smeup.rpgparser.rpginterop.RpgProgramFinder;
import kotlin.Unit;

import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;

public class CallJarikoWithParams {

// Helper method to exec a PGM.
// Return outputParams
public static CommandLineParms execPgm(String name, CommandLineParms inputParams) {
File srcDir = new File(CallJarikoWithParams.class.getResource("/rpg").getPath());
List<RpgProgramFinder> programFinders = Arrays.asList(new DirRpgProgramFinder(srcDir));
CommandLineProgram program = RunnerKt.getProgram(name, new JavaSystemInterface(), programFinders);
return program.singleCall(inputParams, new Configuration());
final Configuration configuration = new Configuration();
configuration.getJarikoCallback().setLogInfo((channel, message) -> {
System.out.printf("LOG - %-11s - %s\n", channel, message.trim());
return Unit.INSTANCE;
});
File srcDir = new File(Objects.requireNonNull(CallJarikoWithParams.class.getResource("/rpg")).getPath());
List<RpgProgramFinder> programFinders = List.of(new DirRpgProgramFinder(srcDir));
final JavaSystemInterface systemInterface = new JavaSystemInterface(configuration);
systemInterface.setLoggingConfiguration(LoggingKt.consoleLoggingConfiguration(LoggingKt.RESOLUTION_LOGGER, LoggingKt.PERFORMANCE_LOGGER));
CommandLineProgram program = RunnerKt.getProgram(name, systemInterface, programFinders);
return program.singleCall(inputParams, configuration);
}

public static void execWithListOfString() {
List<String> plist = Arrays.asList("V1", "V2", "");
CommandLineParms commandLineParms = new CommandLineParms(plist);
CommandLineParms out = execPgm("SAMPLE01", commandLineParms);
System.out.println("execWithListOfStringParams: " + out);
assert "V1V2V1 V2".equals(out.getParmsList().stream().map(s -> s.trim()).collect(Collectors.joining()));
assert "V1V2V1 V2".equals(out.getParmsList().stream().map(String::trim).collect(Collectors.joining()));
}

public static void execWithNamedValues() {
Expand All @@ -46,7 +68,7 @@ public static void execWithNamedValues() {
CommandLineParms commandLineParms = new CommandLineParms(plist);
CommandLineParms out = execPgm("SAMPLE01", commandLineParms);
System.out.println("execWithNamedValues: " + out.getNamedParams());
assert "V1V2V1 V2".equals(out.getParmsList().stream().map(s -> s.trim()).collect(Collectors.joining()));
assert "V1V2V1 V2".equals(out.getParmsList().stream().map(String::trim).collect(Collectors.joining()));
}

public static void execWithDS() {
Expand All @@ -65,7 +87,7 @@ public static void execWithDS() {
});
CommandLineParms out = execPgm("SAMPLE02", commandLineParms);
System.out.println("execWithDS: " + out.getNamedParams());
assert "V1V2V1 V2".equals(out.getParmsList().stream().map(s -> s.trim()).collect(Collectors.joining()));
assert "V1V2V1 V2".equals(out.getParmsList().stream().map(String::trim).collect(Collectors.joining()));
}

public static void main(String[] args) {
Expand Down
Loading

0 comments on commit d0c42cf

Please sign in to comment.