Restructure how libs, reports, and test results are collected

This commit is contained in:
Tyler Benson 2018-04-18 13:14:03 +08:00
parent c2cb7292c6
commit dee08266ae
5 changed files with 92 additions and 75 deletions

View File

@ -1,54 +0,0 @@
#!/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

14
.circleci/collect_libs.sh Executable file
View File

@ -0,0 +1,14 @@
#!/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

26
.circleci/collect_reports.sh Executable file
View File

@ -0,0 +1,26 @@
#!/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

13
.circleci/collect_results.sh Executable file
View File

@ -0,0 +1,13 @@
#!/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 \;

View File

@ -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
- store_test_results:
path: ./reports
command: .circleci/collect_reports.sh
- store_artifacts:
path: ./artifacts
path: ./reports
- run:
name: Collect Test Results
when: always
command: .circleci/collect_results.sh
- store_test_results:
path: ./results
test_7:
<<: *default_test_job
@ -128,12 +149,20 @@ 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_artifacts:
path: ./reports
- run:
name: Collect Test Results
when: always
command: .circleci/collect_results.sh
- store_test_results:
path: ./reports
path: ./results
scan_versions:
<<: *defaults
@ -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