Skip to content

Commit

Permalink
Merge pull request #43354 from KavinduZoysa/update-flow-model
Browse files Browse the repository at this point in the history
Update `flow_model` branch with master
  • Loading branch information
KavinduZoysa authored Sep 3, 2024
2 parents 92b09f6 + 1e44a68 commit 475d1e3
Show file tree
Hide file tree
Showing 503 changed files with 13,546 additions and 1,796 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/automate_issue_labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
ISSUE: ${{ github.event.issue.number }}

- name: Check for APIDocs related issue
if: ${{ contains(github.event.issue.body, '-> API Docs') }}
run: gh issue transfer $ISSUE "ballerina-platform/ballerina-dev-tools"
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
ISSUE: ${{ github.event.issue.number }}

- name: Check for Debugger related issue
if: ${{ contains(github.event.issue.body, '-> Debugger') }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/daily_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
ubuntu_build:
name: Build with tests on Ubuntu
runs-on: ubuntu-latest
timeout-minutes: 75
timeout-minutes: 120

steps:
- name: Checkout Repository
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/pull_request_windows_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,18 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '17.0.7'
distribution: 'graalvm'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
set-java-home: 'false'

- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
packagePAT: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew.bat build --continue -x :ballerina-lang:test -x :jballerina-integration-test:test -x :ballerina-shell:shell-cli:test -x :ballerina-cli:test -x javadoc --stacktrace -scan --console=plain --no-daemon --no-parallel
run: ./gradlew.bat build --continue -x :ballerina-lang:test -x :jballerina-integration-test:test -x javadoc --stacktrace -scan --console=plain --no-daemon --no-parallel

13 changes: 11 additions & 2 deletions .github/workflows/push_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
windows_build:
name: Build with some tests on Windows
runs-on: windows-latest
timeout-minutes: 120
timeout-minutes: 150
concurrency:
group: ${{ github.head_ref }}-windows
cancel-in-progress: true
Expand Down Expand Up @@ -86,8 +86,17 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '17.0.7'
distribution: 'graalvm'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
set-java-home: 'false'

- name: Build with Gradle
run: ./gradlew.bat build --continue -x :ballerina-lang:test -x :jballerina-integration-test:test -x :ballerina-shell:shell-cli:test -x :jballerina-debugger-integration-test:test -x javadoc --stacktrace -scan --console=plain --no-daemon --no-parallel
run: ./gradlew.bat build --continue -x :ballerina-lang:test -x :jballerina-integration-test:test -x :jballerina-debugger-integration-test:test -x javadoc --stacktrace -scan --console=plain --no-daemon --no-parallel


sonarcloud_scan:
Expand Down
8 changes: 4 additions & 4 deletions ballerina-shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ The Ballerina-shell tool is an interactive tool for learning the Ballerina progr
The project is implemented in three base modules.

- **shell-rt** - Module including runtime dependencies for ballerina programs generated. You may find the source code for this
module [here](shell-rt).
module [here](modules/shell-rt).
- **shell-core** - Module including all the base evaluation classes. This has all the base components to evaluate and run a
string. All other components are built on top of this module. You may find the source code for this
module [here](shell-core).
module [here](modules/shell-core).
- **shell-cli** - A command-line interface built on top of shell. Includes multi-line inputs, color-coded outputs,
keyword-based auto-completion, etc... You may find the source code for this module [here](shell-cli).
keyword-based auto-completion, etc... You may find the source code for this module [here](modules/shell-cli).

## Known Issues

Expand Down Expand Up @@ -103,7 +103,7 @@ The project is implemented in three base modules.

## Implementation

For implementation details please refer [this](shell-core/README.md).
For implementation details please refer [this](modules/shell-core/README.md).

## Building

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -62,8 +61,8 @@ public TestIntegrator(InputStream inputStream, OutputStream outputStream, ByteAr
@Override
public void run() {
try {
PrintStream testPrint = new PrintStream(outputStream, true, Charset.defaultCharset());
InputStreamReader inStreamReader = new InputStreamReader(inputStream, Charset.defaultCharset());
PrintStream testPrint = new PrintStream(outputStream, true, StandardCharsets.UTF_8);
InputStreamReader inStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
BufferedReader testReader = new BufferedReader(inStreamReader);

// The response here is not testable because it can change.
Expand Down Expand Up @@ -117,9 +116,8 @@ private String readResponse(BufferedReader stream) throws IOException {
* Send the data given to the specific stream.
*/
private void sendRequest(PrintStream stream, String string) throws InterruptedException {
stream.append(string);
stream.println(System.lineSeparator());
stream.flush();
// This is a workaround since with double `System.lineSeparator()` the tests fail on windows.
stream.append(string).append("\n\n").flush();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.PrintStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.List;

/**
Expand All @@ -54,7 +54,7 @@ protected void test(String fileName) throws Exception {
PrintStream origOut = System.out;
try {
ByteArrayOutputStream stdOut = new ByteArrayOutputStream();
PrintStream interceptedOutStream = new PrintStream(stdOut, true, Charset.defaultCharset());
PrintStream interceptedOutStream = new PrintStream(stdOut, true, StandardCharsets.UTF_8);
System.setOut(interceptedOutStream);

TestIntegrator testIntegrator = new TestIntegrator(testIn, testOut, stdOut, testCases);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.ballerina.compiler.syntax.tree.ExpressionNode;
import io.ballerina.compiler.syntax.tree.Node;
import io.ballerina.compiler.syntax.tree.NodeParser;
import io.ballerina.shell.parser.ParserConstants;
import io.ballerina.shell.parser.TrialTreeParser;

import java.util.ArrayList;
Expand Down Expand Up @@ -57,7 +58,16 @@ public Collection<Node> parse(String source) throws ParserTrialFailedException {
if (expressionNode.hasDiagnostics()) {
throw new ParserTrialFailedException("Error occurred during extracting expression from the statement");
}
validateExpression(expressionNode.toSourceCode());
nodes.add(expressionNode);
return nodes;
}

private void validateExpression(String expression) {
String functionName = expression.replaceAll("\\s*\\(.*", "");
if (ParserConstants.isFunctionNameRestricted(functionName)) {
String message = String.format("Function name '%s' not allowed in Ballerina Shell.%n", functionName);
throw new InvalidMethodException(message);
}
}
}
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ plugins {
apply from: "$rootDir/gradle/repositories.gradle"

allprojects {
tasks.withType(JavaCompile).configureEach {
options.fork = true
}

group = project.group
version = project.version

Expand Down Expand Up @@ -144,4 +148,3 @@ sonarqube {
}

copyBallerinaClassFiles.dependsOn copyExecFilesAndJavaClassFiles
createCodeCoverageReport.dependsOn copyBallerinaClassFiles
18 changes: 5 additions & 13 deletions bvm/ballerina-profiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

apply from: "$rootDir/gradle/javaProject.gradle"

configurations {
runtimeClasspath.transitive = false
}

dependencies {
implementation "org.ow2.asm:asm:${project.ow2AsmVersion}"
implementation "org.ow2.asm:asm-commons:${project.ow2AsmCommonsVersion}"
Expand All @@ -30,20 +34,8 @@ dependencies {
version = 1.0

jar {
dependsOn(':identifier-util:jar')
dependsOn(':ballerina-runtime:jar')
from(sourceSets.main.output)
from(sourceSets.main.java) {
include "**/*.java"
}

from(configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }) {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
manifest {
attributes 'Main-Class': 'io.ballerina.runtime.profiler.Main'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ public interface Repository {
* Get the list of runtime artifacts.
* @return List of artifacts that contains information about the active services and listeners.
*/
public List<Artifact> getArtifacts();
List<Artifact> getArtifacts();

/**
* Get the current Ballerina node.
* @return Ballerina node.
*/
public Node getNode();
Node getNode();

/**
* Get whether remote management is enabled.
* @return True if remote management is enabled, false otherwise.
*/
boolean isRemoteManagementEnabled();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.ballerina.runtime.api.types.ResourceMethodType;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BString;
import io.ballerina.runtime.internal.scheduling.Strand;
import io.ballerina.runtime.internal.types.BAnnotatableType;
Expand Down Expand Up @@ -58,7 +59,13 @@ public static void processAnnotations(MapValue globalAnnotMap, Type bType) {
type.setAnnotations((MapValue<BString, Object>) globalAnnotMap.get(annotationKey));
}

if (type.getTag() != TypeTags.OBJECT_TYPE_TAG && type.getTag() != TypeTags.SERVICE_TAG) {
if (type.getTag() == TypeTags.TYPE_REFERENCED_TYPE_TAG) {
Type impliedType = TypeUtils.getImpliedType(type);
if (isNonObjectType(impliedType.getTag())) {
return;
}
type = (BAnnotatableType) impliedType;
} else if (isNonObjectType(type.getTag())) {
return;
}
BObjectType objectType = (BObjectType) type;
Expand All @@ -75,6 +82,10 @@ public static void processAnnotations(MapValue globalAnnotMap, Type bType) {
}
}

private static boolean isNonObjectType(int impliedTypeTag) {
return impliedTypeTag != TypeTags.OBJECT_TYPE_TAG && impliedTypeTag != TypeTags.SERVICE_TAG;
}

private static void setMethodAnnotations(MapValue<BString, Object> globalAnnotMap, BString annotationKey,
BMethodType resourceMethod) {
if (globalAnnotMap.containsKey(annotationKey)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class RepositoryImpl implements Repository {
private static final String nodeId = generateNodeId();
private static String balHome;
private static String balVersion;
private static boolean isRemoteEnabled = false;
private static boolean isRemoteManagementEnabled = false;

@Override
public List<Artifact> getArtifacts() {
Expand Down Expand Up @@ -72,6 +72,11 @@ public Node getNode() {
System.getProperty("os.version"));
}

@Override
public boolean isRemoteManagementEnabled() {
return isRemoteManagementEnabled;
}

private Artifact createArtifact(ObjectValue service, ObjectValue listener) {
ArtifactImpl artifact = new ArtifactImpl(service.toString(), Artifact.ArtifactType.SERVICE);
List<ObjectValue> listeners = (List<ObjectValue>) artifact.getDetail("listeners");
Expand All @@ -87,7 +92,7 @@ private Artifact createArtifact(ObjectValue service, ObjectValue listener) {
}

public static void addServiceListener(BObject listener, BObject service, Object attachPoint) {
if (!isRemoteEnabled) {
if (!isRemoteManagementEnabled) {
return;
}
BServiceType serviceType = (BServiceType) service.getType();
Expand All @@ -96,10 +101,11 @@ public static void addServiceListener(BObject listener, BObject service, Object
listenerServiceMap.put((ObjectValue) listener, (ObjectValue) service);
}

public static void addBallerinaRuntimeInformation(String balHome, String balVersion, boolean isRemoteEnabled) {
public static void addBallerinaRuntimeInformation(String balHome, String balVersion,
boolean isRemoteManagementEnabled) {
RepositoryImpl.balHome = balHome;
RepositoryImpl.balVersion = balVersion;
RepositoryImpl.isRemoteEnabled = isRemoteEnabled;
RepositoryImpl.isRemoteManagementEnabled = isRemoteManagementEnabled;
}

private static String generateNodeId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public interface ArrayValue extends RefValue, BArray, CollectionValue {
@Override
Object shift(long index);

Object pop(long index);

Object remove(long index);

@Override
void setLength(long length);
}
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,16 @@ public void append(Object value) {
add(this.size, value);
}

@Override
public Object pop(long index) {
return shift(index);
}

@Override
public Object remove(long index) {
return shift(index);
}

@Override
public Object shift(long index) {
handleImmutableArrayValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,20 @@ public void append(Object value) {

@Override
public Object shift(long index) {
return shift(index, "shift");
}

public Object pop(long index) {
return shift(index, "pop");
}

public Object remove(long index) {
return shift(index, "remove");
}

public Object shift(long index, String operation) {
handleImmutableArrayValue();
validateTupleSizeAndInherentType();
validateTupleSizeAndInherentType((int) index, operation);
Object val = get(index);
shiftArray((int) index);
return val;
Expand Down Expand Up @@ -827,15 +839,15 @@ private void resetSize(int index) {
}
}

private void validateTupleSizeAndInherentType() {
private void validateTupleSizeAndInherentType(int index, String operation) {
List<Type> tupleTypesList = this.tupleType.getTupleTypes();
int numOfMandatoryTypes = tupleTypesList.size();
if (numOfMandatoryTypes >= this.getLength()) {
throw ErrorHelper.getRuntimeException(getModulePrefixedReason(ARRAY_LANG_LIB,
OPERATION_NOT_SUPPORTED_IDENTIFIER), ErrorCodes.INVALID_TUPLE_MEMBER_SIZE, "shift");
OPERATION_NOT_SUPPORTED_IDENTIFIER), ErrorCodes.INVALID_TUPLE_MEMBER_SIZE, operation);
}
// Check if value belonging to i th type can be assigned to i-1 th type (Checking done by value, not type)
for (int i = 1; i <= numOfMandatoryTypes; i++) {
for (int i = index + 1; i <= numOfMandatoryTypes; i++) {
if (!TypeChecker.checkIsType(this.getRefValue(i), tupleTypesList.get(i - 1))) {
throw ErrorHelper.getRuntimeException(getModulePrefixedReason(ARRAY_LANG_LIB,
INHERENT_TYPE_VIOLATION_ERROR_IDENTIFIER), ErrorCodes.INCOMPATIBLE_TYPE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,6 @@ public class TransactionConstants {

public static final String ANN_NAME_TRX_PARTICIPANT_CONFIG = "Participant";
public static final String TIMESTAMP_OBJECT_VALUE_FIELD = "timeValue";
public static final int DEFAULT_TRX_AUTO_COMMIT_TIMEOUT = 120;
public static final int DEFAULT_TRX_CLEANUP_TIMEOUT = 600;
}
Loading

0 comments on commit 475d1e3

Please sign in to comment.