From c5548baec962336201ee855abe3a27367f090c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Wed, 17 Jan 2024 10:23:15 +0100 Subject: [PATCH 1/8] Always use `latest` tool version --- .github/workflows/main.yml | 2 ++ action.yml | 7 ++++++- entrypoint.sh | 17 +++++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 853361d..0d85e87 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,6 +37,7 @@ jobs: configuration: runtimeClasspath build-root-directory: testproject project: "" + debug: "true" - uses: peter-evans/find-comment@v3 id: find_comment @@ -90,6 +91,7 @@ jobs: if: github.event_name == 'pull_request' with: configuration: runtimeClasspath + lib-version: "1.2.1" build-root-directory: testproject additional-gradle-arguments: "--no-configuration-cache --stacktrace" project: "" diff --git a/action.yml b/action.yml index 2622797..7d9c495 100644 --- a/action.yml +++ b/action.yml @@ -16,11 +16,15 @@ inputs: lib-version: description: 'Dependency diff library version' required: true - default: '1.2.1' + default: 'latest' additional-gradle-arguments: description: 'Additional arguments passed to gradle commands' required: false default: '' + debug: + description: 'Enable debug logs' + required: false + default: 'false' outputs: text-diff: description: "Dependency diff" @@ -39,5 +43,6 @@ runs: INPUT_BUILD_ROOT_DIR: ${{ inputs.build-root-directory }} INPUT_VERSION: ${{ inputs.lib-version }} ADDITIONAL_GRADLE_ARGUMENTS: ${{ inputs.additional-gradle-arguments }} + INPUT_DEBUG: ${{ inputs.debug }} run: ${{ github.action_path }}/entrypoint.sh shell: bash diff --git a/entrypoint.sh b/entrypoint.sh index e4c8952..3fdc9b0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,13 +2,26 @@ cd "$INPUT_BUILD_ROOT_DIR" -wget "https://github.com/JakeWharton/dependency-tree-diff/releases/download/$INPUT_VERSION/dependency-tree-diff.jar" -q -O dependency-tree-diff.jar +if [ "$INPUT_VERSION" == "latest" ]; then + curl -s https://api.github.com/repos/JakeWharton/dependency-tree-diff/releases/latest \ + | grep "/dependency-tree-diff.jar" \ + | cut -d : -f 2,3 \ + | tr -d \" \ + | wget -qi - -O dependency-tree-diff.jar +else + wget "https://github.com/JakeWharton/dependency-tree-diff/releases/download/$INPUT_VERSION/dependency-tree-diff.jar" -q -O dependency-tree-diff.jar + fi if [ "$INPUT_PROJECT" == ":" ]; then INPUT_PROJECT="" fi -./gradlew $ADDITIONAL_GRADLE_ARGUMENTS projects + +if [ "$INPUT_DEBUG" == "true" ]; then + echo "download finished" + ls -al + ./gradlew $ADDITIONAL_GRADLE_ARGUMENTS projects +fi ./gradlew $ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" >new_diff.txt git fetch --force origin "$INPUT_BASEREF":"$INPUT_BASEREF" --no-tags git switch --force "$INPUT_BASEREF" From 0ff93e47995e7bb4639fd82fa515d77775b767dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Wed, 17 Jan 2024 19:53:18 +0100 Subject: [PATCH 2/8] Test on different machines --- .github/workflows/main.yml | 40 ++++++++++++++++++++++++++++++++++---- Readme.md | 8 +++----- action.yml | 2 +- entrypoint.sh | 2 +- testproject/build.gradle | 4 ++++ 5 files changed, 45 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0d85e87..8194bd9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ jobs: java-version: 21 - name: Downgrade dependency version to see the diff - run: sed -i -E 's/androidx.paging:paging-common-ktx:[[:digit:]]+.[[:digit:]]+.[[:digit:]]+/androidx.paging:paging-common-ktx:3.1.0/g' testproject/build.gradle + run: sed -i -E 's/androidx.paging:paging-common-ktx:[[:digit:]]+.[[:digit:]]+.[[:digit:]]+/androidx.paging:paging-common-ktx:3.2.0/g' testproject/build.gradle - uses: gradle/gradle-build-action@v3 with: @@ -73,15 +73,14 @@ jobs: java-version: 21 - name: Downgrade dependency version to see the diff - run: sed -i -E 's/androidx.paging:paging-common-ktx:[[:digit:]]+.[[:digit:]]+.[[:digit:]]+/androidx.paging:paging-common-ktx:3.1.0/g' testproject/build.gradle + run: sed -i -E 's/androidx.paging:paging-common-ktx:[[:digit:]]+.[[:digit:]]+.[[:digit:]]+/androidx.paging:paging-common-ktx:3.2.0/g' testproject/build.gradle - run: | mkdir -p ~/.gradle printf "org.gradle.unsafe.configuration-cache=true" > ~/.gradle/gradle.properties shell: bash - - name: Cache - uses: gradle/gradle-build-action@v3 + - uses: gradle/gradle-build-action@v3 with: build-root-directory: testproject arguments: dependencies --no-configuration-cache @@ -115,3 +114,36 @@ jobs: comment-id: ${{ steps.find_comment.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} token: ${{ secrets.GITHUB_TOKEN }} + + test-on-different-os: + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + name: Execute on ${{ matrix.os }} runner + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 21 + + - name: Downgrade dependency version to see the diff + run: sed -i -E 's/androidx.paging:paging-common-ktx:[[:digit:]]+.[[:digit:]]+.[[:digit:]]+/androidx.paging:paging-common-ktx:3.2.0/g' testproject/build.gradle + + - uses: gradle/gradle-build-action@v3 + with: + build-root-directory: testproject + arguments: dependencies + + - id: dependency-diff + uses: ./ + if: github.event_name == 'pull_request' + with: + configuration: runtimeClasspath + build-root-directory: testproject + project: "" diff --git a/Readme.md b/Readme.md index 132e01e..771c3df 100644 --- a/Readme.md +++ b/Readme.md @@ -23,15 +23,13 @@ jobs: steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: 21 - - uses: gradle/gradle-build-action@v2 + - uses: gradle/gradle-build-action@v3 with: arguments: dependencies @@ -39,13 +37,13 @@ jobs: name: Generate dependency diff uses: usefulness/dependency-tree-diff-action@v1 - - uses: peter-evans/find-comment@v2 + - uses: peter-evans/find-comment@v3 id: find_comment with: issue-number: ${{ github.event.pull_request.number }} body-includes: Dependency diff - - uses: peter-evans/create-or-update-comment@v2 + - uses: peter-evans/create-or-update-comment@v3 if: ${{ steps.dependency-diff.outputs.text-diff != null || steps.find_comment.outputs.comment-id != null }} with: body: | diff --git a/action.yml b/action.yml index 7d9c495..47a2ed3 100644 --- a/action.yml +++ b/action.yml @@ -44,5 +44,5 @@ runs: INPUT_VERSION: ${{ inputs.lib-version }} ADDITIONAL_GRADLE_ARGUMENTS: ${{ inputs.additional-gradle-arguments }} INPUT_DEBUG: ${{ inputs.debug }} - run: ${{ github.action_path }}/entrypoint.sh + run: $GITHUB_ACTION_PATH/entrypoint.sh shell: bash diff --git a/entrypoint.sh b/entrypoint.sh index 3fdc9b0..ca52a70 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,7 +10,7 @@ if [ "$INPUT_VERSION" == "latest" ]; then | wget -qi - -O dependency-tree-diff.jar else wget "https://github.com/JakeWharton/dependency-tree-diff/releases/download/$INPUT_VERSION/dependency-tree-diff.jar" -q -O dependency-tree-diff.jar - fi +fi if [ "$INPUT_PROJECT" == ":" ]; then INPUT_PROJECT="" diff --git a/testproject/build.gradle b/testproject/build.gradle index 791bcee..1822192 100644 --- a/testproject/build.gradle +++ b/testproject/build.gradle @@ -2,6 +2,10 @@ plugins { id("com.starter.library.kotlin") version "0.69.0" } +kotlin { + jvmToolchain(21) +} + dependencies { implementation("androidx.paging:paging-common-ktx:3.2.1") } From 1ceae087d5bfe4e01063da9468548005a0413ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Sun, 21 Jan 2024 15:51:04 +0100 Subject: [PATCH 3/8] Use curl instead of wget --- entrypoint.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index ca52a70..a975cf6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,16 +7,15 @@ if [ "$INPUT_VERSION" == "latest" ]; then | grep "/dependency-tree-diff.jar" \ | cut -d : -f 2,3 \ | tr -d \" \ - | wget -qi - -O dependency-tree-diff.jar + | xargs curl -L -s -o dependency-tree-diff.jar else - wget "https://github.com/JakeWharton/dependency-tree-diff/releases/download/$INPUT_VERSION/dependency-tree-diff.jar" -q -O dependency-tree-diff.jar + curl -L -s -o dependency-tree-diff.jar "https://github.com/JakeWharton/dependency-tree-diff/releases/download/$INPUT_VERSION/dependency-tree-diff.jar" fi if [ "$INPUT_PROJECT" == ":" ]; then INPUT_PROJECT="" fi - if [ "$INPUT_DEBUG" == "true" ]; then echo "download finished" ls -al From 4189f1287ce62f3a4d7860006bdbd59740754587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Sun, 21 Jan 2024 16:00:43 +0100 Subject: [PATCH 4/8] gradle-home-cache-cleanup --- .github/workflows/main.yml | 5 ++++- Readme.md | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8194bd9..fbe015a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,6 +29,7 @@ jobs: with: build-root-directory: testproject arguments: dependencies + gradle-home-cache-cleanup: true - id: dependency-diff if: github.event_name == 'pull_request' @@ -84,6 +85,7 @@ jobs: with: build-root-directory: testproject arguments: dependencies --no-configuration-cache + gradle-home-cache-cleanup: true - id: dependency-diff uses: ./ @@ -119,7 +121,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-latest, windows-latest] + os: [macos-latest, windows-latest, ubuntu-latest] runs-on: ${{ matrix.os }} name: Execute on ${{ matrix.os }} runner steps: @@ -139,6 +141,7 @@ jobs: with: build-root-directory: testproject arguments: dependencies + gradle-home-cache-cleanup: true - id: dependency-diff uses: ./ diff --git a/Readme.md b/Readme.md index 771c3df..ef921a6 100644 --- a/Readme.md +++ b/Readme.md @@ -61,14 +61,13 @@ jobs: All inputs with their default values: ```yml - id: dependency-diff - name: Generate dependency diff uses: usefulness/dependency-tree-diff-action@v1 with: configuration: 'releaseRuntimeClasspath' project: 'app' build-root-directory: . additional-gradle-arguments: '' - lib-version: '1.2.1' + lib-version: 'latest' ``` - **`configuration`** - Selected Gradle configuration, passed to `./gradlew dependencies --configuration xxx`. @@ -79,7 +78,7 @@ Dependency diff for root projects can be configured using `project: ''`. - **`build-root-directory`** - Relative path to folder containing gradle wrapper. Example usage: `build-root-directory: library` - **`additional-gradle-arguments`** - Additional arguments passed to internal Gradle invocation. Example: `"--no-configuration-cache"` or `"--stacktrace"` -- **`lib-version`** - Overrides [dependency-tree-diff](https://github.com/JakeWharton/dependency-tree-diff) dependency version +- **`lib-version`** - Overrides [dependency-tree-diff](https://github.com/JakeWharton/dependency-tree-diff) dependency version. Example: `"1.2.1"`, `"1.1.0"`, `"latest"`

