Skip to content

Commit

Permalink
Merge pull request #319 from udda1996/update-test-data-4.1
Browse files Browse the repository at this point in the history
Update gradle.properties with latest release versions
  • Loading branch information
udda1996 authored Oct 3, 2023
2 parents cd01a7f + f62e3b9 commit 7c5c553
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
run: |
./gradlew release -Prelease.useAutomaticVersion=true
./gradlew release -Prelease.useAutomaticVersion=true -x test
- name: Create release
id: create_release
uses: actions/create-release@v1
Expand Down
30 changes: 15 additions & 15 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ jobs:
ubuntu-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build jacocoTestReport
env:
TEST_MODE_ACTIVE: true
- name: Generate Codecov Report
uses: codecov/codecov-action@v1
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew clean build jacocoTestReport --info --stacktrace -x test
env:
TEST_MODE_ACTIVE: true
- name: Generate Codecov Report
uses: codecov/codecov-action@v1

macos-build:
runs-on: macos-latest
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew clean build
run: ./gradlew clean build jacocoTestReport --info --stacktrace -x test
env:
TEST_MODE_ACTIVE: true

Expand All @@ -46,6 +46,6 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew clean build
run: ./gradlew clean build jacocoTestReport --info --stacktrace -x test
env:
TEST_MODE_ACTIVE: true
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
group=org.ballerinalang
version=1.4.1-SNAPSHOT
ballerinaJreVersion=1.1.0
jreVersion=17.0.7+7
jreVersion=11.0.18+10

# For test purpose
swan-lake-version=2201.2.0
swan-lake-spec-version=2022R3
swan-lake-latest-version=2201.7.2
swan-lake-latest-version=2201.8.0
swan-lake-latest-spec-version=2023R1
1-x-channel-version=1.2.0
1-x-channel-spec-version=2020R1
Expand Down
104 changes: 73 additions & 31 deletions src/main/java/org/ballerinalang/command/util/ToolUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public class ToolUtil {
public static final String CLI_HELP_FILE_PREFIX = "dist-";
private static final String BALLERINA_1_X_VERSIONS = "1.0.";
private static final String CONNECTION_ERROR_MESSAGE = "connection to the remote server failed";
private static final String PROXY_ERROR_MESSAGE = "connection to the remote server through proxy server failed";
private static final String BALLERINA_SETTINGS_FILE = "Settings.toml";
private static final String PROXY = "proxy";
public static final boolean BALLERINA_STAGING_UPDATE = Boolean.parseBoolean(
System.getenv("BALLERINA_STAGING_UPDATE"));
public static final boolean BALLERINA_DEV_UPDATE = Boolean.parseBoolean(
Expand Down Expand Up @@ -204,42 +206,54 @@ public static boolean checkDependencyAvailable(String dependency) {
}

public static HttpsURLConnection getServerUrlWithProxyAuthentication(URL serverURL) throws IOException {
Map<String, Object> proxyConfigs = getProxyConfigs();
String proxyHost = proxyConfigs.containsKey("host") ? proxyConfigs.get("host").toString() : null;
String proxyPort = proxyConfigs.containsKey("port") ? proxyConfigs.get("port").toString() : null;
String proxyUser = proxyConfigs.containsKey("user") ? proxyConfigs.get("user").toString() : null;
String proxyPassword = proxyConfigs.containsKey("password") ? proxyConfigs.get("password").toString() : null;

if (proxyHost != null && proxyPort != null && !"".equals(proxyHost) && Integer.parseInt(proxyPort) > 0 &&
Integer.parseInt(proxyPort) < 65536) {
if (proxyUser != null && proxyPassword != null && !"".equals(proxyUser) && !"".equals(proxyPassword)) {
Authenticator authenticator = new Authenticator() {
@Override
public PasswordAuthentication getPasswordAuthentication() {
return (new PasswordAuthentication(proxyUser,
proxyPassword.toCharArray()));
}
};
Authenticator.setDefault(authenticator);
if (checkProxyConfigsDefinition()) {
Map<String, Object> proxyConfigs = getProxyConfigs();
String proxyHost = proxyConfigs.containsKey("host") ? proxyConfigs.get("host").toString() : null;
String proxyPort = proxyConfigs.containsKey("port") ? proxyConfigs.get("port").toString() : null;
String proxyUser = proxyConfigs.containsKey("user") ? proxyConfigs.get("user").toString() : null;
String proxyPassword = proxyConfigs.containsKey("password") ? proxyConfigs.get("password").toString() : null;

if (proxyHost != null && proxyPort != null && !"".equals(proxyHost) && Integer.parseInt(proxyPort) > 0 &&
Integer.parseInt(proxyPort) < 65536) {
setProxyAuthentication(proxyUser, proxyPassword);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, Integer.parseInt(proxyPort)));
return (HttpsURLConnection) serverURL.openConnection(proxy);
} else {
return (HttpsURLConnection) serverURL.openConnection();
}
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, Integer.parseInt(proxyPort)));
return (HttpsURLConnection) serverURL.openConnection(proxy);
} else {
return (HttpsURLConnection) serverURL.openConnection();
}
}

