Skip to content

Commit

Permalink
Merge pull request #347 from Bhashinee/updateWorkFlows
Browse files Browse the repository at this point in the history
Update the PR build workflow
  • Loading branch information
Bhashinee committed Apr 9, 2024
2 parents a608181 + 713aca4 commit e51a869
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 62 deletions.
54 changes: 11 additions & 43 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,14 @@
name: PR build
name: PR Build

on: pull_request
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true

jobs:
ubuntu-build:
name: Build on Ubuntu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17.0.7
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
packagePAT: ${{ secrets.GITHUB_TOKEN }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}
run: ./gradlew build
- name: Generate CodeCov Report
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
on: [pull_request]

windows-build:
name: Build on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17.0.7
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
packagePAT: ${{ secrets.GITHUB_TOKEN }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}
# Issue for enabling testcases: https://github.com/ballerina-platform/ballerina-standard-library/issues/4452
run: ./gradlew.bat build
jobs:
call_workflow:
name: Run PR Build Workflow
if: ${{ github.repository_owner == 'ballerina-platform' }}
uses: ballerina-platform/ballerina-standard-library/.github/workflows/pull-request-build-template.yml@main
secrets: inherit
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,28 @@ public void testBuildWithMysql() throws IOException, InterruptedException {
String log = "Persist client and entity types generated successfully in " +
"the persist_build_1 directory.";
Path project = TARGET_DIR.resolve("generated-sources/tool_test_build_1");
assertLogs(log, project);
assertContainLogs(log, project);
}

@Test(enabled = true)
public void testBuildWithInvalidTargetModule() throws IOException, InterruptedException {
String log = "ERROR: invalid module name : 'persist_add_1' :" + System.lineSeparator() +
"module name should follow the template <package_name>.<module_name>";
String log = "ERROR: invalid module name : 'persist_add_1' :";
Path project = TARGET_DIR.resolve("generated-sources/tool_test_build_2");
assertLogs(log, project);
assertContainLogs(log, project);
}

@Test(enabled = true)
public void testBuildWithInvalidCharachtersInTargetModule() throws IOException, InterruptedException {
String log = "ERROR: invalid module name : '*****' :" + System.lineSeparator() +
"module name can only contain alphanumerics, underscores and periods";
String log = "ERROR: invalid module name : '*****' :";
Path project = TARGET_DIR.resolve("generated-sources/tool_test_build_3");
assertLogs(log, project);
assertContainLogs(log, project);
}

@Test(enabled = true)
public void testBuildWithInvalidLengthOfTargetModule() throws IOException, InterruptedException {
String log = "ERROR: invalid module name : 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
"aaaaaaaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" +
"ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" +
"dddddddddddddddddddddd' :" + System.lineSeparator() +
"maximum length of module name is 256 characters";
String log = "ERROR: invalid module name :";
Path project = TARGET_DIR.resolve("generated-sources/tool_test_build_4");
assertLogs(log, project);
assertContainLogs(log, project);
}

@Test(enabled = true)
Expand All @@ -85,7 +79,7 @@ public void testBuildWithInvalidDataSource() throws IOException, InterruptedExce
public void testBuildWithoutEntities() throws IOException, InterruptedException {
String log = "ERROR: the model definition file(model.bal) does not contain any entity definition.";
Path project = TARGET_DIR.resolve("generated-sources/tool_test_build_6");
assertLogs(log, project);
assertContainLogs(log, project);
}

private String collectLogOutput(Path project) throws IOException, InterruptedException {
Expand All @@ -100,11 +94,6 @@ private String collectLogOutput(Path project) throws IOException, InterruptedExc
}
}

private void assertLogs(String log, Path project) throws IOException, InterruptedException {
String generatedLog = collectLogOutput(project);
Assert.assertEquals(generatedLog, log);
}

private void assertContainLogs(String log, Path project) throws IOException, InterruptedException {
String generatedLog = collectLogOutput(project);
Assert.assertTrue(generatedLog.contains(log));
Expand Down

0 comments on commit e51a869

Please sign in to comment.