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

Always use latest tool version #105

Merged
merged 8 commits into from
Jan 26, 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
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
47 changes: 43 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -37,6 +38,7 @@ jobs:
configuration: runtimeClasspath
build-root-directory: testproject
project: ""
debug: true

- uses: peter-evans/find-comment@v3
id: find_comment
Expand Down Expand Up @@ -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: ""
Expand All @@ -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"
13 changes: 5 additions & 8 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,27 @@ 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

- id: dependency-diff
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: |
Expand All @@ -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`.
Expand All @@ -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"`

<details><summary></summary>
<p>
Expand Down
11 changes: 8 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
21 changes: 17 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions testproject/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
18 changes: 18 additions & 0 deletions testproject/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ pluginManagement {
}
}

plugins {
id("com.gradle.enterprise") version "3.16.1"
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
Expand All @@ -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"
}
}
}
Loading