From 4c4bed2620446003c748f45a46f9feb02b392097 Mon Sep 17 00:00:00 2001 From: Nipuna Fernando Date: Sat, 12 Aug 2023 00:03:04 +0530 Subject: [PATCH 1/5] Build the examples --- .gitignore | 1 + README.md | 5 +- {calendar => ballerina}/.gitignore | 0 {calendar => ballerina}/Ballerina.toml | 0 {calendar => ballerina}/Module.md | 0 {calendar => ballerina}/Package.md | 0 {calendar => ballerina}/client.bal | 0 {calendar => ballerina}/constants.bal | 0 .../docs/images/Outlook_calendar.png | Bin .../docs/images/outlook-calendar.png | Bin {calendar => ballerina}/icon.png | Bin .../stream_implementer.bal | 0 {calendar => ballerina}/tests/test.bal | 0 {calendar => ballerina}/types.bal | 0 {calendar => ballerina}/utils.bal | 0 examples/README.md | 34 +++++++++++++ {samples => examples}/add_event.bal | 0 examples/build.sh | 47 ++++++++++++++++++ {samples => examples}/create_calendar.bal | 4 +- {samples => examples}/create_event.bal | 26 +++++----- {samples => examples}/delete_calendar.bal | 4 +- {samples => examples}/delete_event.bal | 4 +- {samples => examples}/get_calendar.bal | 2 +- {samples => examples}/get_event.bal | 0 {samples => examples}/list_calendar.bal | 2 +- {samples => examples}/list_event.bal | 10 ++-- {samples => examples}/update_calendar.bal | 4 +- {samples => examples}/update_event.bal | 42 ++++++++-------- 28 files changed, 135 insertions(+), 50 deletions(-) rename {calendar => ballerina}/.gitignore (100%) rename {calendar => ballerina}/Ballerina.toml (100%) rename {calendar => ballerina}/Module.md (100%) rename {calendar => ballerina}/Package.md (100%) rename {calendar => ballerina}/client.bal (100%) rename {calendar => ballerina}/constants.bal (100%) rename {calendar => ballerina}/docs/images/Outlook_calendar.png (100%) rename {calendar => ballerina}/docs/images/outlook-calendar.png (100%) rename {calendar => ballerina}/icon.png (100%) rename {calendar => ballerina}/stream_implementer.bal (100%) rename {calendar => ballerina}/tests/test.bal (100%) rename {calendar => ballerina}/types.bal (100%) rename {calendar => ballerina}/utils.bal (100%) create mode 100644 examples/README.md rename {samples => examples}/add_event.bal (100%) create mode 100755 examples/build.sh rename {samples => examples}/create_calendar.bal (92%) rename {samples => examples}/create_event.bal (79%) rename {samples => examples}/delete_calendar.bal (90%) rename {samples => examples}/delete_event.bal (90%) rename {samples => examples}/get_calendar.bal (94%) rename {samples => examples}/get_event.bal (100%) rename {samples => examples}/list_calendar.bal (94%) rename {samples => examples}/list_event.bal (80%) rename {samples => examples}/update_calendar.bal (94%) rename {samples => examples}/update_event.bal (62%) diff --git a/.gitignore b/.gitignore index 5be4007..4a458c5 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ .mtj.tmp/ # Package Files # +*.jar *.war *.nar *.ear diff --git a/README.md b/README.md index c2559f4..b972bc5 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ Ballerina Microsoft Outlook Connector ====================================== [![Build Status](https://github.com/ballerina-platform/module-ballerinax-microsoft.outlook.calendar/workflows/CI/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-microsoft.outlook.calendar/actions?query=workflow%3ACI) +[![codecov](https://codecov.io/gh/ballerina-platform/module-ballerinax-microsoft.outlook.calendar/branch/main/graph/badge.svg)](https://codecov.io/gh/ballerina-platform/module-ballerinax-microsoft.outlook.calendar) [![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerinax-microsoft.outlook.calendar.svg)](https://github.com/ballerina-platform/module-ballerinax-microsoft.outlook.calendar/commits/master) [![GraalVM Check](https://github.com/ballerina-platform/module-ballerinax-microsoft.outlook.calendar/actions/workflows/build-with-bal-test-native.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-microsoft.outlook.calendar/actions/workflows/build-with-bal-test-native.yml) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) @@ -29,11 +30,11 @@ Execute the commands below to build from the source. 1. To build the package: ``` - bal pack ./calendar + bal build ./ballerina ``` 2. To run the tests after build: ``` - bal test ./calendar + bal test ./ballerina ``` ## Contributing to Ballerina As an open source project, Ballerina welcomes contributions from the community. diff --git a/calendar/.gitignore b/ballerina/.gitignore similarity index 100% rename from calendar/.gitignore rename to ballerina/.gitignore diff --git a/calendar/Ballerina.toml b/ballerina/Ballerina.toml similarity index 100% rename from calendar/Ballerina.toml rename to ballerina/Ballerina.toml diff --git a/calendar/Module.md b/ballerina/Module.md similarity index 100% rename from calendar/Module.md rename to ballerina/Module.md diff --git a/calendar/Package.md b/ballerina/Package.md similarity index 100% rename from calendar/Package.md rename to ballerina/Package.md diff --git a/calendar/client.bal b/ballerina/client.bal similarity index 100% rename from calendar/client.bal rename to ballerina/client.bal diff --git a/calendar/constants.bal b/ballerina/constants.bal similarity index 100% rename from calendar/constants.bal rename to ballerina/constants.bal diff --git a/calendar/docs/images/Outlook_calendar.png b/ballerina/docs/images/Outlook_calendar.png similarity index 100% rename from calendar/docs/images/Outlook_calendar.png rename to ballerina/docs/images/Outlook_calendar.png diff --git a/calendar/docs/images/outlook-calendar.png b/ballerina/docs/images/outlook-calendar.png similarity index 100% rename from calendar/docs/images/outlook-calendar.png rename to ballerina/docs/images/outlook-calendar.png diff --git a/calendar/icon.png b/ballerina/icon.png similarity index 100% rename from calendar/icon.png rename to ballerina/icon.png diff --git a/calendar/stream_implementer.bal b/ballerina/stream_implementer.bal similarity index 100% rename from calendar/stream_implementer.bal rename to ballerina/stream_implementer.bal diff --git a/calendar/tests/test.bal b/ballerina/tests/test.bal similarity index 100% rename from calendar/tests/test.bal rename to ballerina/tests/test.bal diff --git a/calendar/types.bal b/ballerina/types.bal similarity index 100% rename from calendar/types.bal rename to ballerina/types.bal diff --git a/calendar/utils.bal b/ballerina/utils.bal similarity index 100% rename from calendar/utils.bal rename to ballerina/utils.bal diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..28ec345 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,34 @@ +# Examples + +This directory contains a collection of sample code examples written in Ballerina. These examples demonstrate various +use cases of the module. You can follow the instructions below to build and run these examples. + +## Running an Example + +Execute the following commands to build an example from the source. + +* To build an example + + `bal build ` + + +* To run an example + + `bal run ` + +## Building the Examples with the Local Module + +**Warning**: Because of the absence of support for reading local repositories for single Ballerina files, the bala of +the module is manually written to the central repository as a workaround. Consequently, the bash script may modify your +local Ballerina repositories. + +Execute the following commands to build all the examples against the changes you have made to the module locally. + +* To build all the examples + + `./build.sh build` + + +* To run all the examples + + `./build.sh run` \ No newline at end of file diff --git a/samples/add_event.bal b/examples/add_event.bal similarity index 100% rename from samples/add_event.bal rename to examples/add_event.bal diff --git a/examples/build.sh b/examples/build.sh new file mode 100755 index 0000000..5d32ff0 --- /dev/null +++ b/examples/build.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +BAL_EXAMPLES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +BAL_CENTRAL_DIR="$HOME/.ballerina/repositories/central.ballerina.io/" +BAL_HOME_DIR="$BAL_EXAMPLES_DIR/../ballerina" + +set -e + +case "$1" in +build) + BAL_CMD="build" + ;; +run) + BAL_CMD="run" + ;; +*) + echo "Invalid command provided: '$1'. Please provide 'build' or 'test' as the command." + exit 1 + ;; +esac + +# Read Ballerina package name +BAL_PACKAGE_NAME=$(awk -F'"' '/^name/ {print $2}' "$BAL_HOME_DIR/Ballerina.toml") + +# Push the package to the local repository +cd "$BAL_HOME_DIR" && + bal pack && + bal push --repository=local + +# Remove the cache directories in the repositories +cacheDirs=($(ls -d "$BAL_CENTRAL_DIR"/cache-* 2>/dev/null)) +for dir in "${cacheDirs[@]}"; do + [ -d "$dir" ] && rm -r "$dir" +done +echo "Successfully cleaned the cache directories" + +# Update the central repository +BAL_DESTINATION_DIR="$HOME/.ballerina/repositories/central.ballerina.io/bala/ballerinax/$BAL_PACKAGE_NAME" +BAL_SOURCE_DIR="$HOME/.ballerina/repositories/local/bala/ballerinax/$BAL_PACKAGE_NAME" +[ -d "$BAL_DESTINATION_DIR" ] && rm -r "$BAL_DESTINATION_DIR" +[ -d "$BAL_SOURCE_DIR" ] && cp -r "$BAL_SOURCE_DIR" "$BAL_DESTINATION_DIR" +echo "Successfully updated the local central repositories" + +# Loop through examples in the examples directory +find "$BAL_EXAMPLES_DIR" -type f -name "*.bal" | while read -r BAL_EXAMPLE_FILE; do + bal "$BAL_CMD" --offline "$BAL_EXAMPLE_FILE" +done diff --git a/samples/create_calendar.bal b/examples/create_calendar.bal similarity index 92% rename from samples/create_calendar.bal rename to examples/create_calendar.bal index 2cd95b3..fa9c7e3 100644 --- a/samples/create_calendar.bal +++ b/examples/create_calendar.bal @@ -35,11 +35,11 @@ calendar:Client calendarClient = check new (configuration); public function main() { calendar:CalendarMetadata calendarMetadata = { - name: "Ballerina-Test-Calendar" + name: "Ballerina-Test-Calendar" }; calendar:Calendar|error response = calendarClient->createCalendar(calendarMetadata); if (response is calendar:Calendar) { - log:printInfo("Calendar created with ID : " +response.id.toString()); + log:printInfo("Calendar created with ID : " + response.id.toString()); } else { log:printError(response.toString()); } diff --git a/samples/create_event.bal b/examples/create_event.bal similarity index 79% rename from samples/create_event.bal rename to examples/create_event.bal index becfc5e..9d7d0a9 100644 --- a/samples/create_event.bal +++ b/examples/create_event.bal @@ -36,7 +36,7 @@ calendar:Client calendarClient = check new (configuration); public function main() { calendar:EventMetadata eventMetadata = { subject: "Test-Subject", - body : { + body: { content: "Test-Body" }, 'start: { @@ -47,19 +47,21 @@ public function main() { dateTime: "2021-07-16T14:00:00", timeZone: calendar:TIMEZONE_LK }, - location:{ - displayName:"Harry's Bar" + location: { + displayName: "Harry's Bar" }, - attendees: [{ - emailAddress: { - address:"samanthab@contoso.onmicrosoft.com", - name: "Samantha Booth" - }, - 'type: calendar:ATTENDEE_TYPE_REQUIRED, - status: { - response : calendar:RESPONSE_NOT_RESPONDED + attendees: [ + { + emailAddress: { + address: "samanthab@contoso.onmicrosoft.com", + name: "Samantha Booth" + }, + 'type: calendar:ATTENDEE_TYPE_REQUIRED, + status: { + response: calendar:RESPONSE_NOT_RESPONDED + } } - }], + ], allowNewTimeProposals: true }; calendar:Event|error generatedEvent = calendarClient->createEvent(eventMetadata); diff --git a/samples/delete_calendar.bal b/examples/delete_calendar.bal similarity index 90% rename from samples/delete_calendar.bal rename to examples/delete_calendar.bal index aa1e354..fe45704 100644 --- a/samples/delete_calendar.bal +++ b/examples/delete_calendar.bal @@ -37,8 +37,8 @@ string calendarId = "calendarId"; public function main() { error? response = calendarClient->deleteCalendar(calendarId); if (response is error) { - log:printError("Calendar deleted with ID : " +calendarId); + log:printError("Calendar deleted with ID : " + calendarId); } else { - log:printInfo("Calendar deleted with ID : " +calendarId); + log:printInfo("Calendar deleted with ID : " + calendarId); } } diff --git a/samples/delete_event.bal b/examples/delete_event.bal similarity index 90% rename from samples/delete_event.bal rename to examples/delete_event.bal index 91606bb..c01bf96 100644 --- a/samples/delete_event.bal +++ b/examples/delete_event.bal @@ -37,8 +37,8 @@ string eventId = "eventId"; public function main() { error? response = calendarClient->deleteEvent(eventId); if (response is error) { - log:printError("Error with deleting Event with ID : " +eventId); + log:printError("Error with deleting Event with ID : " + eventId); } else { - log:printInfo("Event deleted with ID : " +eventId); + log:printInfo("Event deleted with ID : " + eventId); } } diff --git a/samples/get_calendar.bal b/examples/get_calendar.bal similarity index 94% rename from samples/get_calendar.bal rename to examples/get_calendar.bal index e4f6327..f07ab65 100644 --- a/samples/get_calendar.bal +++ b/examples/get_calendar.bal @@ -37,7 +37,7 @@ string calendarId = "calendarId"; public function main() { calendar:Calendar|error response = calendarClient->getCalendar(calendarId); if (response is calendar:Calendar) { - log:printInfo("Calendar received with ID : " +response.id.toString()); + log:printInfo("Calendar received with ID : " + response.id.toString()); } else { log:printError(response.toString()); } diff --git a/samples/get_event.bal b/examples/get_event.bal similarity index 100% rename from samples/get_event.bal rename to examples/get_event.bal diff --git a/samples/list_calendar.bal b/examples/list_calendar.bal similarity index 94% rename from samples/list_calendar.bal rename to examples/list_calendar.bal index f787cfa..89e68ab 100644 --- a/samples/list_calendar.bal +++ b/examples/list_calendar.bal @@ -36,7 +36,7 @@ calendar:Client calendarClient = check new (configuration); public function main() { stream|error eventStream = calendarClient->listCalendars(); if (eventStream is stream) { - error? e = eventStream.forEach(isolated function (calendar:Calendar calendar) { + error? e = eventStream.forEach(isolated function(calendar:Calendar calendar) { log:printInfo(calendar.id.toString()); }); } diff --git a/samples/list_event.bal b/examples/list_event.bal similarity index 80% rename from samples/list_event.bal rename to examples/list_event.bal index df06d63..71c208b 100644 --- a/samples/list_event.bal +++ b/examples/list_event.bal @@ -34,11 +34,11 @@ calendar:ConnectionConfig configuration = { calendar:Client calendarClient = check new (configuration); public function main() { - stream|error eventStream - = calendarClient->listEvents(timeZone=calendar:TIMEZONE_AD, contentType=calendar:CONTENT_TYPE_TEXT); + stream|error eventStream + = calendarClient->listEvents(timeZone = calendar:TIMEZONE_AD, contentType = calendar:CONTENT_TYPE_TEXT); if (eventStream is stream) { - error? e = eventStream.forEach(isolated function (calendar:Event event) { - log:printInfo(event.id.toString()); - }); + error? e = eventStream.forEach(isolated function(calendar:Event event) { + log:printInfo(event.id.toString()); + }); } } diff --git a/samples/update_calendar.bal b/examples/update_calendar.bal similarity index 94% rename from samples/update_calendar.bal rename to examples/update_calendar.bal index c8a83ef..4d35532 100644 --- a/samples/update_calendar.bal +++ b/examples/update_calendar.bal @@ -40,8 +40,8 @@ public function main() { boolean makeDefault = false; calendar:Calendar|error response = calendarClient->updateCalendar(calendarId, newName, newColor, makeDefault); if (response is error) { - log:printError("Error on updating the Calendar with ID : " +calendarId); + log:printError("Error on updating the Calendar with ID : " + calendarId); } else { - log:printInfo("Calendar updated with ID : " +calendarId); + log:printInfo("Calendar updated with ID : " + calendarId); } } diff --git a/samples/update_event.bal b/examples/update_event.bal similarity index 62% rename from samples/update_event.bal rename to examples/update_event.bal index 98e3dff..910170d 100644 --- a/samples/update_event.bal +++ b/examples/update_event.bal @@ -35,31 +35,31 @@ calendar:Client calendarClient = check new (configuration); string eventId = "eventId"; public function main() { - calendar:EventMetadata eventBody = { - subject : "Changed the Subject during Update Event", - isAllDay : false, // if this is true, you need to provide `Start` and `End` also. - 'start : { - dateTime : "2015-09-08T00:00:00.000Z", - timeZone : calendar:TIMEZONE_AD + calendar:EventMetadata eventBody = { + subject: "Changed the Subject during Update Event", + isAllDay: false, // if this is true, you need to provide `Start` and `End` also. + 'start: { + dateTime: "2015-09-08T00:00:00.000Z", + timeZone: calendar:TIMEZONE_AD + }, + end: { + dateTime: "2015-09-09T00:00:00.000Z", + timeZone: calendar:TIMEZONE_AD }, - end : { - dateTime : "2015-09-09T00:00:00.000Z", - timeZone : calendar: TIMEZONE_AD - }, responseStatus: { response: calendar:RESPONSE_ACCEPTED }, - recurrence : null, - importance : calendar:IMPORTANCE_HIGH, - reminderMinutesBeforeStart : 99, - isOnlineMeeting : true, - sensitivity : calendar:SENSITIVITY_PERSONAL, - showAs : calendar:SHOW_AS_BUSY, - onlineMeetingProvider : calendar:ONLINE_MEETING_PROVIDER_TYPE_TEAMS_FOR_BUSINESS, - isReminderOn : true, - hideAttendees : false, - responseRequested : true, - categories : ["Red category"] + recurrence: null, + importance: calendar:IMPORTANCE_HIGH, + reminderMinutesBeforeStart: 99, + isOnlineMeeting: true, + sensitivity: calendar:SENSITIVITY_PERSONAL, + showAs: calendar:SHOW_AS_BUSY, + onlineMeetingProvider: calendar:ONLINE_MEETING_PROVIDER_TYPE_TEAMS_FOR_BUSINESS, + isReminderOn: true, + hideAttendees: false, + responseRequested: true, + categories: ["Red category"] }; calendar:Event|error response = calendarClient->updateEvent(eventId, eventBody); if (response is calendar:Event) { From e90f51dd43f788f7138550018774088ab945b2f5 Mon Sep 17 00:00:00 2001 From: Nipuna Fernando Date: Sat, 12 Aug 2023 00:04:00 +0530 Subject: [PATCH 2/5] Update the github workflows --- .../workflows/build-with-bal-test-native.yml | 63 +++++------ .github/workflows/ci.yml | 94 +++++++++------- .github/workflows/daily-build.yml | 103 +++++++++--------- .github/workflows/dev-stg-release.yml | 75 +++++++------ .github/workflows/pull-request.yml | 42 ++++--- .github/workflows/release.yml | 53 +++++---- 6 files changed, 238 insertions(+), 192 deletions(-) diff --git a/.github/workflows/build-with-bal-test-native.yml b/.github/workflows/build-with-bal-test-native.yml index 00508dc..69ac375 100644 --- a/.github/workflows/build-with-bal-test-native.yml +++ b/.github/workflows/build-with-bal-test-native.yml @@ -1,41 +1,42 @@ name: GraalVM Check -on: +on: schedule: - cron: '30 18 * * *' workflow_dispatch: jobs: - build: - runs-on: ubuntu-latest + build: + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 + steps: + - uses: actions/checkout@v2 - - name: Set up GraalVM - uses: graalvm/setup-graalvm@v1 - with: - version: 'latest' - java-version: '11' - components: 'native-image' - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Check GraalVM installation - run: | - echo "GRAALVM_HOME: ${{ env.GRAALVM_HOME }}" - echo "JAVA_HOME: ${{ env.JAVA_HOME }}" - native-image --version - - - name: Set Up Ballerina - uses: ballerina-platform/setup-ballerina@v1.1.0 - with: - version: latest + - name: Set up GraalVM + uses: graalvm/setup-graalvm@v1 + with: + version: 'latest' + java-version: '11' + components: 'native-image' + github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Run Ballerina tests using the native executable - run: bal test --graalvm ./calendar - env: - JAVA_HOME: /usr/lib/jvm/default-jvm - REFRESH_URL: ${{ secrets.REFRESH_URL }} - REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + - name: Check GraalVM installation + run: | + echo "GRAALVM_HOME: ${{ env.GRAALVM_HOME }}" + echo "JAVA_HOME: ${{ env.JAVA_HOME }}" + native-image --version + + - name: Set Up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: latest + + - name: Run Ballerina tests using the native executable + working-directory: ./calendar + run: bal test --graalvm + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + REFRESH_URL: ${{ secrets.REFRESH_URL }} + REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12ad59e..f469646 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,48 +2,62 @@ name: CI on: push: - branches: - - '**' + branches-ignore: + - "automated/dependency_version_update" + - "automated/dependency_version_update_tmp" repository_dispatch: types: check_connector_for_breaking_changes jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Ballerina Build - uses: ballerina-platform/ballerina-action/@nightly - with: - args: - pack ./calendar - - name: Ballerina Test - uses: ballerina-platform/ballerina-action/@nightly - with: - args: - test --code-coverage ./calendar - env: - REFRESH_URL: ${{ secrets.REFRESH_URL }} - REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - - # Read the ballerina test results - - name: Read Ballerina Test Results - id: test_results - run: | - content=`cat ./calendar/target/report/test_results.json` - content="${content//'%'/'%25'}" - content="${content//$'\n'/'%0A'}" - content="${content//$'\r'/'%0D'}" - echo "::set-output name=testResultsJson::$content" - - # Print the code coverage information - - name: Code Coverage - run: | - echo "Covered Code Lines : ${{fromJson(steps.test_results.outputs.testResultsJson).coveredLines}}" - echo "Total Code Lines : $(expr ${{fromJson(steps.test_results.outputs.testResultsJson).missedLines}} + ${{fromJson(steps.test_results.outputs.testResultsJson).coveredLines}})" - echo "Code Coverage Percentage : ${{fromJson(steps.test_results.outputs.testResultsJson).coveragePercentage}}" + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + # Setup Ballerina Environment + - name: Set Up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: latest + + # Build Ballerina Project + - name: Ballerina Build + run: bal pack ./ballerina + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Build Module Examples + - name: Ballerina Examples Build + run: chmod +x ./examples/build.sh && ./examples/build.sh build + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Test Ballerina Project + - name: Ballerina Test + run: bal test ./ballerina --test-report --code-coverage --coverage-format=xml + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + REFRESH_URL: ${{ secrets.REFRESH_URL }} + REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + + # Send notification when build fails + - name: Alert notifier on failure + if: failure() && (github.event.action == 'check_connector_for_breaking_changes') + run: | + curl -X POST \ + 'https://api.github.com/repos/ballerina-platform/ballerina-release/dispatches' \ + --header 'Accept: application/vnd.github.v3+json' \ + --header 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \ + --data-raw '{ + "event_type": "notify-ballerinax-connector-build-failure", + "client_payload": { + "repoName": "module-ballerinax-microsoft.outlook.calendar", + "workflow": "CI" + } + }' diff --git a/.github/workflows/daily-build.yml b/.github/workflows/daily-build.yml index f6b30f7..0c10126 100644 --- a/.github/workflows/daily-build.yml +++ b/.github/workflows/daily-build.yml @@ -1,57 +1,58 @@ name: Daily build -# Controls when the action will run. -on: +on: schedule: - cron: '30 2 * * *' -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - # Build the ballerina project - - name: Ballerina Build - uses: ballerina-platform/ballerina-action/@nightly - with: - args: - pack ./calendar - env: - JAVA_HOME: /usr/lib/jvm/default-jvm - - # Test the ballerina project - - name: Ballerina Test - uses: ballerina-platform/ballerina-action/@nightly - with: - args: - test --code-coverage ./calendar - env: - JAVA_HOME: /usr/lib/jvm/default-jvm - REFRESH_URL: ${{ secrets.REFRESH_URL }} - REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - - # Read the ballerina test results - - name: Read Ballerina Test Results - id: test_results - run: | - content=`cat ./calendar/target/report/test_results.json` - content="${content//'%'/'%25'}" - content="${content//$'\n'/'%0A'}" - content="${content//$'\r'/'%0D'}" - echo "::set-output name=testResultsJson::$content" - - # Print the code coverage information - - name: Code Coverage - run: | - echo "Covered Code Lines : ${{fromJson(steps.test_results.outputs.testResultsJson).coveredLines}}" - echo "Total Code Lines : $(expr ${{fromJson(steps.test_results.outputs.testResultsJson).missedLines}} + ${{fromJson(steps.test_results.outputs.testResultsJson).coveredLines}})" - echo "Code Coverage Percentage : ${{fromJson(steps.test_results.outputs.testResultsJson).coveragePercentage}}" + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + # Setup Ballerina Environment + - name: Set Up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: latest + + # Build Ballerina Project + - name: Ballerina Build + run: bal pack ./ballerina + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Build Module Examples + - name: Ballerina Examples Build + run: chmod +x ./examples/build.sh && ./examples/build.sh build + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Test Ballerina Project + - name: Ballerina Test + run: bal test ./ballerina --test-report --code-coverage --coverage-format=xml + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + REFRESH_URL: ${{ secrets.REFRESH_URL }} + REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + + # Send notification when build fails + - name: Notify failure + if: ${{ failure() }} + run: | + curl -X POST \ + 'https://api.github.com/repos/ballerina-platform/ballerina-release/dispatches' \ + -H 'Accept: application/vnd.github.v3+json' \ + -H 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \ + --data "{ + \"event_type\": \"notify-build-failure\", + \"client_payload\": { + \"repoName\": \"module-ballerinax-microsoft.outlook.calendar\" + } + }" diff --git a/.github/workflows/dev-stg-release.yml b/.github/workflows/dev-stg-release.yml index 4cbe003..9febee1 100644 --- a/.github/workflows/dev-stg-release.yml +++ b/.github/workflows/dev-stg-release.yml @@ -7,41 +7,50 @@ on: description: Ballerina Central Environment type: choice options: - - STAGE - - DEV + - STAGE + - DEV required: true jobs: - release: + release: + runs-on: ubuntu-latest + env: + BALLERINA_${{ github.event.inputs.bal_central_environment }}_CENTRAL: true + steps: + - uses: actions/checkout@v2 - runs-on: ubuntu-latest - env: - BALLERINA_${{ github.event.inputs.bal_central_environment }}_CENTRAL: true + # Setup Ballerina Environment + - name: Set Up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: latest - steps: - - uses: actions/checkout@v2 - - name: Ballerina Build - uses: ballerina-platform/ballerina-action/@2201.2.1 - with: - args: - pack ./calendar - - - name: Push to Staging - uses: ballerina-platform/ballerina-action/@2201.2.1 - if: github.event.inputs.bal_central_environment == 'STAGE' - with: - args: - push - env: - WORKING_DIR: ./calendar - BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_STAGE_ACCESS_TOKEN }} - - name: Push to Dev - uses: ballerina-platform/ballerina-action/@2201.2.1 - if: github.event.inputs.bal_central_environment == 'DEV' - with: - args: - push - env: - WORKING_DIR: ./calendar - BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }} - + # Build Ballerina Project + - name: Ballerina Build + run: bal pack ./ballerina + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Build Module Examples + - name: Ballerina Examples Build + run: chmod +x ./examples/build.sh && ./examples/build.sh build + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Push to Ballerina Staging Central + - name: Push to Staging + if: github.event.inputs.bal_central_environment == 'STAGE' + run: bal push + working-directory: ./ballerina + env: + BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_STAGE_ACCESS_TOKEN }} + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Push to Ballerina Dev Central + - name: Push to Dev + if: github.event.inputs.bal_central_environment == 'DEV' + run: bal push + working-directory: ./ballerina + env: + BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }} + JAVA_HOME: /usr/lib/jvm/default-jvm diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 70dea32..699f641 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,26 +1,42 @@ -name: CI_pull_request +name: Pull Request -on: [pull_request] +on: [ pull_request ] jobs: build: - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 - - name: Ballerina Build - uses: ballerina-platform/ballerina-action/@nightly + + # Setup Ballerina Environment + - name: Set Up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 with: - args: - pack ./calendar + version: latest + + # Build Ballerina Project + - name: Ballerina Build + run: bal pack ./ballerina + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Build Module Examples + - name: Ballerina Examples Build + run: chmod +x ./examples/build.sh && ./examples/build.sh build + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Test Ballerina Project - name: Ballerina Test - uses: ballerina-platform/ballerina-action/@nightly - with: - args: - test ./calendar - env: + # tests will be skipped if the PR is from a forked repository (as the secrets are not available) + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + run: bal test ./ballerina --test-report --code-coverage --coverage-format=xml + env: + JAVA_HOME: /usr/lib/jvm/default-jvm REFRESH_URL: ${{ secrets.REFRESH_URL }} REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} CLIENT_ID: ${{ secrets.CLIENT_ID }} CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a5c0986..3b50649 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,31 +2,36 @@ name: Deployment on: release: - types: [published] + types: [ published ] jobs: - build: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 - runs-on: ubuntu-latest + # Setup Ballerina Environment + - name: Set Up Ballerina + uses: ballerina-platform/setup-ballerina@v1.1.0 + with: + version: latest - steps: - - uses: actions/checkout@v2 - - name: Ballerina Build - uses: ballerina-platform/ballerina-action/@2201.2.1 - with: - args: - pack ./calendar - env: - REFRESH_URL: ${{ secrets.REFRESH_URL }} - REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} - CLIENT_ID: ${{ secrets.CLIENT_ID }} - CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} - - name: Ballerina Push - uses: ballerina-platform/ballerina-action/@2201.2.1 - with: - args: - push - env: - WORKING_DIR: ./calendar - BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }} - \ No newline at end of file + # Build Ballerina Project + - name: Ballerina Build + run: bal pack ./ballerina + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Build Module Examples + - name: Ballerina Examples Build + run: chmod +x ./examples/build.sh && ./examples/build.sh build + env: + JAVA_HOME: /usr/lib/jvm/default-jvm + + # Push to Ballerina Central + - name: Ballerina Push + run: bal push + working-directory: ./ballerina + env: + BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }} + JAVA_HOME: /usr/lib/jvm/default-jvm From 60e05d94752cefb866000a4cad234c829ce45fab Mon Sep 17 00:00:00 2001 From: Nipuna Fernando Date: Sun, 13 Aug 2023 15:43:59 +0530 Subject: [PATCH 3/5] Update Ballerina release version --- .github/workflows/dev-stg-release.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev-stg-release.yml b/.github/workflows/dev-stg-release.yml index 9febee1..7369bed 100644 --- a/.github/workflows/dev-stg-release.yml +++ b/.github/workflows/dev-stg-release.yml @@ -23,7 +23,7 @@ jobs: - name: Set Up Ballerina uses: ballerina-platform/setup-ballerina@v1.1.0 with: - version: latest + version: 2201.7.0 # Build Ballerina Project - name: Ballerina Build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b50649..3c4b01a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: - name: Set Up Ballerina uses: ballerina-platform/setup-ballerina@v1.1.0 with: - version: latest + version: 2201.7.0 # Build Ballerina Project - name: Ballerina Build From a4e07053bd144bb838cc4b59a36bf36ac25e6a61 Mon Sep 17 00:00:00 2001 From: Nipuna Fernando Date: Sun, 13 Aug 2023 20:09:08 +0530 Subject: [PATCH 4/5] Fix outdated examples --- examples/add_event.bal | 4 ++-- examples/create_event.bal | 4 ++-- examples/get_event.bal | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/add_event.bal b/examples/add_event.bal index 7f7e6d0..5590827 100644 --- a/examples/add_event.bal +++ b/examples/add_event.bal @@ -37,7 +37,7 @@ public function main() { string subject = "Test-Subject"; string body = "Test-Body"; calendar:Event|error event = calendarClient->addQuickEvent(subject, body); - if (response is calendar:Event) { - log:printInfo(response.toString()); + if (event is calendar:Event) { + log:printInfo(event.toString()); } } diff --git a/examples/create_event.bal b/examples/create_event.bal index 9d7d0a9..5104dff 100644 --- a/examples/create_event.bal +++ b/examples/create_event.bal @@ -65,7 +65,7 @@ public function main() { allowNewTimeProposals: true }; calendar:Event|error generatedEvent = calendarClient->createEvent(eventMetadata); - if (response is calendar:Event) { - log:printInfo(response.toString()); + if (generatedEvent is calendar:Event) { + log:printInfo(generatedEvent.toString()); } } diff --git a/examples/get_event.bal b/examples/get_event.bal index 8a1cf45..101e601 100644 --- a/examples/get_event.bal +++ b/examples/get_event.bal @@ -36,7 +36,7 @@ string eventId = "eventId"; public function main() { calendar:Event|error event = calendarClient->getEvent(eventId); - if (response is calendar:Event) { - log:printInfo(response.toString()); + if (event is calendar:Event) { + log:printInfo(event.toString()); } } From 30c138b0f9f0e022f78b326219154cfb8c142297 Mon Sep 17 00:00:00 2001 From: Nipuna Fernando Date: Sun, 13 Aug 2023 21:13:15 +0530 Subject: [PATCH 5/5] Fix GraalVM working directory --- .github/workflows/build-with-bal-test-native.yml | 2 +- .github/workflows/dev-stg-release.yml | 2 +- .github/workflows/release.yml | 2 +- examples/build.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-with-bal-test-native.yml b/.github/workflows/build-with-bal-test-native.yml index 69ac375..50a47cc 100644 --- a/.github/workflows/build-with-bal-test-native.yml +++ b/.github/workflows/build-with-bal-test-native.yml @@ -32,7 +32,7 @@ jobs: version: latest - name: Run Ballerina tests using the native executable - working-directory: ./calendar + working-directory: ./ballerina run: bal test --graalvm env: JAVA_HOME: /usr/lib/jvm/default-jvm diff --git a/.github/workflows/dev-stg-release.yml b/.github/workflows/dev-stg-release.yml index 7369bed..c9bd8eb 100644 --- a/.github/workflows/dev-stg-release.yml +++ b/.github/workflows/dev-stg-release.yml @@ -23,7 +23,7 @@ jobs: - name: Set Up Ballerina uses: ballerina-platform/setup-ballerina@v1.1.0 with: - version: 2201.7.0 + version: 2201.2.1 # Build Ballerina Project - name: Ballerina Build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c4b01a..495f63a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: - name: Set Up Ballerina uses: ballerina-platform/setup-ballerina@v1.1.0 with: - version: 2201.7.0 + version: 2201.2.1 # Build Ballerina Project - name: Ballerina Build diff --git a/examples/build.sh b/examples/build.sh index 5d32ff0..f533627 100755 --- a/examples/build.sh +++ b/examples/build.sh @@ -14,7 +14,7 @@ run) BAL_CMD="run" ;; *) - echo "Invalid command provided: '$1'. Please provide 'build' or 'test' as the command." + echo "Invalid command provided: '$1'. Please provide 'build' or 'run' as the command." exit 1 ;; esac