From f01eb0e5542f06488560202e6fb78f8640ef5ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Fri, 16 Feb 2024 23:13:31 +0100 Subject: [PATCH 1/2] Expose raw dependencies files --- .github/workflows/main.yml | 16 +++++++++++++++- action.yml | 6 ++++++ entrypoint.sh | 15 ++++++++------- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 42722de..681afb1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,10 +42,22 @@ jobs: - uses: actions/upload-artifact@v4 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 + 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 + 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' @@ -63,6 +75,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 }} diff --git a/action.yml b/action.yml index d23d82c..a84c4bd 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/entrypoint.sh b/entrypoint.sh index 090a0c2..0cac27c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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" From 8c9cf0fd02af3770ce509eec4c1e59c40ddd61a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Fri, 16 Feb 2024 23:17:46 +0100 Subject: [PATCH 2/2] Do not run `upload-artifact` on `master` --- .github/workflows/main.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 681afb1..4ca74bc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,18 +41,21 @@ jobs: debug: true - uses: actions/upload-artifact@v4 + if: github.event_name == 'pull_request' with: 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 }} @@ -120,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 }} @@ -182,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 }}