Restructure how libs, reports, and test results are collected
DELETE
.circleci/collect_artifacts.sh
-#!/bin/bash
-
-# Save all important reports and artifacts into (project-root)/build
-# This folder will be saved by circleci and available after test runs.
-
-set -e
-
-REPORTS_DIR=./reports
-mkdir -p $REPORTS_DIR >/dev/null 2>&1
-
-ARTIFACT_DIR=./artifacts/
-mkdir -p $ARTIFACT_DIR >/dev/null 2>&1
-
-function save_reports () {
- project_to_save=$1
- echo "saving reports for $project_to_save"
-
- report_path=$REPORTS_DIR/$project_to_save/reports
- mkdir -p $report_path
- cp -r workspace/$project_to_save/build/reports/* $report_path/
-}
-
-function save_libs () {
- project_to_save=$1
- echo "saving libs for $project_to_save"
-
- libs_path=$ARTIFACT_DIR/$project_to_save/libs
- mkdir -p $libs_path
- cp -r workspace/$project_to_save/build/libs/* $libs_path/
-}
-
-
-function save_results () {
- echo "saving test results"
- mkdir -p $REPORTS_DIR/results
- find workspace/**/build/test-results -name \*.xml -exec cp {} $REPORTS_DIR/results \;
-}
-
-save_reports dd-java-agent/agent-tooling
-save_reports dd-java-agent/testing
-# Save reports for all instrumentation projects
-for integration_path in dd-java-agent/instrumentation/*; do
- if [ -d "workspace/$integration_path/build/reports" ]; then
- save_reports $integration_path
- fi
-done
-save_reports dd-java-agent-ittests
-save_reports dd-trace-ot
-
-save_libs dd-java-agent
-save_libs dd-trace-api
-save_libs dd-trace-ot
-
-save_results

ADD
.circleci/collect_libs.sh
+#!/usr/bin/env bash
+
+# Save all important libs into (project-root)/libs
+# This folder will be saved by circleci and available after test runs.
+
+set -e
+
+LIBS_DIR=./libs/
+mkdir -p $LIBS_DIR >/dev/null 2>&1
+
+for lib_path in workspace/**/build/libs; do
+ echo "saving libs in $lib_path"
+ cp $lib_path/*.jar $LIBS_DIR/
+done

ADD
.circleci/collect_reports.sh
+#!/usr/bin/env bash
+
+# Save all important reports into (project-root)/reports
+# This folder will be saved by circleci and available after test runs.
+
+set -e
+
+REPORTS_DIR=./reports
+mkdir -p $REPORTS_DIR >/dev/null 2>&1
+
+function save_reports () {
+ project_to_save=$1
+ echo "saving reports for $project_to_save"
+
+ report_path=$REPORTS_DIR/$project_to_save
+ mkdir -p $report_path
+ cp -r workspace/$project_to_save/build/reports/* $report_path/
+}
+
+shopt -s globstar
+
+for report_path in workspace/**/build/reports; do
+ report_path=${report_path//workspace\//}
+ report_path=${report_path//\/build\/reports/}
+ save_reports $report_path
+done

ADD
.circleci/collect_results.sh
+#!/usr/bin/env bash
+
+# Save all important reports and artifacts into (project-root)/results
+# This folder will be saved by circleci and available after test runs.
+
+set -e
+
+TEST_RESULTS_DIR=./results
+mkdir -p $TEST_RESULTS_DIR >/dev/null 2>&1
+
+echo "saving test results"
+mkdir -p $TEST_RESULTS_DIR/results
+find workspace/**/build/test-results -name \*.xml -exec cp {} $TEST_RESULTS_DIR \;

MODIFY
.circleci/config.yml
.circleci/config.yml
@@ -29,7 +29,23 @@ jobs:
- run:
name: Build Project
- command: GRADLE_OPTS="-Dorg.gradle.jvmargs=-Xmx2G -Xms512M" ./gradlew clean compileTestGroovy compileTestScala compileTestJava check -x test -x traceAgentTest --build-cache --parallel --stacktrace --no-daemon --max-workers=6
+ command: GRADLE_OPTS="-Dorg.gradle.jvmargs=-Xmx2G -Xms512M" ./gradlew clean :dd-java-agent:shadowJar compileTestGroovy compileTestScala compileTestJava check -x test -x traceAgentTest --build-cache --parallel --stacktrace --no-daemon --max-workers=6
+
+ - run:
+ name: Collect Libs
+ when: always
+ command: .circleci/collect_libs.sh
+
+ - store_artifacts:
+ path: ./libs
+
+ - run:
+ name: Collect Reports
+ when: always
+ command: .circleci/collect_reports.sh
+
+ - store_artifacts:
+ path: ./reports
- persist_to_workspace:
root: .
@@ -69,15 +85,20 @@ jobs:
command: GRADLE_OPTS="-Dorg.gradle.jvmargs=-Xmx2G -Xms512M" ./gradlew $TEST_TASK --build-cache --parallel --stacktrace --no-daemon --max-workers=3
- run:
- name: Collect Artifacts
+ name: Collect Reports
when: always
- command: .circleci/collect_artifacts.sh
+ command: .circleci/collect_reports.sh
- - store_test_results:
+ - store_artifacts:
path: ./reports
- - store_artifacts:
- path: ./artifacts
+ - run:
+ name: Collect Test Results
+ when: always
+ command: .circleci/collect_results.sh
+
+ - store_test_results:
+ path: ./results
test_7:
<<: *default_test_job
@@ -128,13 +149,21 @@ jobs:
command: ./gradlew traceAgentTest --build-cache --parallel --stacktrace --no-daemon --max-workers=6
- run:
- name: Collect Artifacts
+ name: Collect Reports
when: always
- command: .circleci/collect_artifacts.sh
+ command: .circleci/collect_reports.sh
- - store_test_results:
+ - store_artifacts:
path: ./reports
+ - run:
+ name: Collect Test Results
+ when: always
+ command: .circleci/collect_results.sh
+
+ - store_test_results:
+ path: ./results
+
scan_versions:
<<: *defaults
steps:
@@ -150,17 +179,6 @@ jobs:
name: Verify Version Scan
command: ./gradlew verifyVersionScan --parallel --stacktrace --no-daemon --max-workers=6
- - run:
- name: Collect Artifacts
- when: always
- command: .circleci/collect_artifacts.sh
-
- - store_test_results:
- path: ./reports
-
- - store_artifacts:
- path: ./artifacts
-
- save_cache:
key: dd-trace-java-version-scan-{{ checksum "dd-trace-java.gradle" }}
paths: ~/.gradle

Restructure how libs, reports, and test results are collected