Skip to content

Commit

Permalink
GHA deduplication(#1253)
Browse files Browse the repository at this point in the history
  • Loading branch information
meiao authored May 10, 2023
1 parent e8a99e2 commit 48a691c
Show file tree
Hide file tree
Showing 15 changed files with 140 additions and 643 deletions.
47 changes: 47 additions & 0 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
@@ -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
43 changes: 9 additions & 34 deletions .github/workflows/Create-Custom-Jar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Create custom jar
on:
workflow_dispatch:
inputs:
ref:
agent-ref:
description: "Specify branch/tag/hash"
required: true
default: 'main'
Expand All @@ -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
Expand Down
95 changes: 14 additions & 81 deletions .github/workflows/GHA-Functional-Tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]

- 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() }}
Expand Down
66 changes: 14 additions & 52 deletions .github/workflows/GHA-Scala-Functional-Tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 48a691c

Please sign in to comment.