Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PR and Main Build for patched dependencies jobs #669

Closed
wants to merge 3 commits into from
Closed
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
13 changes: 5 additions & 8 deletions .github/actions/patch-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ description: |
This workflow supports patching opentelemetry-java and opentelemetry-java-instrumentation repositories by executing
the `patch.sh` script that will try to patch those repositories and after that will optionally test and then publish
the artifacts to maven local.
To add a patch you have to add a file in the `.github/patches/` directory with the name of the repository that must
To add a patch you have to add a file in the `.github/patches` directory with the name of the repository that must
be patched.
This action assumes that java was set correctly.
inputs:
run_tests:
default: "false"
required: false
description: "If the workflow should run tests of the dependencies. Anything different than false will evaluate to true"
branch:
required: true
description: "The branch where this patches are being applied e.g.: release/v1.21.x"
gpg_private_key:
description: "The gpg key used to sign the artifacts"
required: true
Expand All @@ -27,19 +24,19 @@ runs:
steps:
- name: check patches
run: |
if [[ -f .github/patches/${{ inputs.branch }}/opentelemetry-java.patch ]]; then
if [[ -f .github/patches/opentelemetry-java.patch ]]; then
echo 'patch_otel_java=true' >> $GITHUB_ENV
fi
if [[ -f .github/patches/${{ inputs.branch }}/opentelemetry-java-instrumentation.patch ]]; then
if [[ -f .github/patches/opentelemetry-java-instrumentation.patch ]]; then
echo 'patch_otel_java_instrumentation=true' >> $GITHUB_ENV
fi
if [[ -f .github/patches/${{ inputs.branch }}/opentelemetry-java-contrib.patch ]]; then
if [[ -f .github/patches/opentelemetry-java-contrib.patch ]]; then
echo 'patch_otel_java_contrib=true' >> $GITHUB_ENV
fi
shell: bash

- name: Clone and patch repositories
run: .github/scripts/patch.sh "${{ inputs.branch }}"
run: .github/scripts/patch.sh
if: ${{ env.patch_otel_java == 'true' ||
env.patch_otel_java_instrumentation == 'true' ||
env.patch_otel_java_contrib == 'true' }}
Expand Down
File renamed without changes.
15 changes: 6 additions & 9 deletions .github/scripts/patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,26 @@
# Enable debug mode, fail on any command that fail in this script and fail on unset variables
set -x -e -u

# This parameter will help find the patches to be applied
BRANCH=$1

# .github/patches/$BRANCH/versions.sh should define all the versions of the dependencies that we are going to patch
# .github/patches/versions.sh should define all the versions of the dependencies that we are going to patch
# This is used so that we can properly clone the upstream repositories.
# This file should define the following variables:
# OTEL_JAVA_VERSION. Tag of the opentelemetry-java repository to use. E.g.: JAVA_OTEL_JAVA_VERSION=v1.21.0
# OTEL_JAVA_INSTRUMENTATION_VERSION. Tag of the opentelemetry-java-instrumentation repository to use, e.g.: OTEL_JAVA_INSTRUMENTATION_VERSION=v1.21.0
# OTEL_JAVA_CONTRIB_VERSION. Tag of the opentelemetry-java-contrib repository. E.g.: OTEL_JAVA_CONTRIB_VERSION=v1.21.0
# This script will fail if a variable that is supposed to exist is referenced.

if [[ ! -f .github/patches/${BRANCH}/versions ]]; then
if [[ ! -f .github/patches/versions ]]; then
echo "No versions file found. Skipping patching"
exit 0
fi

source .github/patches/${BRANCH}/versions
source .github/patches/versions

git config --global user.email "adot-patch-workflow@github.com"
git config --global user.name "ADOT Patch workflow"


OTEL_JAVA_PATCH=".github/patches/${BRANCH}/opentelemetry-java.patch"
OTEL_JAVA_PATCH=".github/patches/opentelemetry-java.patch"
if [[ -f "$OTEL_JAVA_PATCH" ]]; then
git clone https://github.com/open-telemetry/opentelemetry-java.git
cd opentelemetry-java
Expand All @@ -37,7 +34,7 @@ else
fi


