Skip to content

Commit

Permalink
Merge pull request #5912 from ballerina-platform/readme-proj-api-fix-2
Browse files Browse the repository at this point in the history
Fix project API failures and re-enable project API tests
  • Loading branch information
gayaldassanayake authored Jan 3, 2025
2 parents 5b4d28a + e8c5154 commit 97ef75e
Show file tree
Hide file tree
Showing 27 changed files with 62 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/daily-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ jobs:
project-api-tests:

runs-on: ubuntu-latest
if: false
if: github.repository_owner == 'ballerina-platform'

steps:
- name: Checkout Repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,8 @@ private void updatePackageJsonBallerinaVersion(Path packagePath, String balVersi

// Update the value for the given key
jsonObject.addProperty("ballerina_version", balVersion);
jsonObject.addProperty("platform", "java17");
jsonObject.remove("readme");
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String formattedJson = gson.toJson(jsonObject);
Files.writeString(packageJsonPath, formattedJson);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.nio.file.StandardOpenOption.APPEND;
import static org.ballerina.projectapi.CentralTestUtils.BALLERINA_ARTIFACT_TYPE;
import static org.ballerina.projectapi.CentralTestUtils.BALLERINA_HOME_DIR;
import static org.ballerina.projectapi.CentralTestUtils.BALLERINA_TOML;
Expand Down Expand Up @@ -227,9 +228,8 @@ public void testUpdatedPackage() throws IOException, InterruptedException {
// Add a module to the package
addNewModule(importedPackageName, "doc.api", "mod.api");
// Update version details in Ballerina.toml
updateBallerinaToml(importedPackageName, COMMON_VERSION, updatedVersion,
"\"" + importedPackageName + ".mod.api\"",
"\"" + importedPackageName + ".mod.api\", \"" + importedPackageName + ".doc.api\"");
updateBallerinaToml(importedPackageName, COMMON_VERSION, updatedVersion, "", "");
addExports(importedPackageName, new String[]{importedPackageName + ".doc.api"});
// Build the bala for updated package
buildPackageBala(tempWorkspaceDirectory, envVariables, importedPackageName, orgName, updatedVersion,
Collections.emptyList());
Expand Down Expand Up @@ -422,6 +422,18 @@ private void updateBallerinaToml(String packageName, String previousVersion, Str
lines.close();
}

private void addExports(String packageName, String[] moduleNames) throws IOException {
Path filePath = tempWorkspaceDirectory.resolve(packageName).resolve(BALLERINA_TOML);
List<String> exports = new ArrayList<>();
for (String mod : moduleNames) {
exports.add("\n");
exports.add("[[package.modules]]");
exports.add("name = \"" + mod + "\"");
exports.add("export = true");
}
Files.write(filePath, exports, APPEND);
}

private void updateImports(String packageName, String s, String fileName) throws IOException {
Path filePath = tempWorkspaceDirectory.resolve(packageName).resolve(fileName);
Stream<String> lines = Files.lines(filePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
org = "bctestorg"
name = "disttestpackage"
version = "1.0.0"
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
org = "bctestorg"
name = "disttestpackage"
version = "1.0.1"
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
org = "bctestorg"
name = "disttestpackage"
version = "1.0.4"
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
org = "bctestorg"
name = "disttestpackage"
version = "1.1.0"
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
org = "bctestorg"
name = "my_package"
version = "1.0.0"
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
org = "bctestorg"
name = "my_package"
version = "1.0.0"
readme = "Package.md"

[platform.java21]
graalvmCompatible=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
org = "bctestorg"
name = "my_package"
version = "1.0.0"
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
org = "bctestorg"
name = "my_package"
version = "1.0.0"
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
org = "bctestorg"
name = "my_package"
version = "1.0.0"
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
org = "bctestorg"
name = "my_package"
version = "1.0.0"
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
org = "bctestorg"
name = "my_package"
version = "1.0.0"
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
org = "bctestorg"
name = "my_package"
version = "1.0.0-snapshot"
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
org = "bctestorg"
name = "disttestmultiples"
version = "1.1.1"
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
org = "bctestorg"
name = "disttestpack1"
version = "1.1.0"
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@
org = "bctestorg"
name = "PackageH.test.mod"
version = "1.0.1"
export = ["PackageH.test.mod.api", "PackageH.test.mod.api.doc"]
readme = "Package.md"

[[package.modules]]
name = "PackageH.test.mod.api"
export = true

[[package.modules]]
name = "PackageH.test.mod.api.doc"
export = true
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
org = "bctestorg"
name = "PackageH.test"
version = "1.0.0"
export = ["PackageH.test.mod.api"]
readme = "Package.md"

[[package.modules]]
name = "PackageH.test.mod.api"
export = true
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
org = "bctestorg"
name = "PackageJ.test"
version = "1.0.0"

export=["PackageJ.test"]
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
org = "bctestorg"
name = "PackageL.test"
version = "1.0.0"
export = ["PackageL.test.mod.api"]
readme = "Package.md"

[[package.modules]]
name = "PackageL.test.mod.api"
export = true
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
org = "bctestorg"
name = "PackageO.test"
version = "1.0.0"
export = ["PackageO.test"]
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
org = "bctestorg"
name = "PackageQ.test"
version = "1.0.0"
export = ["PackageQ.test.mod.api"]
readme = "Package.md"

[[package.modules]]
name = "PackageQ.test.mod.api"
export = true
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
org = "bctestorg"
name = "PackageR.test"
version = "1.0.0"
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
org = "bctestorg"
name = "PackageT.test"
version = "1.0.0-beta.1"
export = ["PackageT.test"]
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
org = "bctestorg"
name = "Transitive.PackageH.test"
version = "1.0.0"
export = ["Transitive.PackageH.test"]
readme = "Package.md"
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
org = "bctestorg"
name = "pact"
version = "0.2.0"
readme = "Package.md"

[build-options]
observabilityIncluded = true

0 comments on commit 97ef75e

Please sign in to comment.