diff --git a/.github/actions/setup-environment/action.yml b/.github/actions/setup-environment/action.yml new file mode 100644 index 0000000000..88ce589344 --- /dev/null +++ b/.github/actions/setup-environment/action.yml @@ -0,0 +1,47 @@ +name: Setup Environment +description: Sets up the environment to build/test the agent. +# This action expects the agent to be checked out at $GITHUB_WORKSPACE. +# It will also set up the instrumentation jar zip if AWS credentials are set. +# This action requires these because composite actions cannot use secrets and +# for a composite action to be run, the repo must be checked out. + +runs: + using: composite + + steps: + - name: Set up Javas + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: | + 20 + 17 + 11 + 8 + + - name: Check Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: set gradle.properties + shell: bash + run: | + sed -i -e "s|jdk8=8|jdk8=${JAVA_HOME_8_X64}| + s|jdk11=11|jdk11=${JAVA_HOME_11_X64}| + s|jdk17=17|jdk17=${JAVA_HOME_17_X64}| + s|jdk20=20|jdk20=${JAVA_HOME_20_X64}|" gradle.properties.gha + cat gradle.properties.gha >> gradle.properties + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Setup Gradle options + shell: bash + run: echo "GRADLE_OPTIONS=--console=plain --parallel -Porg.gradle.java.installations.auto-detect=false -Porg.gradle.java.installations.fromEnv=JAVA_HOME_8_X64,JAVA_HOME_11_X64,JAVA_HOME_17_X64,JAVA_HOME_20_X64" >> $GITHUB_ENV + + - name: Download S3 instrumentation jar zip + shell: bash + run: | + aws s3 cp s3://nr-java-agent-s3-instrumentation/proprietary-jars-20220805.zip proprietary-jars.zip && unzip proprietary-jars.zip + if [ $? -ne 0 ]; then + echo "Instrumentation jar zip unavailable." >> $GITHUB_STEP_SUMMARY + fi diff --git a/.github/workflows/Create-Custom-Jar.yml b/.github/workflows/Create-Custom-Jar.yml index 7f15d3015b..7e187124ab 100644 --- a/.github/workflows/Create-Custom-Jar.yml +++ b/.github/workflows/Create-Custom-Jar.yml @@ -3,7 +3,7 @@ name: Create custom jar on: workflow_dispatch: inputs: - ref: + agent-ref: description: "Specify branch/tag/hash" required: true default: 'main' @@ -13,50 +13,25 @@ on: jobs: create_custom_jar: + name: Create jar runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 - with: - ref: ${{ inputs.ref }} - - uses: gradle/wrapper-validation-action@v1 - # JDK 11 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 - - name: save JAVA_HOME as JDK11 for later usage - run: echo "JDK11=$JAVA_HOME" >> $GITHUB_ENV - # setting JDK 8 last so it is the default - - name: Set up JDK 1.8 - uses: actions/setup-java@v3 + - name: Checkout Java agent + uses: actions/checkout@v3 with: - distribution: 'temurin' - java-version: 8 - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - name: Setup Gradle options - run: echo "GRADLE_OPTIONS=-Porg.gradle.java.installations.auto-detect=false -Porg.gradle.java.installations.fromEnv=JDK11" >> $GITHUB_ENV - - name: set gradle.properties - run: | - sed -i -e "s|jdk8=8|jdk8=${JDK8}| - s|jdk11=11|jdk11=${JDK11}|" gradle.properties.gha - mv gradle.properties.gha gradle.properties + ref: ${{ inputs.agent-ref }} - name: Configure AWS Credentials + if: ${{ env.AWS_KEY != '' }} uses: aws-actions/configure-aws-credentials@v1-node16 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-2 - - name: Download S3 instrumentation jar zip - run: aws s3 cp s3://nr-java-agent-s3-instrumentation/proprietary-jars-20220805.zip proprietary-jars.zip ## Updated 2022 - - name: Unzip the instrumentation jars - run: unzip proprietary-jars.zip - # - name: Log jars are in target libs - # run: find instrumentation -name "*.jar" + + - name: Setup environment + uses: ./.github/actions/setup-environment - name: Build agent run: ./gradlew $GRADLE_OPTIONS jar diff --git a/.github/workflows/GHA-Functional-Tests.yaml b/.github/workflows/GHA-Functional-Tests.yaml index dfeb9e57cd..6f8b64583d 100644 --- a/.github/workflows/GHA-Functional-Tests.yaml +++ b/.github/workflows/GHA-Functional-Tests.yaml @@ -30,109 +30,42 @@ jobs: matrix: java-version: [ 8, 11, 17, 20 ] steps: - - uses: actions/checkout@v3 + - name: Checkout Java agent + uses: actions/checkout@v3 with: ref: ${{ inputs.agent-ref || github.ref || 'main' }} - #- uses: gradle/wrapper-validation-action@v1.0.4 - - name: Set up Java 8 - # https://github.com/actions/setup-java - uses: actions/setup-java@v3 + - name: Configure AWS Credentials + if: ${{ env.AWS_KEY != '' }} + uses: aws-actions/configure-aws-credentials@v1-node16 with: - distribution: 'temurin' - java-version: 8 + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-2 - - name: Save JAVA_HOME as JDK8 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk8=$JAVA_HOME" >> $GITHUB_ENV - - - name: Set up Java 11 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 - - - name: Save JAVA_HOME as JDK11 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk11=$JAVA_HOME" >> $GITHUB_ENV - - - name: Set up Java 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 17 - - - name: Save JAVA_HOME as JDK17 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk17=$JAVA_HOME" >> $GITHUB_ENV - - # Install latest non-LTS Java version (we should only ever test one non-LTS version to keep test times reasonable) - - name: Set up Java 20 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 20 - - - name: Save JAVA_HOME as JDK20 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk20=$JAVA_HOME" >> $GITHUB_ENV - - - name: Check environmental variables - run: printenv | sort -f - - - name: Set gradle.properties - run: | - sed -i -e "s|jdk8=8|jdk8=${ORG_GRADLE_PROJECT_jdk8}| - s|jdk11=11|jdk11=${ORG_GRADLE_PROJECT_jdk11}| - s|jdk17=17|jdk17=${ORG_GRADLE_PROJECT_jdk17}| - s|jdk20=20|jdk20=${ORG_GRADLE_PROJECT_jdk20}|" gradle.properties.gha - cat gradle.properties.gha - rm gradle.properties - mv gradle.properties.gha gradle.properties - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + - name: Setup environment + uses: ./.github/actions/setup-environment - name: Build newrelicJar - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: | - echo "*** NOT PUBLISHING BUILD SCANS ***" - ls -la - cat settings.gradle - ./gradlew clean jar --parallel - ls -la newrelic-agent/build/ + run: ./gradlew $GRADLE_OPTIONS clean jar - name: Run functional tests on ${{ matrix.java-version }} (attempt 1) id: run_tests_1 continue-on-error: true timeout-minutes: 50 - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: | - ./gradlew --console=plain --parallel :functional_test:test -Ptest${{ matrix.java-version }} --continue + run: ./gradlew $GRADLE_OPTIONS :functional_test:test -Ptest${{ matrix.java-version }} --continue - name: Run functional tests on ${{ matrix.java-version }} (attempt 2) id: run_tests_2 continue-on-error: true timeout-minutes: 50 if: steps.run_tests_1.outcome == 'failure' - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: | - ./gradlew --console=plain --parallel :functional_test:test -Ptest${{ matrix.java-version }} --continue + run: ./gradlew $GRADLE_OPTIONS :functional_test:test -Ptest${{ matrix.java-version }} --continue - name: Run functional tests on ${{ matrix.java-version }} (attempt 3) timeout-minutes: 50 if: steps.run_tests_2.outcome == 'failure' - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: | - ./gradlew --console=plain --parallel :functional_test:test -Ptest${{ matrix.java-version }} --continue + run: ./gradlew $GRADLE_OPTIONS :functional_test:test -Ptest${{ matrix.java-version }} --continue - name: Capture build reports if: ${{ failure() }} diff --git a/.github/workflows/GHA-Scala-Functional-Tests.yaml b/.github/workflows/GHA-Scala-Functional-Tests.yaml index bbc914414e..795a70e473 100644 --- a/.github/workflows/GHA-Scala-Functional-Tests.yaml +++ b/.github/workflows/GHA-Scala-Functional-Tests.yaml @@ -27,86 +27,48 @@ jobs: matrix: java-version: [8, 11] steps: - - uses: actions/checkout@v3 + - name: Checkout Java agent + uses: actions/checkout@v3 with: ref: ${{ inputs.agent-ref || github.ref || 'main' }} - - name: Set up Java 8 - # https://github.com/actions/setup-java - uses: actions/setup-java@v3 + - name: Configure AWS Credentials + if: ${{ env.AWS_KEY != '' }} + uses: aws-actions/configure-aws-credentials@v1-node16 with: - distribution: 'temurin' - java-version: 8 + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-2 - - name: Save JAVA_HOME as JDK8 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk8=$JAVA_HOME" >> $GITHUB_ENV - - - name: Set up Java 11 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 - - - name: Save JAVA_HOME as JDK11 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk11=$JAVA_HOME" >> $GITHUB_ENV - - - name: Check environmental variables - run: printenv | sort -f - - - name: Set gradle.properties - run: | - sed -i -e "s|jdk8=8|jdk8=${ORG_GRADLE_PROJECT_jdk8}| - s|jdk11=11|jdk11=${ORG_GRADLE_PROJECT_jdk11}|" gradle.properties.gha - cat gradle.properties.gha - rm gradle.properties - mv gradle.properties.gha gradle.properties - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + - name: Setup environment + uses: ./.github/actions/setup-environment - name: Build newrelicJar - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: | - # echo "JAVA_HOME=${ORG_GRADLE_PROJECT_jdk8}" >> $GITHUB_ENV - echo "REVIEW ANY NEW ITEMS IN WORKSPACE" - ls -la - ./gradlew clean jar --parallel - ls -la newrelic-agent/build/ + run: ./gradlew $GRADLE_OPTIONS clean jar - name: Run functional tests against version defined in ${{ matrix.java-version }} (attempt 1) id: run_tests_1 continue-on-error: true timeout-minutes: 25 - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} run: | # Removed ":newrelic-cats-effect3-api:test" temporarily - ./gradlew --console=plain --parallel :newrelic-scala-api:test :newrelic-scala-cats-api:test :newrelic-scala-zio-api:test :newrelic-scala-monix-api:test -PincludeScala -Ptest${{ matrix.java-version }} --continue + ./gradlew $GRADLE_OPTIONS :newrelic-scala-api:test :newrelic-scala-cats-api:test :newrelic-scala-zio-api:test :newrelic-scala-monix-api:test -PincludeScala -Ptest${{ matrix.java-version }} --continue - name: Run functional tests against version defined in ${{ matrix.java-version }} (attempt 2) id: run_tests_2 continue-on-error: true if: steps.run_tests_1.outcome == 'failure' timeout-minutes: 25 - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} run: | # Removed ":newrelic-cats-effect3-api:test" temporarily - ./gradlew --console=plain --parallel :newrelic-scala-api:test :newrelic-scala-cats-api:test :newrelic-scala-zio-api:test :newrelic-scala-monix-api:test -PincludeScala -Ptest${{ matrix.java-version }} --continue + ./gradlew $GRADLE_OPTIONS :newrelic-scala-api:test :newrelic-scala-cats-api:test :newrelic-scala-zio-api:test :newrelic-scala-monix-api:test -PincludeScala -Ptest${{ matrix.java-version }} --continue - name: Run functional tests against version defined in ${{ matrix.java-version }} (attempt 3) if: steps.run_tests_2.outcome == 'failure' timeout-minutes: 25 - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} run: | # Removed ":newrelic-cats-effect3-api:test" temporarily - ./gradlew --console=plain --parallel :newrelic-scala-api:test :newrelic-scala-cats-api:test :newrelic-scala-zio-api:test :newrelic-scala-monix-api:test -PincludeScala -Ptest${{ matrix.java-version }} --continue + ./gradlew $GRADLE_OPTIONS :newrelic-scala-api:test :newrelic-scala-cats-api:test :newrelic-scala-zio-api:test :newrelic-scala-monix-api:test -PincludeScala -Ptest${{ matrix.java-version }} --continue - name: Upload coverage to Codecov diff --git a/.github/workflows/GHA-Scala-Instrumentation-Tests.yaml b/.github/workflows/GHA-Scala-Instrumentation-Tests.yaml index 6b5bd73f6f..29c1335667 100644 --- a/.github/workflows/GHA-Scala-Instrumentation-Tests.yaml +++ b/.github/workflows/GHA-Scala-Instrumentation-Tests.yaml @@ -36,104 +36,42 @@ jobs: - java-version: 11 scala: 2.11 steps: - - uses: actions/checkout@v3 + - name: Checkout Java agent + uses: actions/checkout@v3 with: ref: ${{ inputs.agent-ref || github.ref || 'main' }} - - name: Set up Java 8 - # https://github.com/actions/setup-java - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 8 - - - name: Save JAVA_HOME as JDK8 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk8=$JAVA_HOME" >> $GITHUB_ENV - - - name: Set up Java 11 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 - - - name: Save JAVA_HOME as JDK11 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk11=$JAVA_HOME" >> $GITHUB_ENV - - - name: Check environmental variables - run: printenv | sort -f - - ## AWS jars - plan to cache - # secrets are available in the interface, but may NOT be edited. - name: Configure AWS Credentials - if: ${{ env.AWS_KEY != '' }} + if: ${{ env.AWS_KEY != '' }} uses: aws-actions/configure-aws-credentials@v1-node16 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-2 - - name: Download S3 instrumentation jar zip - run: aws s3 cp s3://nr-java-agent-s3-instrumentation/proprietary-jars-20220805.zip proprietary-jars.zip ## Updated 2022 - if: ${{ env.AWS_KEY != '' }} - - - name: Unzip the instrumentation jars - if: ${{ env.AWS_KEY != '' }} - run: unzip proprietary-jars.zip - - - - name: Log jars are in target libs - if: ${{ env.AWS_KEY != '' }} - run: find instrumentation -name "*.jar" - ## End AWS jars - plan to cache (check for cache, restore if required) - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + - name: Setup environment + uses: ./.github/actions/setup-environment - name: Build newrelicJar - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: | - # echo "JAVA_HOME=${ORG_GRADLE_PROJECT_jdk8}" >> $GITHUB_ENV - echo "REVIEW ANY NEW ITEMS IN WORKSPACE" - ls -la - ./gradlew clean jar --parallel - ls -la newrelic-agent/build/ - - - name: set gradle.properties - run: | - sed -i -e "s|jdk8=8|jdk8=${ORG_GRADLE_PROJECT_jdk8}| - s|jdk11=11|jdk11=${ORG_GRADLE_PROJECT_jdk11}|" gradle.properties.gha - cat gradle.properties.gha - rm gradle.properties - mv gradle.properties.gha gradle.properties + run: ./gradlew $GRADLE_OPTIONS clean jar --parallel - name: Run instrumentation tests for Java ${{ matrix.java-version }} and scala ${{ matrix.scala }} (attempt 1) id: run_tests_1 continue-on-error: true timeout-minutes: 25 - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: ./gradlew --console=plain --parallel :instrumentation:test -Ptest${{ matrix.java-version }} -PnoInstrumentation -Pscala-${{ matrix.scala }} --continue + run: ./gradlew $GRADLE_OPTIONS :instrumentation:test -Ptest${{ matrix.java-version }} -PnoInstrumentation -Pscala-${{ matrix.scala }} --continue - name: Run instrumentation tests for Java ${{ matrix.java-version }} and scala ${{ matrix.scala }} (attempt 2) id: run_tests_2 if: steps.run_tests_1.outcome == 'failure' continue-on-error: true timeout-minutes: 25 - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: ./gradlew --console=plain --parallel :instrumentation:test -Ptest${{ matrix.java-version }} -PnoInstrumentation -Pscala-${{ matrix.scala }} --continue + run: ./gradlew $GRADLE_OPTIONS :instrumentation:test -Ptest${{ matrix.java-version }} -PnoInstrumentation -Pscala-${{ matrix.scala }} --continue - name: Run instrumentation tests for Java ${{ matrix.java-version }} and scala ${{ matrix.scala }} (attempt 3) if: steps.run_tests_2.outcome == 'failure' timeout-minutes: 25 - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: ./gradlew --console=plain --parallel :instrumentation:test -Ptest${{ matrix.java-version }} -PnoInstrumentation -Pscala-${{ matrix.scala }} --continue + run: ./gradlew $GRADLE_OPTIONS :instrumentation:test -Ptest${{ matrix.java-version }} -PnoInstrumentation -Pscala-${{ matrix.scala }} --continue - name: Capture build reports if: ${{ failure() }} diff --git a/.github/workflows/GHA-Unit-Tests.yaml b/.github/workflows/GHA-Unit-Tests.yaml index af72496f01..a5ed02bedd 100644 --- a/.github/workflows/GHA-Unit-Tests.yaml +++ b/.github/workflows/GHA-Unit-Tests.yaml @@ -27,100 +27,39 @@ jobs: matrix: java-version: [8, 11, 17, 20] steps: - - uses: actions/checkout@v3 + - name: Checkout Java agent + uses: actions/checkout@v3 with: ref: ${{ inputs.agent-ref || github.ref || 'main' }} - - name: Set up Java 8 - uses: actions/setup-java@v3 + - name: Configure AWS Credentials + if: ${{ env.AWS_KEY != '' }} + uses: aws-actions/configure-aws-credentials@v1-node16 with: - distribution: 'temurin' - java-version: 8 + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-2 - - name: Save JAVA_HOME as JDK8 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk8=$JAVA_HOME" >> $GITHUB_ENV - - - name: Set up Java 11 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 - - - name: Save JAVA_HOME as JDK11 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk11=$JAVA_HOME" >> $GITHUB_ENV - - - name: Set up Java 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 17 - - - name: Save JAVA_HOME as JDK17 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk17=$JAVA_HOME" >> $GITHUB_ENV - - # Install latest non-LTS Java version (we should only ever test one non-LTS version to keep test times reasonable) - - name: Set up Java 20 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 20 - - - name: Save JAVA_HOME as JDK20 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk20=$JAVA_HOME" >> $GITHUB_ENV - - - name: Check environmental variables - run: printenv | sort -f - - - name: Set gradle.properties - run: | - sed -i -e "s|jdk8=8|jdk8=${ORG_GRADLE_PROJECT_jdk8}| - s|jdk11=11|jdk11=${ORG_GRADLE_PROJECT_jdk11}| - s|jdk17=17|jdk17=${ORG_GRADLE_PROJECT_jdk17}| - s|jdk20=20|jdk20=${ORG_GRADLE_PROJECT_jdk20}|" gradle.properties.gha - cat gradle.properties.gha - rm gradle.properties - mv gradle.properties.gha gradle.properties - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + - name: Setup environment + uses: ./.github/actions/setup-environment - name: Run unit tests for each Java version as defined in the matrix (attempt 1) id: run_tests_1 continue-on-error: true timeout-minutes: 35 - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: | - echo "*** NOT PUBLISHING BUILD SCANS ***" - ./gradlew --console=plain --parallel test -x :functional_test:test -x :newrelic-scala-api:test -x :newrelic-scala-cats-api:test -x :newrelic-cats-effect3-api:test -x :newrelic-scala-monix-api:test -x :newrelic-scala-zio-api:test -Ptest${{ matrix.java-version }} -PnoInstrumentation --continue + run: ./gradlew $GRADLE_OPTIONS test -x :functional_test:test -x :newrelic-scala-api:test -x :newrelic-scala-cats-api:test -x :newrelic-cats-effect3-api:test -x :newrelic-scala-monix-api:test -x :newrelic-scala-zio-api:test -Ptest${{ matrix.java-version }} -PnoInstrumentation --continue - name: Run unit tests for each Java version as defined in the matrix (attempt 2) id: run_tests_2 continue-on-error: true timeout-minutes: 35 if: steps.run_tests_1.outcome == 'failure' - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: | - echo "*** NOT PUBLISHING BUILD SCANS ***" - ./gradlew --console=plain --parallel test -x :functional_test:test -x :newrelic-scala-api:test -x :newrelic-scala-cats-api:test -x :newrelic-cats-effect3-api:test -x :newrelic-scala-monix-api:test -x :newrelic-scala-zio-api:test -Ptest${{ matrix.java-version }} -PnoInstrumentation --continue + run: ./gradlew $GRADLE_OPTIONS test -x :functional_test:test -x :newrelic-scala-api:test -x :newrelic-scala-cats-api:test -x :newrelic-cats-effect3-api:test -x :newrelic-scala-monix-api:test -x :newrelic-scala-zio-api:test -Ptest${{ matrix.java-version }} -PnoInstrumentation --continue - name: Run unit tests for each Java version as defined in the matrix (attempt 3) timeout-minutes: 35 if: steps.run_tests_2.outcome == 'failure' - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: | - echo "*** NOT PUBLISHING BUILD SCANS ***" - ./gradlew --console=plain --parallel test -x :functional_test:test -x :newrelic-scala-api:test -x :newrelic-scala-cats-api:test -x :newrelic-cats-effect3-api:test -x :newrelic-scala-monix-api:test -x :newrelic-scala-zio-api:test -Ptest${{ matrix.java-version }} -PnoInstrumentation --continue + run: ./gradlew $GRADLE_OPTIONS test -x :functional_test:test -x :newrelic-scala-api:test -x :newrelic-scala-cats-api:test -x :newrelic-cats-effect3-api:test -x :newrelic-scala-monix-api:test -x :newrelic-scala-zio-api:test -Ptest${{ matrix.java-version }} -PnoInstrumentation --continue - name: Upload coverage to Codecov if: success() diff --git a/.github/workflows/Java-Instrumentation-Tests.yml b/.github/workflows/Java-Instrumentation-Tests.yml index 843266711d..a5c14ff7b1 100644 --- a/.github/workflows/Java-Instrumentation-Tests.yml +++ b/.github/workflows/Java-Instrumentation-Tests.yml @@ -29,146 +29,46 @@ jobs: # we use these in env vars for conditionals (secrets can't be used in conditionals) AWS_KEY: ${{ secrets.aws-secret-access-key }} steps: - - uses: actions/checkout@v3 + - name: Checkout Java agent + uses: actions/checkout@v3 with: ref: ${{ inputs.agent-ref || github.ref || 'main' }} - # Install 8 - - name: Set up Java 8 - # https://github.com/actions/setup-java - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 8 - - # Save new JDK variable - - name: Save JAVA_HOME as JDK8 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk8=$JAVA_HOME" >> $GITHUB_ENV - - # Install 11 - - name: Set up Java 11 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 - - # Save new JDK variable - - name: Save JAVA_HOME as JDK11 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk11=$JAVA_HOME" >> $GITHUB_ENV - - # Install 17 - - name: Set up Java 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 17 - - # Save new JDK variable - - name: Save JAVA_HOME as JDK17 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk17=$JAVA_HOME" >> $GITHUB_ENV - - # Install latest non-LTS Java version (we should only ever test one non-LTS version to keep test times reasonable) - - name: Set up Java 20 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 20 - - # Save new JDK variable - - name: Save JAVA_HOME as JDK20 for later usage - run: | - echo "Current JAVA_HOME = ${JAVA_HOME}" - echo "ORG_GRADLE_PROJECT_jdk20=$JAVA_HOME" >> $GITHUB_ENV - - # Needed for toolchains and GHA. - - name: setup gradle options - run: echo "GRADLE_OPTIONS=-Porg.gradle.java.installations.auto-detect=false -Porg.gradle.java.installations.fromEnv=ORG_GRADLE_PROJECT_jdk8,ORG_GRADLE_PROJECT_jdk11" >> $GITHUB_ENV - - # Check ENV variables - - name: Check environmental variables - run: printenv | sort -f - - ## AWS jars - plan to cache - name: Configure AWS Credentials if: ${{ env.AWS_KEY != '' }} uses: aws-actions/configure-aws-credentials@v1-node16 with: - aws-access-key-id: ${{ secrets.aws-access-key-id }} - aws-secret-access-key: ${{ secrets.aws-secret-access-key }} + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-2 - - name: Download S3 instrumentation jar zip - if: ${{ env.AWS_KEY != '' }} - run: aws s3 cp s3://nr-java-agent-s3-instrumentation/proprietary-jars-20220805.zip proprietary-jars.zip ## Updated 2022 - - - name: Unzip the instrumentation jars - if: ${{ env.AWS_KEY != '' }} - run: unzip proprietary-jars.zip - - - name: Log jars are in target libs - if: ${{ env.AWS_KEY != '' }} - run: find instrumentation -name "*.jar" - ## End AWS jars - plan to cache (check for cache, restore if required) - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 + - name: Setup environment + uses: ./.github/actions/setup-environment # Is newrelicJar present in newrelic-agent/build # TO DO: Below version number has to be dynamic - name: Build newrelicJar - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: | - ls -la - cat settings.gradle - ./gradlew $GRADLE_OPTIONS clean jar --parallel - ls -la newrelic-agent/build/ + run: ./gradlew $GRADLE_OPTIONS clean jar # GHA run instrumentation tests - # Rewrite gradle.properties - - name: set gradle.properties - run: | - sed -i -e "s|jdk8=8|jdk8=${ORG_GRADLE_PROJECT_jdk8}| - s|jdk11=11|jdk11=${ORG_GRADLE_PROJECT_jdk11}| - s|jdk17=17|jdk17=${ORG_GRADLE_PROJECT_jdk17}| - s|jdk20=20|jdk20=${ORG_GRADLE_PROJECT_jdk20}|" gradle.properties.gha - cat gradle.properties.gha - rm gradle.properties - mv gradle.properties.gha gradle.properties - - name: Run instrumentation tests for Java ${{ matrix.jre }} (attempt 1) id: run_tests_1 continue-on-error: true timeout-minutes: 35 - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: | - ./gradlew $GRADLE_OPTIONS --console=plain :instrumentation:test -Ptest${{ matrix.jre }} --continue + run: ./gradlew $GRADLE_OPTIONS :instrumentation:test -Ptest${{ matrix.jre }} --continue - name: Run instrumentation tests for Java ${{ matrix.jre }} (attempt 2) id: run_tests_2 continue-on-error: true timeout-minutes: 35 if: steps.run_tests_1.outcome == 'failure' - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: | - ./gradlew $GRADLE_OPTIONS --console=plain :instrumentation:test -Ptest${{ matrix.jre }} --continue + run: ./gradlew $GRADLE_OPTIONS :instrumentation:test -Ptest${{ matrix.jre }} --continue - name: Run instrumentation tests for Java ${{ matrix.jre }} (attempt 3) timeout-minutes: 35 if: steps.run_tests_2.outcome == 'failure' - env: - JAVA_HOME: ${{ env.ORG_GRADLE_PROJECT_jdk8 }} - run: | - ./gradlew $GRADLE_OPTIONS --console=plain :instrumentation:test -Ptest${{ matrix.jre }} --continue + run: ./gradlew $GRADLE_OPTIONS :instrumentation:test -Ptest${{ matrix.jre }} --continue # Capture HTML build result in artifacts - name: Capture build reports diff --git a/.github/workflows/Test-AITs.yml b/.github/workflows/Test-AITs.yml index 3417ecce8d..66ae7c3eda 100644 --- a/.github/workflows/Test-AITs.yml +++ b/.github/workflows/Test-AITs.yml @@ -38,7 +38,7 @@ jobs: uses: ./.github/workflows/X-Reusable-BuildAgent.yml with: # inputs.agent-ref is for workflow dispatch/call, github.ref for PR or push, main if all else fail - ref: ${{ inputs.agent-ref || github.ref || 'main' }} + agent-ref: ${{ inputs.agent-ref || github.ref || 'main' }} secrets: inherit list-tests: diff --git a/.github/workflows/VerifyInstrumentation-Single.yml b/.github/workflows/VerifyInstrumentation-Single.yml index 12f2f392ca..7ce581a428 100644 --- a/.github/workflows/VerifyInstrumentation-Single.yml +++ b/.github/workflows/VerifyInstrumentation-Single.yml @@ -24,43 +24,6 @@ jobs: with: ref: ${{ inputs.ref }} - - name: Set up Java 11 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 - - - name: Save JAVA_HOME as JDK11 for later usage - run: | - echo "JDK11=$JAVA_HOME" >> $GITHUB_ENV - - - name: Set up Java 8 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 8 - - - name: Save JAVA_HOME as JDK8 for later usage - run: | - echo "JDK8=$JAVA_HOME" >> $GITHUB_ENV - - # Rewrite gradle.properties - - name: set gradle.properties - run: | - sed -i -e "s|jdk8=8|jdk8=${JDK8}| - s|jdk11=11|jdk11=${JDK11}|" gradle.properties.gha - mv gradle.properties.gha gradle.properties - - # The verify task should not save to the cache. It will only use the cache from the build-agent job. - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - with: - cache-read-only: true - - - name: Setup Gradle options - run: echo "GRADLE_OPTIONS=-Porg.gradle.java.installations.auto-detect=false -Porg.gradle.java.installations.fromEnv=JDK11" >> $GITHUB_ENV - - ## AWS jars - plan to cache - name: Configure AWS Credentials if: ${{ env.AWS_KEY != '' }} uses: aws-actions/configure-aws-credentials@v1-node16 @@ -69,21 +32,11 @@ jobs: aws-secret-access-key: ${{ secrets.aws-secret-access-key }} aws-region: us-east-2 - - name: Download S3 instrumentation jar zip - if: ${{ env.AWS_KEY != '' }} - run: aws s3 cp s3://nr-java-agent-s3-instrumentation/proprietary-jars-20220805.zip proprietary-jars.zip ## Updated 2022 - - - name: Unzip the instrumentation jars - if: ${{ env.AWS_KEY != '' }} - run: unzip proprietary-jars.zip - - - name: Log jars are in target libs - if: ${{ env.AWS_KEY != '' }} - run: find instrumentation -name "*.jar" - ## End AWS jars - plan to cache (check for cache, restore if required) + - name: Setup environment + uses: ./.github/actions/setup-environment - name: Build agent - run: ./gradlew $GRADLE_OPTIONS clean jar --parallel + run: ./gradlew $GRADLE_OPTIONS clean jar - name: Running verifyInstrumentation on (${{ env.MODULE }}) run: ./gradlew $GRADLE_OPTIONS :instrumentation:${{ env.MODULE }}:verifyInstrumentation diff --git a/.github/workflows/VerifyInstrumentation.yml b/.github/workflows/VerifyInstrumentation.yml index 395574f836..375561be40 100644 --- a/.github/workflows/VerifyInstrumentation.yml +++ b/.github/workflows/VerifyInstrumentation.yml @@ -24,7 +24,7 @@ jobs: name: Build agent uses: ./.github/workflows/X-Reusable-BuildAgent.yml with: - ref: ${{ inputs.agent-ref || 'main' }} + agent-ref: ${{ inputs.agent-ref || 'main' }} secrets: inherit # GHA Matrix strategy only allows 255 entries. diff --git a/.github/workflows/X-Reusable-BuildAgent.yml b/.github/workflows/X-Reusable-BuildAgent.yml index 00626305e0..bde2ffaddd 100644 --- a/.github/workflows/X-Reusable-BuildAgent.yml +++ b/.github/workflows/X-Reusable-BuildAgent.yml @@ -3,7 +3,7 @@ name: Build agent on: workflow_call: inputs: - ref: + agent-ref: required: true default: main type: string @@ -16,32 +16,11 @@ jobs: # we use this in env var for conditionals (secrets can't be used in conditionals) AWS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} steps: - - uses: actions/checkout@v3 + - name: Checkout Java agent + uses: actions/checkout@v3 with: - ref: ${{ inputs.ref }} + ref: ${{ inputs.agent-ref }} - - name: Set up Javas - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: | - 11 - 8 - - # Rewrite gradle.properties - - name: set gradle.properties - run: | - sed -i -e "s|jdk8=8|jdk8=${JAVA_HOME_8_x64}| - s|jdk11=11|jdk11=${JAVA_HOME_11_x64}|" gradle.properties.gha - mv gradle.properties.gha gradle.properties - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - - name: Setup Gradle options - run: echo "GRADLE_OPTIONS=-Porg.gradle.java.installations.auto-detect=false -Porg.gradle.java.installations.fromEnv=JAVA_HOME_11_x64" >> $GITHUB_ENV - - ## AWS jars - plan to cache - name: Configure AWS Credentials if: ${{ env.AWS_KEY != '' }} uses: aws-actions/configure-aws-credentials@v1-node16 @@ -50,21 +29,11 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-2 - - name: Download S3 instrumentation jar zip - if: ${{ env.AWS_KEY != '' }} - run: aws s3 cp s3://nr-java-agent-s3-instrumentation/proprietary-jars-20220805.zip proprietary-jars.zip ## Updated 2022 - - - name: Unzip the instrumentation jars - if: ${{ env.AWS_KEY != '' }} - run: unzip proprietary-jars.zip - - - name: Log jars are in target libs - if: ${{ env.AWS_KEY != '' }} - run: find instrumentation -name "*.jar" - ## End AWS jars - plan to cache (check for cache, restore if required) + - name: Setup environment + uses: ./.github/actions/setup-environment - name: Build agent - run: ./gradlew $GRADLE_OPTIONS clean jar --parallel + run: ./gradlew $GRADLE_OPTIONS clean jar - name: Cache agent uses: actions/cache@v3 diff --git a/.github/workflows/X-Reusable-VerifyInstrumentation.yml b/.github/workflows/X-Reusable-VerifyInstrumentation.yml index 7cacb836a8..257afadb9d 100644 --- a/.github/workflows/X-Reusable-VerifyInstrumentation.yml +++ b/.github/workflows/X-Reusable-VerifyInstrumentation.yml @@ -59,22 +59,8 @@ jobs: with: ref: ${{ inputs.ref }} - - name: Set up Javas - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 17 - - # Rewrite gradle.properties - - name: set gradle.properties - run: | - sed -i -e "s|jdk8=8|jdk8=${JAVA_HOME_8_x64}| - s|jdk11=11|jdk11=${JAVA_HOME_11_x64}| - s|jdk17=17|jdk17=${JAVA_HOME_17_x64}|" gradle.properties.gha - mv gradle.properties.gha gradle.properties - - - name: Setup Gradle options - run: echo "GRADLE_OPTIONS=-Porg.gradle.java.installations.auto-detect=false -Porg.gradle.java.installations.fromEnv=JAVA_HOME_11_x64,JAVA_HOME_8_x64" >> $GITHUB_ENV + - name: Setup environment + uses: ./.github/actions/setup-environment - name: Retrieve agent from cache id: retrieve-agent diff --git a/.github/workflows/publish_main_snapshot.yml b/.github/workflows/publish_main_snapshot.yml index 851c4a216c..15d175b5d4 100644 --- a/.github/workflows/publish_main_snapshot.yml +++ b/.github/workflows/publish_main_snapshot.yml @@ -9,57 +9,17 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - - uses: gradle/wrapper-validation-action@v1 - # The first JDK set up gets to be "primary". - - name: Set up JDK 1.8 - uses: actions/setup-java@v1.4.3 - with: - java-version: 8 - - name: save JAVA_HOME as JDK8 for later usage - run: echo "ORG_GRADLE_PROJECT_jdk8=$JAVA_HOME" >> $GITHUB_ENV - # The second JDK is not first in the path but does reset JAVA_HOME - # JDK 11 - - name: Set up JDK 11 - uses: actions/setup-java@v1.4.3 - with: - java-version: 11 - - name: save JAVA_HOME as JDK11 for later usage - run: echo "ORG_GRADLE_PROJECT_jdk11=$JAVA_HOME" >> $GITHUB_ENV - # Java is installed; document settings - - name: log project settings - run: | - echo "--- Java versions ---" - echo "ORG_GRADLE_PROJECT_jdk8: " $ORG_GRADLE_PROJECT_jdk8 - echo "ORG_GRADLE_PROJECT_jdk11: " $ORG_GRADLE_PROJECT_jdk11 - $ORG_GRADLE_PROJECT_jdk8/bin/java -version - $ORG_GRADLE_PROJECT_jdk11/bin/java -version - - name: correct JAVA_HOME - run: echo "JAVA_HOME=$ORG_GRADLE_PROJECT_jdk8" >> $GITHUB_ENV - # Restore the gradle cache - - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - # The docs say to use hashfiles, but gradle itself is smart enough to - # re-download dependencies if it couldn't resolve them. - # Because our gradle cache is _so big_, I think a 90% cache is far - # better than a 0% cache. - key: ${{ runner.os }}-gradle - restore-keys: | - ${{ runner.os }}-gradle + - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1-node16 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-2 - - name: Download S3 instrumentation jar zip - run: aws s3 cp s3://nr-java-agent-s3-instrumentation/proprietary-jars-20220805.zip proprietary-jars.zip ## Updated 2022 - - name: Unzip the instrumentation jars - run: unzip proprietary-jars.zip - - name: Log jars are in target libs - run: find instrumentation -name "*.jar" + + - name: Setup environment + uses: ./.github/actions/setup-environment + - name: Publish snapshot env: SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index bc78cd0503..6a9171b441 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -10,65 +10,17 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - - uses: gradle/wrapper-validation-action@v1 - # The first JDK set up gets to be "primary". - - name: Set up JDK 1.8 - uses: actions/setup-java@v1.4.3 - with: - java-version: 8 - - name: save JAVA_HOME as JDK8 for later usage - run: echo "ORG_GRADLE_PROJECT_jdk8=$JAVA_HOME" >> $GITHUB_ENV - # The second JDK is not first in the path but does reset JAVA_HOME - - name: Set up JDK 1.7 - uses: actions/setup-java@v1.4.3 - with: - java-version: 7 - - name: save JAVA_HOME as JDK7 for later usage - run: echo "ORG_GRADLE_PROJECT_jdk7=$JAVA_HOME" >> $GITHUB_ENV - # JDK 11 - - name: Set up JDK 11 - uses: actions/setup-java@v1.4.3 - with: - java-version: 11 - - name: save JAVA_HOME as JDK11 for later usage - run: echo "ORG_GRADLE_PROJECT_jdk11=$JAVA_HOME" >> $GITHUB_ENV - # Java is installed; document settings - - name: log project settings - run: | - echo "--- Java versions ---" - $ORG_GRADLE_PROJECT_jdk7/bin/java -version - $ORG_GRADLE_PROJECT_jdk8/bin/java -version - $ORG_GRADLE_PROJECT_jdk11/bin/java -version - - name: correct JAVA_HOME - run: echo "JAVA_HOME=$ORG_GRADLE_PROJECT_jdk8" >> $GITHUB_ENV - # these options are required so toolchain only uses the JDKs we specified - - name: setup gradle options - run: echo "GRADLE_OPTIONS=-Porg.gradle.java.installations.auto-detect=false -Porg.gradle.java.installations.fromEnv=ORG_GRADLE_PROJECT_jdk8,ORG_GRADLE_PROJECT_jdk11" >> $GITHUB_ENV - # Restore the gradle cache - - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - # The docs say to use hashfiles, but gradle itself is smart enough to - # re-download dependencies if it couldn't resolve them. - # Because our gradle cache is _so big_, I think a 90% cache is far - # better than a 0% cache. - key: ${{ runner.os }}-gradle - restore-keys: | - ${{ runner.os }}-gradle + - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1-node16 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-2 - - name: Download S3 instrumentation jar zip - run: aws s3 cp s3://nr-java-agent-s3-instrumentation/proprietary-jars-20220805.zip proprietary-jars.zip ## Updated 2022 - - name: Unzip the instrumentation jars - run: unzip proprietary-jars.zip - - name: Log jars are in target libs - run: find instrumentation -name "*.jar" + + - name: Setup environment + uses: ./.github/actions/setup-environment + - name: Publish release env: SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} diff --git a/gradle.properties.gha b/gradle.properties.gha index 6392e6d9dd..8234cac61d 100644 --- a/gradle.properties.gha +++ b/gradle.properties.gha @@ -1,21 +1,4 @@ -# The agent version. -agentVersion=8.3.0 -#org.gradle.java.home=/usr/bin/java jdk8=8 -jdk9=9 -jdk10=10 jdk11=11 -jdk12=12 -jdk13=13 -jdk14=14 -jdk15=15 -jdk16=16 jdk17=17 -jdk18=18 -jdk19=19 jdk20=20 - -newrelicDebug=false -org.gradle.jvmargs=-Xmx2048m -file.encoding=utf-8 -