Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
name: Java Agent Main Build
on:
workflow_call:
inputs:
caller-workflow-name:
required: true
type: string
ref:
description: 'The branch, tag or SHA to checkout'
required: false
type: string
default: ''
push:
branches:
- main
Expand All @@ -24,6 +34,8 @@ jobs:
runs-on: aws-otel-java-instrumentation_ubuntu-latest_32-core
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
with:
ref: ${{ inputs.ref || github.sha }}
- uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 #v5.0.0
with:
java-version-file: .java-version
Expand Down Expand Up @@ -58,6 +70,7 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
with:
fetch-depth: 0
ref: ${{ inputs.ref || github.sha }}
- uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 #v5.0.0
with:
java-version-file: .java-version
Expand Down Expand Up @@ -193,6 +206,7 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
with:
fetch-depth: 0
ref: ${{ inputs.ref || github.sha }}
- uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 #v5.0.0
with:
java-version: 23
Expand Down Expand Up @@ -233,6 +247,7 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
with:
fetch-depth: 0
ref: ${{ inputs.ref || github.sha }}
- uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 #v5.0.0
with:
java-version-file: .java-version
Expand Down
131 changes: 131 additions & 0 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: Nightly Upstream Snapshot Build

on:
schedule:
- cron: "21 3 * * *"
workflow_dispatch:
push:
branches:
- zhaez/nightly-build

permissions:
contents: write
pull-requests: write
id-token: write

env:
AWS_DEFAULT_REGION: us-east-1
BRANCH_NAME: nightly-dependency-updates

jobs:
update-and-create-pr:
runs-on: ubuntu-latest
outputs:
has_changes: ${{ steps.check_changes.outputs.has_changes }}

steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Configure git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"

- name: Check out dependency update branch
run: |
if git ls-remote --exit-code --heads origin "$BRANCH_NAME"; then
echo "Branch $BRANCH_NAME already exists, checking out..."
git checkout "$BRANCH_NAME"
else
echo "Branch $BRANCH_NAME does not exist, creating new branch..."
git checkout -b "$BRANCH_NAME"
fi

- name: Set up Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c #v6.0.0
with:
python-version: '3.11'

- name: Install Python dependencies
run: pip install requests packaging

- name: Generate breaking changes summary
id: breaking_changes
run: python3 scripts/find_breaking_changes.py

- name: Update dependencies
run: python3 scripts/update_dependencies.py

- name: Check for changes and commit
id: check_changes
run: |
if git diff --quiet; then
echo "No dependency updates needed"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Dependencies were updated"
echo "has_changes=true" >> $GITHUB_OUTPUT

git add dependencyManagement/build.gradle.kts
git commit -m "chore: update OpenTelemetry dependencies to latest versions"
git push origin "$BRANCH_NAME"
fi

- name: Create or update PR
if: steps.check_changes.outputs.has_changes == 'true'
run: |
PR_BODY="Automated update of OpenTelemetry dependencies to their latest available versions.

**Upstream releases with breaking changes:**
${{ steps.breaking_changes.outputs.breaking_changes_info }}"

if gh pr view "$BRANCH_NAME" --json state --jq '.state' 2>/dev/null | grep -q "OPEN"; then
echo "Open PR already exists, updating description..."
gh pr edit "$BRANCH_NAME" --body "$PR_BODY"
else
echo "Creating new PR..."
gh pr create \
--title "Nightly dependency update: OpenTelemetry packages to latest versions" \
--body "$PR_BODY" \
--base main \
--head "$BRANCH_NAME"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-and-test:
needs: update-and-create-pr
if: needs.update-and-create-pr.outputs.has_changes == 'true'
uses: ./.github/workflows/main-build.yml
secrets: inherit
with:
caller-workflow-name: nightly-build
ref: nightly-dependency-updates

