Skip to content

Commit

Permalink
Generate dependency report
Browse files Browse the repository at this point in the history
  • Loading branch information
stoyicker committed Aug 16, 2023
1 parent 6360d84 commit 1cd8efa
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/dependencyReport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- uses: mikepenz/gradle-dependency-submission@v0.9.0
- uses: actions/setup-java@v3.9.0
with:
gradle-build-module: :library
gradle-build-configuration: allSourceSetsCompileDependenciesMetadata
fail-on-error: true
distribution: temurin
java-version: 17
cache: gradle
- run: |
.scripts/dependency_report_generate.sh
-m library
-c allSourceSetsCompileDependenciesMetadata
-o dependencies_library_raw
- run: echo "SCANNED_AT=$(TZ=UTC date +"%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV
44 changes: 44 additions & 0 deletions .scripts/dependency_report_generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
set -e

DIR_TMP="build/report_dependencies"
rm -rf $DIR_TMP || true
mkdir -p $DIR_TMP

print_usage()
{
echo "Usage: $0 -m <module> -c <configuration> -o <output_file>"
}

while getopts ":m:c:o:" OPT; do
case $OPT in
m) MODULE="$OPTARG"
;;
c) CONFIGURATION="$OPTARG"
;;
o) FILE_OUTPUT="$OPTARG"
;;
?) print_usage
exit 1
;;
esac
done

read -r -d '' -a WITH_ADJUSTED < <(./gradlew --console=plain "$MODULE":dependencies --configuration "$CONFIGURATION" | grep --color=never -o "\S*:.*:.*" | grep --color=never -v "/" | awk 'NR > 1' | tr -d " (*)" && printf '\0' )

RESOLVED=()
REGEX_PATTERN_DEPENDENCY_WITH_VERSION_UPGRADED='.*:.*:.*->.*'
for DEPENDENCY in "${WITH_ADJUSTED[@]}"
do
if [[ "$DEPENDENCY" =~ $REGEX_PATTERN_DEPENDENCY_WITH_VERSION_UPGRADED ]]; then
RESOLVED+=("$(echo "$DEPENDENCY" | grep -o ".*:.*:")$(echo "$DEPENDENCY" | cut -d ">" -f2)")
else
RESOLVED+=("$DEPENDENCY")
fi
done
FILE_TMP=$DIR_TMP/"tmp"
for DEPENDENCY in "${RESOLVED[@]}"
do
echo "$DEPENDENCY" >> $FILE_TMP
done
sort -u $FILE_TMP > "$FILE_OUTPUT"
2 changes: 1 addition & 1 deletion .scripts/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

REPORT_DIR="build/pre-commit"
rm -rf $REPORT_DIR || true
mkdir -p ${REPORT_DIR}
mkdir -p $REPORT_DIR

PIDSTOOUTPUTFILES=()
TASK_FILE_BUILD=${REPORT_DIR}/build.log
Expand Down

0 comments on commit 1cd8efa

Please sign in to comment.