From 5c3efa37d188660d2ec84340955610c8a3865472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Sun, 21 Jan 2024 16:02:42 +0100 Subject: [PATCH 5/8] Run with debug flag --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fbe015a..bcb2f09 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,7 +38,7 @@ jobs: configuration: runtimeClasspath build-root-directory: testproject project: "" - debug: "true" + debug: true - uses: peter-evans/find-comment@v3 id: find_comment @@ -150,3 +150,4 @@ jobs: configuration: runtimeClasspath build-root-directory: testproject project: "" + debug: true From d8308200de0e6e25d09d745dbfaa8746a2860c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Sun, 21 Jan 2024 16:12:58 +0100 Subject: [PATCH 6/8] Publish build scans --- .editorconfig | 9 +++++++++ .github/workflows/main.yml | 1 + entrypoint.sh | 3 ++- testproject/settings.gradle | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..274aa58 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*.{kt,kts}] +max_line_length = 140 +indent_size = 4 +insert_final_newline = true +ij_kotlin_allow_trailing_comma = true +ij_kotlin_allow_trailing_comma_on_call_site = true +ktlint_code_style = intellij_idea diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bcb2f09..b339270 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -151,3 +151,4 @@ jobs: build-root-directory: testproject project: "" debug: true + additional-gradle-arguments: "--scan" diff --git a/entrypoint.sh b/entrypoint.sh index a975cf6..d38826a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,8 +18,9 @@ fi if [ "$INPUT_DEBUG" == "true" ]; then echo "download finished" + echo $JAVA_HOME + java -version ls -al - ./gradlew $ADDITIONAL_GRADLE_ARGUMENTS projects fi ./gradlew $ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" >new_diff.txt git fetch --force origin "$INPUT_BASEREF":"$INPUT_BASEREF" --no-tags diff --git a/testproject/settings.gradle b/testproject/settings.gradle index 1131dd3..31a2d14 100644 --- a/testproject/settings.gradle +++ b/testproject/settings.gradle @@ -5,6 +5,10 @@ pluginManagement { } } +plugins { + id("com.gradle.enterprise") version "3.16.1" +} + dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { @@ -14,3 +18,17 @@ dependencyResolutionManagement { } rootProject.name = 'com.starter.dependencydiff.test' + +gradleEnterprise { + buildScan { + termsOfServiceUrl = "https://gradle.com/terms-of-service" + termsOfServiceAgree = "yes" + + uploadInBackground = System.getenv("CI") == null + + if (System.getenv("CI")) { + publishAlways() + tag "CI" + } + } +} From 30845c547420005fcfc9038ea2d248b2b8c2d3cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Fri, 26 Jan 2024 21:35:24 +0100 Subject: [PATCH 7/8] Rename `INPUT_ADDITIONAL_GRADLE_ARGUMENTS` for consistency --- action.yml | 2 +- entrypoint.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 47a2ed3..73516fa 100644 --- a/action.yml +++ b/action.yml @@ -42,7 +42,7 @@ runs: INPUT_BASEREF: ${{ github.base_ref }} INPUT_BUILD_ROOT_DIR: ${{ inputs.build-root-directory }} INPUT_VERSION: ${{ inputs.lib-version }} - ADDITIONAL_GRADLE_ARGUMENTS: ${{ inputs.additional-gradle-arguments }} + INPUT_ADDITIONAL_GRADLE_ARGUMENTS: ${{ inputs.additional-gradle-arguments }} INPUT_DEBUG: ${{ inputs.debug }} run: $GITHUB_ACTION_PATH/entrypoint.sh shell: bash diff --git a/entrypoint.sh b/entrypoint.sh index d38826a..48f177a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,14 +18,14 @@ fi if [ "$INPUT_DEBUG" == "true" ]; then echo "download finished" - echo $JAVA_HOME + echo "$JAVA_HOME" java -version ls -al fi -./gradlew $ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" >new_diff.txt +./gradlew $INPUT_ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" >new_diff.txt git fetch --force origin "$INPUT_BASEREF":"$INPUT_BASEREF" --no-tags git switch --force "$INPUT_BASEREF" -./gradlew $ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" >old_diff.txt +./gradlew $INPUT_ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" >old_diff.txt diff=$(java -jar dependency-tree-diff.jar old_diff.txt new_diff.txt) From cf24f8920f820b74fce63e14754884ab492d8e5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Fri, 26 Jan 2024 21:51:10 +0100 Subject: [PATCH 8/8] temporairly disable macos-runner --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b339270..55b93b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -121,7 +121,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-latest, windows-latest, ubuntu-latest] + os: [windows-latest, ubuntu-latest] runs-on: ${{ matrix.os }} name: Execute on ${{ matrix.os }} runner steps: