Skip to content

Commit

Permalink
Create flow for automating byte-buddy version bump (#161)
Browse files Browse the repository at this point in the history
* Squash workflow changes
* rm workflow_dispatch trigger
* better target_url
  • Loading branch information
hughsimpson authored Sep 25, 2024
1 parent 5a8ba22 commit b30542a
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 3 deletions.
37 changes: 34 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
name: Test all the things

on: [push, pull_request]
on:
push:
pull_request:
issue_comment:
types: [ created ]

permissions:
checks: write
pull-requests: read
contents: read

jobs:
ci:
if: (github.event.issue.pull_request && contains(github.event.comment.body, 'please rerun tests')) || !github.event.issue
runs-on: ubuntu-latest
name: Java ${{ matrix.java }}
strategy:
matrix:
java: [8, 11, 17, 21]
java: [ 8, 11, 17, 21 ]
fail-fast: false
steps:
- name: Get PR branch
uses: xt0rted/pull-request-comment-branch@v2
id: comment-branch
if: github.event.issue.pull_request
- uses: actions/checkout@v3
if: (!github.event.issue)
- uses: actions/checkout@v3
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
if: github.event.issue.pull_request
- name: Set up JDK ${{ matrix.java }}
uses: actions/cache@v2
with:
Expand All @@ -31,4 +50,16 @@ jobs:
./gradlew wrapper --gradle-version=8.4-rc-1 :agent:spec && ./gradlew wrapper --gradle-version=8.4-rc-1 agent:publishToMavenLocal
else
./travis-test.sh
fi
fi
- name: Report status
if: github.event.issue.pull_request
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/$GITHUB_REPOSITORY/check-runs \
-f "name=Test all the things / Java ${{ matrix.java }}" -f "head_sha=${{ steps.comment-branch.outputs.head_ref }}" -f "status=completed" \
-f "output[title]=Requested test" -f "conclusion=success" -f "target_url=https://github.com/$GITHUB_REPOSITORY/actions/runs/${{ github.run_id }}" -f "output[summary]=Manually triggered test succeeded"
54 changes: 54 additions & 0 deletions .github/workflows/pr-bb-updates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Byte Buddy Update"

on:
pull_request:

permissions:
pull-requests: write
contents: write

jobs:
pr-api-change:
name: PR Byte Buddy change
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 8
- name: Rebuild byte-buddy if version has changed
env:
GH_TOKEN: ${{ github.token }}
run: |
if [ 'byte-buddy-tag' = $(git diff --diff-filter=d --name-only origin/master -- 'byte-buddy-tag' agent/libs | xargs) ]
then
echo Byte Buddy tag was updated
tag=$(cat byte-buddy-tag)
rm agent/libs/byte-buddy*
git clone https://github.com/raphw/byte-buddy.git
cp bb.patch byte-buddy
cd byte-buddy
git checkout $tag
git apply bb.patch
mvn clean package -Pextras -Dskiptests -q -B
echo Build succeeded
mv ./byte-buddy/target/$tag.jar ../agent/libs
mv ./byte-buddy/target/$tag-sources.jar ../agent/libs
cd ..
rm -rf byte-buddy
perl -pi -e "s|libs/byte-buddy-.+jar|libs/$tag.jar|" agent/build.gradle
echo updated byte buddy and reference
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
echo set origin url to https://github.com/$GITHUB_REPOSITORY
git fetch
git checkout -b update_byte_buddy-tag-$tag
git add agent/libs agent/build.gradle
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git commit -m "rebuilt byte buddy"
git push -f origin update_byte_buddy-tag-$tag
gh pr create -B master -H update_byte_buddy-tag-$tag --fill && echo Update PR successfully made || echo PR is already open
fi
62 changes: 62 additions & 0 deletions bb.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
diff --git a/byte-buddy-dep/pom.xml b/byte-buddy-dep/pom.xml
index 3f8fa6217f..07ed398b33 100644
--- a/byte-buddy-dep/pom.xml
+++ b/byte-buddy-dep/pom.xml
@@ -48,10 +48,6 @@
<groupId>org.ow2.asm</groupId>
<artifactId>asm-analysis</artifactId>
</exclusion>
- <exclusion>
- <groupId>org.ow2.asm</groupId>
- <artifactId>asm-tree</artifactId>
- </exclusion>
</exclusions>
</dependency>
<dependency>
diff --git a/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/InstrumentedType.java b/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/InstrumentedType.java
index 936a7c2b61..302c55e373 100644
--- a/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/InstrumentedType.java
+++ b/byte-buddy-dep/src/main/java/net/bytebuddy/dynamic/scaffold/InstrumentedType.java
@@ -44,7 +44,8 @@ import static net.bytebuddy.matcher.ElementMatchers.is;
import static net.bytebuddy.matcher.ElementMatchers.not;

/**
- * Implementations of this interface represent an instrumented type that is subject to change. Implementations
+ * Implementations of this
+ represent an instrumented type that is subject to change. Implementations
* should however be immutable and return new instance when its builder methods are invoked.
*/
public interface InstrumentedType extends TypeDescription {
@@ -509,10 +510,10 @@ public interface InstrumentedType extends TypeDescription {
* A set containing all keywords of the Java programming language.
*/
private static final Set<String> KEYWORDS = new HashSet<String>(Arrays.asList(
- "abstract", "continue", "for", "new", "switch", "assert", "default", "goto", "package", "synchronized", "boolean",
+ "abstract", "continue", "for", "new", "switch", "assert", "goto", "package", "synchronized", "boolean",
"do", "if", "private", "this", "break", "double", "implements", "protected", "throw", "byte", "else", "import",
"public", "throws", "case", "enum", "instanceof", "return", "transient", "catch", "extends", "int", "short",
- "try", "char", "final", "interface", "static", "void", "class", "finally", "long", "strictfp", "volatile",
+ "try", "char", "final", "static", "void", "class", "finally", "long", "strictfp", "volatile",
"const", "float", "native", "super", "while"
));

diff --git a/byte-buddy/pom.xml b/byte-buddy/pom.xml
index 35e8445b31..1c5bd75787 100644
--- a/byte-buddy/pom.xml
+++ b/byte-buddy/pom.xml
@@ -277,6 +277,7 @@
<exclude>**/NOTICE</exclude>
</excludes>
</filter>
+ <!--
<filter>
<artifact>org.ow2.asm:asm-commons</artifact>
<includes>
@@ -292,6 +293,7 @@
<include>org/objectweb/asm/commons/SimpleRemapper.**</include>
</includes>
</filter>
+ -->
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
1 change: 1 addition & 0 deletions byte-buddy-tag
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
byte-buddy-1.14.5

0 comments on commit b30542a

Please sign in to comment.