Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose raw dependency files #118

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,26 @@ jobs:
debug: true

- uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: file-diff-test-1
name: file-diff-test-1-output
path: ${{ steps.dependency-diff.outputs.file-diff }}
if-no-files-found: error

- uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: file-diff-test-1-dependencies-previous
path: ${{ steps.dependency-diff.outputs.dependencies-previous }}
if-no-files-found: error

- uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: file-diff-test-1-dependencies-current
path: ${{ steps.dependency-diff.outputs.dependencies-current }}
if-no-files-found: error

- uses: peter-evans/find-comment@v3
id: find_comment
if: github.event_name == 'pull_request'
Expand All @@ -63,6 +78,8 @@ jobs:
```

file path: `${{ steps.dependency-diff.outputs.file-diff }}`
previous dependencies: `${{ steps.dependency-diff.outputs.dependencies-previous }}`
current dependencies: `${{ steps.dependency-diff.outputs.dependencies-current }}`
edit-mode: replace
comment-id: ${{ steps.find_comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
Expand Down Expand Up @@ -106,6 +123,7 @@ jobs:
project: ""

- uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: file-diff-test-2
path: ${{ steps.dependency-diff.outputs.file-diff }}
Expand Down Expand Up @@ -168,7 +186,7 @@ jobs:
additional-gradle-arguments: "--scan"

- uses: actions/upload-artifact@v4
if: matrix.os != 'windows-latest' # https://github.com/actions/upload-artifact/issues/337
if: github.event_name == 'pull_request' && matrix.os != 'windows-latest' # https://github.com/actions/upload-artifact/issues/337
with:
name: file-diff-test-on-${{ matrix.os }}
path: ${{ steps.dependency-diff.outputs.file-diff }}
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ outputs:
file-diff:
description: "Path to a file containing the raw diff output"
value: ${{ steps.diff-generator.outputs.file-diff }}
dependencies-current:
description: ""
value: ${{ steps.diff-generator.outputs.dependencies-current }}
dependencies-previous:
description: ""
value: ${{ steps.diff-generator.outputs.dependencies-previous }}
branding:
color: 'red'
icon: 'check-square'
Expand Down
15 changes: 8 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,26 @@ fi

current_head=$(git rev-parse HEAD)

./gradlew $INPUT_ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" > new_diff.txt
./gradlew $INPUT_ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" > dependency_tree_diff_dependencies_current.txt
git fetch --force origin "$INPUT_BASEREF":"$INPUT_BASEREF" --no-tags
git switch --force "$INPUT_BASEREF"
./gradlew $INPUT_ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" > old_diff.txt
java -jar dependency-tree-diff.jar old_diff.txt new_diff.txt > tree_diff.txt
./gradlew $INPUT_ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" > dependency_tree_diff_dependencies_previous.txt
java -jar dependency-tree-diff.jar dependency_tree_diff_dependencies_previous.txt dependency_tree_diff_dependencies_current.txt > dependency_tree_diff_output.txt

if [ "$INPUT_DEBUG" == "true" ]; then
echo "diff generated"
ls -al
du tree_diff.txt
realpath tree_diff.txt
realpath dependency_tree_diff_output.txt
pwd
fi

delimiter=$(openssl rand -hex 20)
echo "text-diff<<$delimiter" >> $GITHUB_OUTPUT
cat tree_diff.txt >> $GITHUB_OUTPUT
cat dependency_tree_diff_output.txt >> $GITHUB_OUTPUT
echo "$delimiter" >> $GITHUB_OUTPUT

echo "file-diff=$(realpath tree_diff.txt)" >> $GITHUB_OUTPUT
echo "file-diff=$(realpath dependency_tree_diff_output.txt)" >> $GITHUB_OUTPUT
echo "dependencies-previous=$(realpath dependency_tree_diff_dependencies_previous.txt)" >> $GITHUB_OUTPUT
echo "dependencies-current=$(realpath dependency_tree_diff_dependencies_current.txt)" >> $GITHUB_OUTPUT

git switch --detach "$current_head"