Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
erichaagdev committed Sep 8, 2024
1 parent 062905f commit 6957885
Showing 1 changed file with 37 additions and 25 deletions.
62 changes: 37 additions & 25 deletions .github/workflows/maven-build-caching-samples-verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,40 @@ jobs:
projectDir: build-caching-maven-samples
goals: verify
args: -B
# - name: Verify goal outcomes
# run: |
# bearerToken="$(echo "$DEVELOCITY_ACCESS_KEY" | cut -d= -f2)
# buildScanIdFirstBuild="$(echo "${{ steps.build.outputs.buildScanFirstBuild }}" | rev | cut -d/ -f1 | rev )"
# buildScanIdSecondBuild="$(echo "${{ steps.build.outputs.buildScanSecondBuild }}" | rev | cut -d/ -f1 | rev )"
# echo "$buildScanIdFirstBuild"
# echo "$buildScanIdSecondBuild"
# mavenBuildCachePerformanceFirstBuild="$(curl -vs -H "Authorization: Bearer $DEVELOCITY_ACCESS_KEY" "$DEVELOCITY_URL/api/builds/$buildScanIdFirstBuild/maven-build-cache-performance")"
# mavenBuildCachePerformanceSecondBuild="$(curl -vs -H "Authorization: Bearer $DEVELOCITY_ACCESS_KEY" "$DEVELOCITY_URL/api/builds/$buildScanIdSecondBuild/maven-build-cache-performance")"
# echo "$mavenBuildCachePerformanceFirstBuild"
# echo "$mavenBuildCachePerformanceSecondBuild"
# hasMisconfiguredCacheableGoals="$(echo "$mavenBuildCachePerformanceFirstBuild" | jq '[.goalExecution[] | select(.nonCacheabilityCategory != "goal_not_supported" and .nonCacheabilityCategory != null)] | length')"
# hasExecutedCacheableGoals="$(echo "$mavenBuildCachePerformanceSecondBuild" | jq '[.goalExecution[] | select(.avoidanceOutcome == "executed_cacheable")] | length')"
# echo "$hasMisconfiguredCacheableGoals"
# echo "$hasExecutedCacheableGoals"
# exitCode=0
# if [[ "$hasMisconfiguredCacheableGoals" -gt 0 ]]; then
# echo "::error ::Build caching was not enabled for one or more goal executions. See this build scan for more details: ${{ steps.build.outputs.buildScanFirstBuild }}/timeline?cacheability=any-non-cacheable,not:goal-not-supported&hide-timeline"
# exitCode=1
# fi
# if [[ "$hasExecutedCacheableGoals" -gt 0 ]]; then
# echo "::error ::One or more goal cacheable goals were re-executed. See this build scan for more details: ${{ steps.build.outputs.buildScanSecondBuild }}/timeline?cacheability=cacheable&outcome=success,failed&hide-timeline"
# exitCode=1
# fi
# exit $exitCode
- name: Verify goal outcomes
run: |
function callDevelocityApi() {
curl -s -H "Authorization: Bearer $(getDevelocityAccessKey "${DEVELOCITY_URL#https://}")" "${DEVELOCITY_URL}/api$1"
}
function getDevelocityAccessKey() {
for entry in ${DEVELOCITY_ACCESS_KEY//;/ }; do
if [[ "${entry%=*}" == "$1" ]]; then
echo "${entry#*=}" && return
fi
done
echo "::error ::No Develocity access key found for host: $1" && exit 1
}
function getBuildScanIdFromUrl() {
echo "$1" | rev | cut -d/ -f1 | rev
}
buildScanIdFirstBuild="$(getBuildScanIdFromUrl "${{ steps.build.outputs.buildScanFirstBuild }}")"
buildScanIdSecondBuild="$(getBuildScanIdFromUrl "${{ steps.build.outputs.buildScanSecondBuild }}")"
mavenBuildCachePerformanceFirstBuild="$(callDevelocityApi "/builds/$buildScanIdFirstBuild/maven-build-cache-performance")"
mavenBuildCachePerformanceSecondBuild="$(callDevelocityApi "/builds/$buildScanIdSecondBuild/maven-build-cache-performance")"
hasMisconfiguredCacheableGoals="$(echo "$mavenBuildCachePerformanceFirstBuild" | jq '[.goalExecution[] | select(.nonCacheabilityCategory != "goal_not_supported" and .nonCacheabilityCategory != null)] | length')"
hasExecutedCacheableGoals="$(echo "$mavenBuildCachePerformanceSecondBuild" | jq '[.goalExecution[] | select(.avoidanceOutcome == "executed_cacheable")] | length')"
exitCode=0
if [[ "$hasMisconfiguredCacheableGoals" -gt 0 ]]; then
echo "::error ::Build caching was not enabled for one or more goal executions. See this build scan for more details: ${{ steps.build.outputs.buildScanFirstBuild }}/timeline?cacheability=any-non-cacheable,not:goal-not-supported&hide-timeline"
exitCode=1
fi
if [[ "$hasExecutedCacheableGoals" -gt 0 ]]; then
echo "::error ::One or more goal cacheable goals were re-executed. See this build scan for more details: ${{ steps.build.outputs.buildScanSecondBuild }}/timeline?cacheability=cacheable&outcome=success,failed&hide-timeline"
exitCode=1
fi
exit $exitCode

0 comments on commit 6957885

Please sign in to comment.