Skip to content

Commit

Permalink
Merge pull request #1 from NipunaMadhushan/main
Browse files Browse the repository at this point in the history
Implementation of New Relic Extension
  • Loading branch information
NipunaMadhushan authored Dec 11, 2023
2 parents 9ea7556 + f197b50 commit c96ef28
Show file tree
Hide file tree
Showing 34 changed files with 2,494 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.

# See: https://help.github.com/articles/about-codeowners/

# These owners will be the default owners for everything in the repo.
* @NipunaMadhushan @keizer619
File renamed without changes.
File renamed without changes.
71 changes: 71 additions & 0 deletions .github/workflows/build-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build

on:
workflow_dispatch:
inputs:
ballerina_version:
description: 'Ballerina version'
required: true
default: '2201.8.3'
push:
branches:
- main

env:
BALLERINA_DISTRIBUTION_VERSION: 2201.8.3 # Update this with the latest Ballerina version

jobs:
build:
runs-on: ubuntu-latest
if: github.repository_owner == 'ballerina-platform'
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17.0.7
- name: Set up Ballerina
if: github.event_name == 'workflow_dispatch'
uses: ballerina-platform/[email protected]
with:
version: ${{ github.event.inputs.ballerina_version }}
- name: Set up Ballerina
if: github.event_name == 'push'
uses: ballerina-platform/[email protected]
with:
version: ${{ env.BALLERINA_DISTRIBUTION_VERSION }}
- name: Change to Timestamped Version
run: |
startTime=$(TZ="Asia/Kolkata" date +'%Y%m%d-%H%M00')
latestCommit=$(git log -n 1 --pretty=format:"%h")
VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)
updatedVersion=$VERSION-$startTime-$latestCommit
echo $updatedVersion
echo TIMESTAMPED_VERSION=$updatedVersion >> $GITHUB_ENV
sed -i "s/version=\(.*\)/version=$updatedVersion/g" gradle.properties
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Set Docker Host env variable
run: echo "DOCKER_HOST=$(docker context ls --format '{{print .DockerEndpoint}}' | tr -d '\n')" >> $GITHUB_ENV
- name: Build with Gradle
env:
DOCKER_HOST: unix:///var/run/docker.sock
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
packagePublishRepo: ${{ github.repository }}
run: |
./gradlew clean build publish --stacktrace --scan --console=plain --no-daemon
./gradlew codeCoverageReport --console=plain --no-daemon
- name: Upload Coverage Report
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: distribution
path: |
ballerina/build/distributions/newrelic-extension-ballerina-*.zip
if-no-files-found: error
82 changes: 82 additions & 0 deletions .github/workflows/central-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Publish to the Ballerina central

on:
workflow_dispatch:
inputs:
ballerina_version:
description: 'Ballerina version'
required: true
default: '2201.8.3'
environment:
type: choice
description: Select environment
required: true
options:
- CENTRAL
- DEV CENTRAL
- STAGE CENTRAL

jobs:
publish-release:
runs-on: ubuntu-latest
if: github.repository_owner == 'ballerina-platform'
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17.0.7
- name: Set up Ballerina
uses: ballerina-platform/[email protected]
with:
version: ${{ github.event.inputs.ballerina_version }}
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
packagePAT: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew build -x check -x test
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'rootfs'
scan-ref: '/github/workspace/ballerina/lib'
format: 'table'
timeout: '10m0s'
exit-code: '1'

- name: Ballerina Central Push
if: ${{ github.event.inputs.environment == 'CENTRAL' }}
env:
BALLERINA_DEV_CENTRAL: false
BALLERINA_STAGE_CENTRAL: false
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }}
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
run: |
./gradlew clean build -PpublishToCentral=true
- name: Ballerina Central Dev Push
if: ${{ github.event.inputs.environment == 'DEV CENTRAL' }}
env:
BALLERINA_DEV_CENTRAL: true
BALLERINA_STAGE_CENTRAL: false
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN }}
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
run: |
sed -i 's/version=\(.*\)-SNAPSHOT/version=\1/g' gradle.properties
./gradlew clean build -PpublishToCentral=true
- name: Ballerina Central Stage Push
if: ${{ github.event.inputs.environment == 'STAGE CENTRAL' }}
env:
BALLERINA_DEV_CENTRAL: false
BALLERINA_STAGE_CENTRAL: true
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_STAGE_ACCESS_TOKEN }}
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
run: |
sed -i 's/version=\(.*\)-SNAPSHOT/version=\1/g' gradle.properties
./gradlew clean build -PpublishToCentral=true
64 changes: 64 additions & 0 deletions .github/workflows/daily-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Daily build

on:
schedule:
- cron: '30 2 * * *'
workflow_dispatch:
inputs:
ballerina_version:
description: 'Ballerina version'
required: true
default: '2201.8.3'

