Skip to content

Commit

Permalink
Removing patch dependencies scope restriction to release branch only (#…
Browse files Browse the repository at this point in the history
…670)

Removing patches scope restriction to release branch
  • Loading branch information
PaurushGarg authored Dec 21, 2023
1 parent e48f3cf commit 6c223a3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
11 changes: 4 additions & 7 deletions .github/actions/patch-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ inputs:
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
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 "[email protected]"
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
8 changes: 2 additions & 6 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
testpatch:
name: Test patches applied to dependencies
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref_name, 'release/v') }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand All @@ -48,7 +47,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 +70,11 @@ 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') }}
with:
branch: ${{ github.ref_name }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_password: ${{ secrets.GPG_PASSPHRASE }}

Expand Down Expand Up @@ -339,7 +335,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
12 changes: 8 additions & 4 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
testpatch:
name: Test patches applied to dependencies
runs-on: ubuntu-latest
if: ${{ startsWith(github.event.pull_request.base.ref, 'release/v') }}
steps:
- uses: actions/checkout@v4

Expand All @@ -37,7 +36,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 +65,17 @@ 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') }}
with:
branch: ${{ github.event.pull_request.base.ref }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_password: ${{ secrets.GPG_PASSPHRASE }}

Expand Down

0 comments on commit 6c223a3

Please sign in to comment.