OTEL_JAVA_CONTRIB_PATCH=".github/patches/${BRANCH}/opentelemetry-java-contrib.patch"
OTEL_JAVA_CONTRIB_PATCH=".github/patches/opentelemetry-java-contrib.patch"
if [[ -f "$OTEL_JAVA_CONTRIB_PATCH" ]]; then
git clone https://github.com/open-telemetry/opentelemetry-java-contrib.git
cd opentelemetry-java-contrib
Expand All @@ -50,7 +47,7 @@ else
fi


OTEL_JAVA_INSTRUMENTATION_PATCH=".github/patches/${BRANCH}/opentelemetry-java-instrumentation.patch"
OTEL_JAVA_INSTRUMENTATION_PATCH=".github/patches/opentelemetry-java-instrumentation.patch"
if [[ -f "$OTEL_JAVA_INSTRUMENTATION_PATCH" ]]; then
git clone https://github.com/open-telemetry/opentelemetry-java-instrumentation.git
cd opentelemetry-java-instrumentation
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
testpatch:
name: Test patches applied to dependencies
runs-on: aws-otel-java-instrumentation_ubuntu-latest_32-core
if: ${{ startsWith(github.ref_name, 'release/v') }}
if: ${{ hashFiles('.github/patches/opentelemetry-java-*.patch') != ''}}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand All @@ -48,7 +48,6 @@ jobs:
- uses: ./.github/actions/patch-dependencies
with:
run_tests: "true"
branch: ${{ github.ref_name }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_password: ${{ secrets.GPG_PASSPHRASE }}

Expand All @@ -72,13 +71,12 @@ jobs:
with:
path: |
~/.m2/repository/io/opentelemetry/
key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/**/opentelemetry-java-*.patch') }}
key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/opentelemetry-java-*.patch') }}

- name: Publish patched dependencies to maven local
uses: ./.github/actions/patch-dependencies
if: ${{ startsWith(github.ref_name, 'release/v') }}
if: ${{ hashFiles('.github/patches/opentelemetry-java-*.patch') != ''}}
with:
branch: ${{ github.ref_name }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_password: ${{ secrets.GPG_PASSPHRASE }}

Expand Down Expand Up @@ -339,7 +337,7 @@ jobs:
with:
path: |
~/.m2/repository/io/opentelemetry/
key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/**/opentelemetry-java-*.patch') }}
key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/opentelemetry-java-*.patch') }}

- uses: gradle/wrapper-validation-action@v1

Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
testpatch:
name: Test patches applied to dependencies
runs-on: aws-otel-java-instrumentation_ubuntu-latest_32-core
if: ${{ startsWith(github.event.pull_request.base.ref, 'release/v') }}
if: $${{ hashFiles('.github/patches/opentelemetry-java-*.patch') != ''}}
steps:
- uses: actions/checkout@v4

Expand All @@ -37,7 +37,6 @@ jobs:
- uses: ./.github/actions/patch-dependencies
with:
run_tests: "true"
branch: ${{ github.event.pull_request.base.ref }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_password: ${{ secrets.GPG_PASSPHRASE }}

Expand Down Expand Up @@ -67,11 +66,18 @@ jobs:

- uses: gradle/wrapper-validation-action@v1

# cache local patch outputs
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: |
~/.m2/repository/io/opentelemetry/
key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/opentelemetry-java-*.patch') }}

- name: Publish patched dependencies to maven local
uses: ./.github/actions/patch-dependencies
if: ${{ startsWith(github.event.pull_request.base.ref, 'release/v') }}
if: ${{ hashFiles('.github/patches/opentelemetry-java-*.patch') != ''}}
with:
branch: ${{ github.event.pull_request.base.ref }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_password: ${{ secrets.GPG_PASSPHRASE }}

Expand Down