publish-nightly-build-status:
name: "Publish Nightly Build Status"
needs: [update-and-create-pr, build-and-test]
runs-on: ubuntu-latest
if: always()
steps:
- name: Configure AWS Credentials for emitting metrics
uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 #v5.0.0
with:
role-to-assume: ${{ secrets.METRICS_ROLE_ARN }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}

- name: Publish nightly build status
run: |
if [[ "${{ needs.build-and-test.result }}" == "skipped" ]]; then
echo "Build was skipped (no changes), not publishing metric"
else
value="${{ needs.build-and-test.result == 'success' && '0.0' || '1.0'}}"
aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=nightly_build \
--value $value
fi
116 changes: 116 additions & 0 deletions scripts/find_breaking_changes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/usr/bin/env python3

import re
import requests
import sys
from packaging import version


def get_current_versions():
"""Get current versions from build.gradle.kts."""
try:
with open("dependencyManagement/build.gradle.kts", "r", encoding="utf-8") as file:
content = file.read()

# Extract otelVersion
otel_version_match = re.search(r'val otelVersion = "([^"]*)"', content)
current_instrumentation_version = otel_version_match.group(1) if otel_version_match else None

return current_instrumentation_version

except (OSError, IOError) as error:
print(f"Error reading current versions: {error}")
return None


def get_releases_with_breaking_changes(repo, current_version, new_version):
"""Get releases between current and new version that mention breaking changes."""
try:
response = requests.get(f"https://api.github.com/repos/open-telemetry/{repo}/releases", timeout=30)
response.raise_for_status()
releases = response.json()

breaking_releases = []

for release in releases:
try:
tag_name = release["tag_name"]
release_version = tag_name.lstrip("v")

# Check if this release is between current and new version
if (
version.parse(current_version)
< version.parse(release_version)
<= version.parse(new_version)
):

# Check if release notes have breaking changes as headers
body = release.get("body", "")
breaking_header_pattern = r'^\s*#+.*Breaking changes'
if re.search(breaking_header_pattern, body, re.MULTILINE):
breaking_releases.append(
{
"version": release_version,
"name": release["name"],
"url": release["html_url"],
"body": release.get("body", ""),
}
)
except (ValueError, KeyError):
continue

return breaking_releases

except requests.RequestException as request_error:
print(f"Warning: Could not get releases for {repo}: {request_error}")
return []


def main():
current_instrumentation_version = get_current_versions()

if not current_instrumentation_version:
print("Could not determine current versions")
sys.exit(1)

# Get new versions from the update script
sys.path.append('scripts')
from update_dependencies import get_latest_instrumentation_version, get_latest_contrib_version

new_instrumentation_version = get_latest_instrumentation_version()
new_contrib_version = get_latest_contrib_version()

if not new_instrumentation_version:
print("Could not determine new versions")
sys.exit(1)

print("Checking for breaking changes:")
print(f"Instrumentation: {current_instrumentation_version} → {new_instrumentation_version}")
if new_contrib_version:
print(f"Contrib: → {new_contrib_version}")

# Check instrumentation repo for breaking changes
instrumentation_breaking = get_releases_with_breaking_changes(
"opentelemetry-java-instrumentation", current_instrumentation_version, new_instrumentation_version
)

# Output for GitHub Actions
breaking_info = ""

if instrumentation_breaking:
breaking_info += "**opentelemetry-java-instrumentation:**\n"
for release in instrumentation_breaking:
breaking_info += f"- [{release['name']}]({release['url']})\n"

if new_contrib_version:
breaking_info += "\n**Check contrib releases for potential breaking changes:**\n"
breaking_info += "- [opentelemetry-java-contrib releases](https://github.com/open-telemetry/opentelemetry-java-contrib/releases)\n"

import os
if os.environ.get("GITHUB_OUTPUT"):
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output_file:
output_file.write(f"breaking_changes_info<<EOF\n{breaking_info}EOF\n")


if __name__ == "__main__":
main()
Loading
Loading