Skip to content

Daily build

Daily build #661

Workflow file for this run

name: Daily build
# Controls when the action will run.
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@v3
# Set up Java Environment
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
# Grant execute permission to the gradlew script
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# Build the project with Gradle
- name: Build with Gradle
env:
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
JAVA_OPTS: -DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true
run: |
./gradlew build
# Build the ballerina project
- name: Ballerina Build
uses: ballerina-platform/ballerina-action/@nightly
with:
args:
pack ./twitter
env:
JAVA_HOME: /usr/lib/jvm/default-jvm
DEV_ENVIRONMENT_NAME: ${{ secrets.DEV_ENVIRONMENT_NAME }}
# Test the ballerina project
- name: Ballerina Test
uses: ballerina-platform/ballerina-action/@nightly
with:
args:
test --code-coverage ./twitter
env:
JAVA_HOME: /usr/lib/jvm/default-jvm
API_KEY: ${{ secrets.API_KEY }}
API_SECRET: ${{ secrets.API_SECRET }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
ACCESS_TOKEN_SECRET: ${{ secrets.ACCESS_TOKEN_SECRET }}
DEV_ENVIRONMENT_NAME: ${{ secrets.DEV_ENVIRONMENT_NAME }}
CALLBACK_URL: ${{ secrets.CALLBACK_URL }}
PORT: ${{ secrets.PORT }}
# Read the ballerina test results
- name: Read Ballerina Test Results
id: test_results
run: |
content=`cat ./twitter/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}}"
# 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-twitter\"
}
}"