diff --git a/.github/workflows/Check-Build-Files.yml b/.github/workflows/Check-Build-Files.yml new file mode 100644 index 0000000000..8f8d649356 --- /dev/null +++ b/.github/workflows/Check-Build-Files.yml @@ -0,0 +1,21 @@ +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + check-build-files: + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b + with: + fetch-depth: 2 + + - name: Check changed files meet build linter requirements + run: | + CHANGED_FILES=$(git diff --name-only -r HEAD^1 HEAD | xargs) + ./automation/pull-request/lint-build-files.sh $CHANGED_FILES + if [ $? -ne 0 ]; then + echo "::warning::Build files in this PR did not pass optional checks. Please review for accuracy! See check-build-files step for details." + fi + continue-on-error: true \ No newline at end of file diff --git a/.github/workflows/migrate_publish_release.yml b/.github/workflows/migrate_publish_release.yml new file mode 100644 index 0000000000..ff75cde44b --- /dev/null +++ b/.github/workflows/migrate_publish_release.yml @@ -0,0 +1,54 @@ +name: Test migration workflow + +on: + workflow_dispatch: + inputs: + agent-ref: + description: "Specify agent branch/tag/sha (main is default)" + required: false + default: 'main' + +jobs: + publish_release: + runs-on: ubuntu-24.04 + steps: + - name: Checkout Agent + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # pin@v4 + with: + ref: ${{ inputs.agent-ref || 'main' }} + + - name: Setup environment + uses: ./.github/actions/setup-environment + + - name: Publish release + env: + SONATYPE_USERNAME: ${{ secrets.MIGRATION_TEST_SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.MIGRATION_TEST_SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} + run: ./gradlew $GRADLE_OPTIONS publish -x :newrelic-scala3-api:publish -x :newrelic-scala-api:publish -x :newrelic-scala-cats-api:publish -x :newrelic-cats-effect3-api:publish -x :newrelic-scala-zio-api:publish -x :newrelic-scala-zio2-api:publish -x :agent-bridge:publish -x :agent-bridge-datastore:publish -x :newrelic-weaver:publish -x :newrelic-weaver-api:publish -x :newrelic-weaver-scala:publish -x :newrelic-weaver-scala-api:publish -x :newrelic-opentelemetry-agent-extension:publish -Prelease=true + - name: Publish release scala apis + env: + SONATYPE_USERNAME: ${{ secrets.MIGRATION_TEST_SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.MIGRATION_TEST_SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} + run: ./gradlew $GRADLE_OPTIONS :newrelic-scala3-api:publish :newrelic-scala-api:publish :newrelic-scala-cats-api:publish :newrelic-cats-effect3-api:publish :newrelic-scala-zio-api:publish :newrelic-scala-zio2-api:publish -Prelease=true + - name: Publish apis for Security agent + env: + SONATYPE_USERNAME: ${{ secrets.MIGRATION_TEST_SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.MIGRATION_TEST_SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} + run: ./gradlew $GRADLE_OPTIONS :agent-bridge:publish :agent-bridge-datastore:publish :newrelic-weaver:publish :newrelic-weaver-api:publish :newrelic-weaver-scala:publish :newrelic-weaver-scala-api:publish -Prelease=true + - name: Publish New Relic OpenTelemetry API Extension + env: + SONATYPE_USERNAME: ${{ secrets.MIGRATION_TEST_SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.MIGRATION_TEST_SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} + run: ./gradlew $GRADLE_OPTIONS :newrelic-opentelemetry-agent-extension:publish -Prelease=true diff --git a/automation/pull-request/check-implementation-title.sh b/automation/pull-request/check-implementation-title.sh new file mode 100755 index 0000000000..24359abd04 --- /dev/null +++ b/automation/pull-request/check-implementation-title.sh @@ -0,0 +1,18 @@ +#! /bin/bash + +FILE=$1 + +if [ -z "$FILE" ]; then + echo "Usage: $0 " + exit 1 +fi + +MODULE_NAME=$(basename "$(dirname "$FILE")") +EXPECTED_TITLE="com.newrelic.instrumentation.$MODULE_NAME" +TITLE_LINE=$(grep "'Implementation-Title':\s*'${EXPECTED_TITLE}'" "$FILE") + +#If the line is empty, fail +if [ -z "$TITLE_LINE" ]; then + echo " Error: Expected $EXPECTED_TITLE in 'Implementation-Title' field but did not find it." + exit 1 +fi \ No newline at end of file diff --git a/automation/pull-request/check-verify.sh b/automation/pull-request/check-verify.sh new file mode 100755 index 0000000000..b62d58b43f --- /dev/null +++ b/automation/pull-request/check-verify.sh @@ -0,0 +1,21 @@ +#! /bin/bash + +FILE=$1 + +if [ -z "$FILE" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Extract verifyInstrumentation block +block=$(awk '/verifyInstrumentation[[:space:]]*\{/,/\}/' "$FILE") + +if [ -z "$block" ]; then + echo " Error: verifyInstrumentation block not found." + exit 1 +fi + +if !(echo "$block" | grep -q 'passesOnly') ; then + echo " Error: passesOnly not found inside verifyInstrumentation block." + exit 1 +fi \ No newline at end of file diff --git a/automation/pull-request/lint-build-files.sh b/automation/pull-request/lint-build-files.sh new file mode 100755 index 0000000000..3fe6d9bc4b --- /dev/null +++ b/automation/pull-request/lint-build-files.sh @@ -0,0 +1,31 @@ +#! /bin/bash + +CHANGED_FILES=$@ +MYPATH=$0 +INSTALL_DIR="`dirname ${MYPATH}`" +CHECK_TITLE="IMPLEMENTATION_TITLE_SHOULD_MATCH_MODULE_NAME" +CHECK_VERIFY_INSTRUMENTATION="VERIFY_INSTRUMENTATION_SHOULD_CONTAIN_PASSESONLY" + + +FAILURES="" +for file in $CHANGED_FILES; do + if [[ $file == *instrumentation/*.gradle ]]; then + echo "Checking build file: $file" + /bin/sh "${INSTALL_DIR}/check-verify.sh" "$file" + if [ $? -ne 0 ]; then + FAILURES="${FAILURES} ${CHECK_VERIFY_INSTRUMENTATION}:${file} \n" + fi + /bin/sh "${INSTALL_DIR}/check-implementation-title.sh" "$file" + if [ $? -ne 0 ]; then + FAILURES="${FAILURES} ${CHECK_TITLE}:${file} \n" + fi + fi +done +echo "~~~~~~~~~~ RESULTS ~~~~~~~~~~" +if [[ -n "$FAILURES" ]]; then + echo "Build file checks failed at the following locations:" + echo -e "$FAILURES" + exit 1 +else + echo "All build files passed lint checks." +fi \ No newline at end of file diff --git a/build.gradle b/build.gradle index 38dbe795fb..3b19ddba33 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ allprojects { } } - group = 'com.newrelic.agent.java' + group = 'io.github.kanderson250.agent.java' version = agentVersion + (project.findProperty("release") == "true" ? "" : "-SNAPSHOT") version = version + (project.findProperty("release-suffix") != null ? project.findProperty("release-suffix") : "") diff --git a/instrumentation/my-test-package/build.gradle b/instrumentation/my-test-package/build.gradle new file mode 100644 index 0000000000..d213a7b7e2 --- /dev/null +++ b/instrumentation/my-test-package/build.gradle @@ -0,0 +1,6 @@ + +'Implementation-Title': 'com.newrelic.instrumentation.my-bar-test-package' + +verifyInstrumentation { + passes "foo" +} \ No newline at end of file diff --git a/newrelic-java/build.gradle b/newrelic-java/build.gradle index 1bb3a17d1e..254b4491ee 100644 --- a/newrelic-java/build.gradle +++ b/newrelic-java/build.gradle @@ -8,7 +8,7 @@ plugins { evaluationDependsOn(":newrelic-agent") -group = "com.newrelic.agent.java" +group = "io.github.kanderson250.agent.java" task dist(type: Zip, dependsOn: [ project(":newrelic-agent").newrelicVersionedAgentJar,