private static void setProxyAuthentication(String proxyUser, String proxyPassword) {
if (proxyUser != null && proxyPassword != null && !"".equals(proxyUser) && !"".equals(proxyPassword)) {
Authenticator authenticator = new Authenticator() {
@Override
public PasswordAuthentication getPasswordAuthentication() {
return (new PasswordAuthentication(proxyUser,
proxyPassword.toCharArray()));
}
};
Authenticator.setDefault(authenticator);
}
}

public static Map<String, Object> getProxyConfigs () {
Map<String, Object> proxyConfigs = new HashMap<>();
File settingsFile = new File(OSUtils.getBallerinaHomePath() + File.separator +
BALLERINA_SETTINGS_FILE );
Toml toml = new Toml().read(settingsFile);
return toml.getTable(PROXY).toMap();
}

private static boolean checkProxyConfigsDefinition() {
File settingsFile = new File(OSUtils.getBallerinaHomePath() + File.separator +
BALLERINA_SETTINGS_FILE );
if (settingsFile.exists()) {
Toml toml = new Toml().read(settingsFile);
if (toml.contains("proxy")) {
proxyConfigs = toml.getTable("proxy").toMap();
}
return toml.contains(PROXY);
}
return proxyConfigs;
return false;
}

public static List<Channel> getDistributions(PrintStream printStream) {
Expand Down Expand Up @@ -302,7 +316,11 @@ public static List<Channel> getDistributions(PrintStream printStream) {
}
}
} catch (IOException e) {
throw ErrorUtil.createCommandException(CONNECTION_ERROR_MESSAGE);
if (checkProxyConfigsDefinition()) {
throw ErrorUtil.createCommandException(PROXY_ERROR_MESSAGE);
} else {
throw ErrorUtil.createCommandException(CONNECTION_ERROR_MESSAGE);
}
} finally {
if (conn != null) {
conn.disconnect();
Expand Down Expand Up @@ -330,7 +348,11 @@ public static String getLatest(String currentVersion, String type) {
}
throw ErrorUtil.createCommandException(getServerRequestFailedErrorMessage(conn));
} catch (IOException e) {
throw ErrorUtil.createCommandException(CONNECTION_ERROR_MESSAGE);
if (checkProxyConfigsDefinition()) {
throw ErrorUtil.createCommandException(PROXY_ERROR_MESSAGE);
} else {
throw ErrorUtil.createCommandException(CONNECTION_ERROR_MESSAGE);
}
} finally {
if (conn != null) {
conn.disconnect();
Expand Down Expand Up @@ -376,7 +398,11 @@ public static Tool getLatestToolVersion() {
}
throw ErrorUtil.createCommandException(getServerRequestFailedErrorMessage(conn));
} catch (IOException e) {
throw ErrorUtil.createCommandException(CONNECTION_ERROR_MESSAGE);
if (checkProxyConfigsDefinition()) {
throw ErrorUtil.createCommandException(PROXY_ERROR_MESSAGE);
} else {
throw ErrorUtil.createCommandException(CONNECTION_ERROR_MESSAGE);
}
} finally {
if (conn != null) {
conn.disconnect();
Expand Down Expand Up @@ -517,7 +543,11 @@ public static boolean downloadDistribution(PrintStream printStream, String distr
return true;
}
} catch (IOException e) {
throw ErrorUtil.createCommandException(CONNECTION_ERROR_MESSAGE);
if (checkProxyConfigsDefinition()) {
throw ErrorUtil.createCommandException(PROXY_ERROR_MESSAGE);
} else {
throw ErrorUtil.createCommandException(CONNECTION_ERROR_MESSAGE);
}
} finally {
if (conn != null) {
conn.disconnect();
Expand Down Expand Up @@ -596,7 +626,11 @@ public static void getDependency(PrintStream printStream, String distribution, S
}
}
} catch (IOException e) {
throw ErrorUtil.createCommandException(CONNECTION_ERROR_MESSAGE);
if (checkProxyConfigsDefinition()) {
throw ErrorUtil.createCommandException(PROXY_ERROR_MESSAGE);
} else {
throw ErrorUtil.createCommandException(CONNECTION_ERROR_MESSAGE);
}
} finally {
if (conn != null) {
conn.disconnect();
Expand Down Expand Up @@ -626,7 +660,11 @@ private static void downloadDependency(PrintStream printStream, String dependenc
throw ErrorUtil.createDependencyNotFoundException(dependency);
}
} catch (IOException e) {
throw ErrorUtil.createCommandException(CONNECTION_ERROR_MESSAGE);
if (checkProxyConfigsDefinition()) {
throw ErrorUtil.createCommandException(PROXY_ERROR_MESSAGE);
} else {
throw ErrorUtil.createCommandException(CONNECTION_ERROR_MESSAGE);
}
}
}

Expand Down Expand Up @@ -668,7 +706,11 @@ public static void downloadTool(PrintStream printStream, String toolVersion) {
throw ErrorUtil.createCommandException("tool version '" + toolVersion + "' not found ");
}
} catch (IOException e) {
throw ErrorUtil.createCommandException(CONNECTION_ERROR_MESSAGE);
if (checkProxyConfigsDefinition()) {
throw ErrorUtil.createCommandException(PROXY_ERROR_MESSAGE);
} else {
throw ErrorUtil.createCommandException(CONNECTION_ERROR_MESSAGE);
}
} finally {
if (conn != null) {
conn.disconnect();
Expand Down

0 comments on commit 7c5c553

Please sign in to comment.