env:
BALLERINA_DISTRIBUTION_VERSION: 2201.8.3 # Update this with the latest Ballerina version

jobs:
build:
if: github.repository_owner == 'ballerina-platform'
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: Set up Ballerina
if: github.event_name == 'workflow_dispatch'
uses: ballerina-platform/[email protected]
with:
version: ${{ github.event.inputs.ballerina_version }}
- name: Set up Ballerina
if: github.event_name == 'schedule'
uses: ballerina-platform/[email protected]
with:
version: ${{ env.BALLERINA_DISTRIBUTION_VERSION }}
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
packagePAT: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew clean build
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'rootfs'
scan-ref: '/github/workspace/ballerina/lib'
format: 'table'
timeout: '10m0s'
exit-code: '1'
- 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-newrelic\"
}
}"
62 changes: 62 additions & 0 deletions .github/workflows/graalvm-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: GraalVM Check

on:
schedule:
- cron: '30 18 * * *'
workflow_dispatch:
inputs:
ballerina_version:
description: 'Ballerina version'
required: true
default: '2201.8.3'

env:
BALLERINA_DISTRIBUTION_VERSION: 2201.8.3 # Update this with the latest Ballerina version

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
version: 'latest'
java-version: '17.0.7'
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
if: github.event_name == 'workflow_dispatch'
uses: ballerina-platform/[email protected]
with:
version: ${{ github.event.inputs.ballerina_version }}
- name: Set up Ballerina
if: github.event_name == 'schedule'
uses: ballerina-platform/[email protected]
with:
version: ${{ env.BALLERINA_DISTRIBUTION_VERSION }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- 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
- name: Update dependency versions
run: ./gradlew :newrelic-extension-ballerina:updateTomlVerions
env:
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
JAVA_OPTS: -DBALLERINA_DEV_COMPILE_BALLERINA_ORG=true
- name: Run Ballerina build using the native executable
run: bal build --native ./ballerina
- name: Run Ballerina tests using the native executable
run: bal test --native ./ballerina
83 changes: 83 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Publish Release

on:
workflow_dispatch:
inputs:
distribution_version:
description: 'Ballerina distribution version (e.g.; 2201.8.0)'
required: true
default: '2201.8.0'

jobs:
publish-release:
runs-on: ubuntu-latest
if: github.repository_owner == 'ballerina-platform'
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17.0.7
- name: Set up Ballerina
uses: ballerina-platform/[email protected]
with:
version: ${{ github.event.inputs.ballerina_version }}
- name: Set version env variable
run: echo "VERSION=$((grep -w 'version' | cut -d= -f2) < gradle.properties | rev | cut --complement -d- -f1 | rev)" >> $GITHUB_ENV
- name: Pre release depenency version update
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
run: |
echo "Version: ${VERSION}"
git config user.name ${{ secrets.BALLERINA_BOT_USERNAME }}
git config user.email ${{ secrets.BALLERINA_BOT_EMAIL }}
git checkout -b release-${VERSION}
git add gradle.properties
git commit -m "Move dependencies to stable version" || echo "No changes to commit"
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Set Docker Host env variable
run: echo "DOCKER_HOST=$(docker context ls --format '{{print .DockerEndpoint}}' | tr -d '\n')" >> $GITHUB_ENV
- name: Build with Gradle
env:
packageUser: ${{ github.actor }}
packagePAT: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew build -x check -x test
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'rootfs'
scan-ref: '/github/workspace/ballerina/lib'
format: 'table'
timeout: '10m0s'
exit-code: '1'
- name: Publish artifact
env:
DOCKER_HOST: unix:///var/run/docker.sock
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
BALLERINA_CENTRAL_ACCESS_TOKEN: ${{ secrets.BALLERINA_CENTRAL_ACCESS_TOKEN }}
packageUser: ${{ secrets.BALLERINA_BOT_USERNAME }}
packagePAT: ${{ secrets.BALLERINA_BOT_TOKEN }}
packagePublishRepo: ${{ github.repository }}
run: |
git stash
./gradlew release -Prelease.useAutomaticVersion=true
./gradlew -Pversion=${VERSION} publish -x test
- name: Create Github release from the release tag
run: |
curl --request POST 'https://api.github.com/repos/${{ github.repository }}/releases' \
--header 'Accept: application/vnd.github.v3+json' \
--header 'Authorization: Bearer ${{ secrets.BALLERINA_BOT_TOKEN }}' \
--header 'Content-Type: application/json' \
--data-raw '{
"tag_name": "v'"$VERSION"'",
"name": "module-ballerinax-newrelic-v'"$VERSION"'"
}'
- name: Post release PR
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
run: |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
bin/hub pull-request --base main -m "[Automated] Sync master after "$VERSION" release"
Loading

0 comments on commit c96ef28

Please sign in to comment.