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 853361d..55b93b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,12 +23,13 @@ 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: build-root-directory: testproject arguments: dependencies + gradle-home-cache-cleanup: true - id: dependency-diff if: github.event_name == 'pull_request' @@ -37,6 +38,7 @@ jobs: configuration: runtimeClasspath build-root-directory: testproject project: "" + debug: true - uses: peter-evans/find-comment@v3 id: find_comment @@ -72,24 +74,25 @@ 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 + gradle-home-cache-cleanup: true - id: dependency-diff uses: ./ 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: "" @@ -113,3 +116,39 @@ 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: [windows-latest, ubuntu-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 + gradle-home-cache-cleanup: true + + - id: dependency-diff + uses: ./ + if: github.event_name == 'pull_request' + with: + configuration: runtimeClasspath + build-root-directory: testproject + project: "" + debug: true + additional-gradle-arguments: "--scan" diff --git a/Readme.md b/Readme.md index 132e01e..ef921a6 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: | @@ -63,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`. @@ -81,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"`

diff --git a/action.yml b/action.yml index 2622797..73516fa 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" @@ -38,6 +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 }} - run: ${{ github.action_path }}/entrypoint.sh + 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 e4c8952..48f177a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,17 +2,30 @@ 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 \" \ + | xargs curl -L -s -o dependency-tree-diff.jar +else + 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 -./gradlew $ADDITIONAL_GRADLE_ARGUMENTS projects -./gradlew $ADDITIONAL_GRADLE_ARGUMENTS "$INPUT_PROJECT":dependencies --configuration "$INPUT_CONFIGURATION" >new_diff.txt +if [ "$INPUT_DEBUG" == "true" ]; then + echo "download finished" + echo "$JAVA_HOME" + java -version + ls -al +fi +./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) 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") } 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" + } + } +}