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

Migration to Gradle #1625

Merged
merged 59 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
27897f0
Use gradle for project build
petertrr Dec 28, 2020
c22b18b
Use gradle for project build
petertrr Jan 13, 2021
55d6d6f
Use gradle for project build
petertrr Jan 13, 2021
ff83821
Merge remote-tracking branch 'origin/master' into feature/migrate-to-…
petertrr Jan 13, 2021
c975f81
Move project build to gradle
petertrr Jan 13, 2021
33c8d9d
Move project build to gradle
petertrr Jan 13, 2021
b6f703b
Migration to Gradle
nulls Mar 14, 2023
3536bf7
finished a basic migration to gradle
nulls Mar 15, 2023
c176b27
Merge branch 'master' into feature/migrate-to-gradle-2
nulls Mar 15, 2023
b114680
downgrade gradle
nulls Mar 15, 2023
c5401f6
added ksp to generate enum names
nulls Mar 15, 2023
45ca514
reverted unused changes
nulls Mar 15, 2023
9b519f9
reverted unused changes with WarningNames
nulls Mar 15, 2023
d5bb2e4
moved updating copyright year to gradle
nulls Mar 15, 2023
a37789f
migrated maven plugin
nulls Mar 15, 2023
e7cb0ca
disabled explicit setting a goal prefix
nulls Mar 15, 2023
4440904
upgraded ksp
nulls Mar 15, 2023
a7e9fdc
removed pom.xml and fixed PublishingConfiguration
nulls Mar 15, 2023
a80649f
fixed review notes
nulls Mar 16, 2023
269e10d
upgraded itf version
nulls Mar 16, 2023
c95cc12
formatting
nulls Mar 16, 2023
e2e2ba0
fixed package name for gradle/plugins
nulls Mar 16, 2023
87bee78
Merge branch 'master' into feature/migrate-to-gradle-2
nulls Mar 16, 2023
5b81349
Merge remote-tracking branch 'origin/feature/migrate-to-gradle' into …
nulls Mar 16, 2023
deecffa
fixed github action
nulls Mar 16, 2023
bf95ef0
fixed github action
nulls Mar 16, 2023
4674e27
make github executable
nulls Mar 16, 2023
31ede40
downgraded java version
nulls Mar 16, 2023
857e7f2
cleanup VersioningConfiguration.kt
nulls Mar 16, 2023
ca60c8e
fixed detekt to use gradle
nulls Mar 16, 2023
23c3707
fixed diktat-dev-ksp
nulls Mar 16, 2023
8d2df4c
disabled spotless
nulls Mar 16, 2023
509973d
added annotation for ksp
nulls Mar 16, 2023
0429267
Merge branch 'master' into feature/migrate-to-gradle-2
nulls Mar 16, 2023
493825b
fixed a path to fat jar
nulls Mar 16, 2023
7325d3c
Merge remote-tracking branch 'origin/feature/migrate-to-gradle-2' int…
nulls Mar 16, 2023
6d333d5
extracted githook installation
nulls Mar 16, 2023
e2e2012
disabled spotless plugin
nulls Mar 16, 2023
0e0b3b4
added shadow plugin
nulls Mar 16, 2023
f156684
removed spotlessKotlin
nulls Mar 16, 2023
f8c0307
disabled tests for maven
nulls Mar 16, 2023
dbb2b83
WIP
nulls Mar 17, 2023
d564f37
Merge remote-tracking branch 'origin/feature/migrate-to-gradle-2' int…
nulls Mar 17, 2023
f6561f7
removed spotless
nulls Mar 20, 2023
e1b3fd5
Merge remote-tracking branch 'origin/master' into feature/migrate-to-…
nulls Mar 20, 2023
c564f4c
updated .gitignore
nulls Mar 20, 2023
77a8599
WIP
nulls Mar 20, 2023
03641f6
WIP
nulls Mar 22, 2023
a5161cd
fixed shadowJar
nulls Mar 23, 2023
7ad9757
updated detekt.yml, diktat.yml and codeql-analysis.yml
nulls Mar 23, 2023
08620fb
update diktat_snapshot.yml
nulls Mar 23, 2023
69f3f0d
added codecov to common build
nulls Mar 23, 2023
043ed6b
upgraded diktat and fixed detekt issues
nulls Mar 23, 2023
2437a7f
setup snapshot diktat check
nulls Mar 23, 2023
3f9294e
diktatFix
nulls Mar 23, 2023
f260fe3
diktatFix
nulls Mar 23, 2023
327f07b
fixed a path to artifact of diktat-*.jar
nulls Mar 23, 2023
06c35d2
Merge remote-tracking branch 'origin/master' into feature/migrate-to-…
nulls Mar 23, 2023
289ed17
supported changes after merge
nulls Mar 23, 2023
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ ij_smart_tabs = false
ij_visual_guides = 80,120,180
ij_wrap_on_typing = false

[{*.yaml,*.yml}]
indent_size = 2

[{*.kt,*.kts}]
ij_kotlin_align_in_columns_case_branch = false
ij_kotlin_align_multiline_binary_operation = false
Expand Down
137 changes: 86 additions & 51 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,67 @@ on:
branches:
- 'master'

concurrency:
# https://docs.github.com/en/actions/using-jobs/using-concurrency
# The latest queued workflow is preferred; the ones already in progress get cancelled
# Workflows on master branch shouldn't be cancelled, that's why they are identified by commit SHA
group: ${{ github.ref == 'refs/heads/master' && format('{0}-{1}', github.workflow, github.sha) || format('{0}-{1}', github.workflow, github.ref) }}
cancel-in-progress: true

jobs:
build_and_test_with_code_coverage:
name: Build, test and upload code coverage
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
# required for correct codecov upload
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- name: Cache local Maven repository
distribution: temurin
- name: Retrieve Kotlin version
run: |
kv=$(cat gradle/libs.versions.toml | grep '^kotlin =' | awk -F'[=]' '{print $2}' | tr -d '" ')
echo KOTLIN_VERSION=$kv >> $GITHUB_ENV
shell: bash
- name: Cache konan
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: maven-build-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-build-
- name: Maven Install
run: mvn -B -Dstyle.color=always clean install
- name: Code coverage report
uses: codecov/codecov-action@v3
path: ~/.konan
key: ${{ runner.os }}-gradle-konan-${{ env.KOTLIN_VERSION }}
- name: Build all
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
gradle-home-cache-cleanup: true
arguments: |
build
-x detekt
--scan
--build-cache

- name: Upload gradle reports
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
files: '**/target/site/jacoco*/jacoco.xml,**/reports/jacoco/**/*.xml'
flags: unittests
fail_ci_if_error: true # optional (default = false)
name: gradle-reports
path: '**/build/reports/'
retention-days: 1
- name: Upload diktat jar
uses: actions/upload-artifact@v3
with:
name: diktat-ruleset
path: diktat-ruleset/target/diktat-*.jar
# no need to store artifact longer, it is used only by dependant jobs
retention-days: 1
- name: Upload gradle reports
if: ${{ failure() }}
uses: actions/upload-artifact@v3
- name: Code coverage report
uses: codecov/codecov-action@v3
with:
name: gradle-test-report-${{ runner.os }}
path: 'diktat-gradle-plugin/build/reports/'
retention-days: 1
fail_ci_if_error: false

run_diktat_from_CLI:
name: Run diktat via CLI
Expand All @@ -60,10 +80,11 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Setup environment variables

- name: Retrieve Ktlint version
run: |
cat pom.xml | grep "<version>.*</version>" | head -1 | awk -F'[><]' '{ printf "DIKTAT_VERSION=%s\n",$3 }' >> $GITHUB_ENV
cat pom.xml | grep "<ktlint.version>.*</ktlint.version>" | head -1 | awk -F'[><]' '{ printf "KTLINT_VERSION=%s\n",$3 }' >> $GITHUB_ENV
ktlint_version=$(cat gradle/libs.versions.toml | grep '^ktlint =' | awk -F'[=]' '{print $2}' | tr -d '" ')
echo KTLINT_VERSION=$ktlint_version >> $GITHUB_ENV
shell: bash

- name: Setup environment
Expand All @@ -77,10 +98,16 @@ jobs:
with:
name: diktat-ruleset

- name: Retrieve diktat jar file name
run: |
filename=$(ls diktat-*.jar)
echo DIKTAT_JAR=$filename >> $GITHUB_ENV
shell: bash

- name: Run diKTat from cli
continue-on-error: true
run: |
java -jar ktlint -R diktat-${{ env.DIKTAT_VERSION }}.jar --disabled_rules=standard 'examples/maven/src/main/kotlin/Test.kt' &>out.txt
java -jar ktlint -R ${{ env.DIKTAT_JAR }} --disabled_rules=standard 'examples/maven/src/main/kotlin/Test.kt' &>out.txt
shell: bash

- name: Check output
Expand All @@ -94,14 +121,14 @@ jobs:
continue-on-error: true
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
run: |
java -jar ktlint -R diktat-${{ env.DIKTAT_VERSION }}.jar --disabled_rules=standard "$PWD/examples/maven/src/main/kotlin/Test.kt" &>out.txt
java -jar ktlint -R ${{ env.DIKTAT_JAR }} --disabled_rules=standard "$PWD/examples/maven/src/main/kotlin/Test.kt" &>out.txt
shell: bash

- name: Run diKTat from cli on windows (absolute paths)
continue-on-error: true
if: runner.os == 'Windows'
run: |
java -jar ktlint -R diktat-${{ env.DIKTAT_VERSION }}.jar --disabled_rules=standard "%cd%/examples/maven/src/main/kotlin/Test.kt" > out.txt 2>&1
java -jar ktlint -R ${{ env.DIKTAT_JAR }} --disabled_rules=standard "%cd%/examples/maven/src/main/kotlin/Test.kt" > out.txt 2>&1
shell: cmd

- name: Check output (absolute paths)
Expand All @@ -114,7 +141,7 @@ jobs:
- name: Run diKTat from cli (glob paths, 1 of 4)
continue-on-error: true
run: |
java -jar ktlint -R diktat-${{ env.DIKTAT_VERSION }}.jar --disabled_rules=standard 'examples/maven/src/main/kotlin/*.kt' &>out.txt
java -jar ktlint -R ${{ env.DIKTAT_JAR }} --disabled_rules=standard 'examples/maven/src/main/kotlin/*.kt' &>out.txt
shell: bash

- name: Check output (glob paths, 1 of 4)
Expand All @@ -127,7 +154,7 @@ jobs:
- name: Run diKTat from cli (glob paths, 2 of 4)
continue-on-error: true
run: |
java -jar ktlint -R diktat-${{ env.DIKTAT_VERSION }}.jar --disabled_rules=standard 'examples/**/main/kotlin/*.kt' &>out.txt
java -jar ktlint -R ${{ env.DIKTAT_JAR }} --disabled_rules=standard 'examples/**/main/kotlin/*.kt' &>out.txt
shell: bash

- name: Check output (glob paths, 2 of 4)
Expand All @@ -140,7 +167,7 @@ jobs:
- name: Run diKTat from cli (glob paths, 3 of 4)
continue-on-error: true
run: |
java -jar ktlint -R diktat-${{ env.DIKTAT_VERSION }}.jar --disabled_rules=standard 'examples/**/*.kt' &>out.txt
java -jar ktlint -R ${{ env.DIKTAT_JAR }} --disabled_rules=standard 'examples/**/*.kt' &>out.txt
shell: bash

- name: Check output (glob paths, 3 of 4)
Expand All @@ -153,7 +180,7 @@ jobs:
- name: Run diKTat from cli (glob paths, 4 of 4)
continue-on-error: true
run: |
java -jar ktlint -R diktat-${{ env.DIKTAT_VERSION }}.jar --disabled_rules=standard '**/*.kt' &>out.txt
java -jar ktlint -R ${{ env.DIKTAT_JAR }} --disabled_rules=standard '**/*.kt' &>out.txt
shell: bash

- name: Check output (glob paths, 4 of 4)
Expand All @@ -171,7 +198,7 @@ jobs:
# test failures may be OS-specific (or the tests themselves flaky).
fail-fast: false
matrix:
os: [ windows-latest, macos-latest ]
os: [ ubuntu-latest, windows-latest, macos-latest ]

# A possible workaround for <https://github.com/dorny/test-reporter/issues/168>.
permissions:
Expand All @@ -182,30 +209,35 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
# required for correct codecov upload
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: maven-build-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-build-

- name: Maven Install
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
distribution: temurin
- name: Retrieve Kotlin version
run: |
mvn -B -Dstyle.color=always -T1C clean install
kv=$(cat gradle/libs.versions.toml | grep '^kotlin =' | awk -F'[=]' '{print $2}' | tr -d '" ')
echo KOTLIN_VERSION=$kv >> $GITHUB_ENV
shell: bash
- name: Cache konan
uses: actions/cache@v3
with:
path: ~/.konan
key: ${{ runner.os }}-gradle-konan-${{ env.KOTLIN_VERSION }}

- name: Maven Install on windows
if: runner.os == 'Windows'
run: |
mvn -B -Dstyle.color=always -T1C clean install
shell: cmd
- name: Build all
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
gradle-home-cache-cleanup: true
arguments: |
build
-x detekt
--scan
--build-cache

# This step needs a Git repository, so it's impossible to extract it
# into a separate job (or, otherwise, we'd need to upload the content
Expand All @@ -216,7 +248,7 @@ jobs:
with:
name: JUnit Tests (${{ runner.os }}, dorny/test-reporter@v1)
# Comma-separated values.
path: "**/target/*-reports/TEST-*.xml, **/build/test-results/*/TEST-*.xml"
path: "**/build/test-results/*/TEST-*.xml"
reporter: java-junit
# Ignore the "Resource not accessible by integration" error when a PR
# originates from a non-collaborator. This is
Expand All @@ -230,17 +262,20 @@ jobs:
with:
name: xml-test-reports-${{ runner.os }}
path: |
**/target/*-reports/TEST-*.xml
**/build/test-results/*/TEST-*.xml
retention-days: 1

- name: Upload gradle reports
if: ${{ failure() }}
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: gradle-test-report-${{ matrix.os }}
path: 'diktat-gradle-plugin/build/reports/'
path: '**/build/reports/'
retention-days: 1
- name: Code coverage report
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false

report:
name: Publish JUnit test results
Expand Down
22 changes: 19 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['java']
language: ['kotlin']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

Expand Down Expand Up @@ -58,8 +58,24 @@ jobs:
# and modify them (or add more) to build your code if your project
# uses a compiled language

- run: |
mvn clean install
- uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
# The `--continue` flag is necessary so that Gradle keeps going after the 1st test failure.
# By default, when test for all MPP targets are executed, Kotlin Gradle Plugin generates a single aggregated HTML report.
# Property `kotlin.tests.individualTaskReports` enables individual Junit-style XML reports.
# See org.jetbrains.kotlin.gradle.testing.internal.KotlinTestReport.
arguments: |
build
--continue
-x detekt
-Pkotlin.tests.individualTaskReports=true
-Porg.gradle.caching=true
-Pdetekt.multiplatform.disabled=true
-PdisableRedundantTargets=true
-PenabledExecutables=debug
-PgprUser=${{ github.actor }}
-PgprKey=${{ secrets.GITHUB_TOKEN }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
39 changes: 26 additions & 13 deletions .github/workflows/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,37 @@ on:
pull_request:

jobs:
test:
name: Running detekt
runs-on: ubuntu-18.04
detekt_check:
runs-on: ubuntu-latest
permissions:
# required for all workflows
security-events: write

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
- name: Cache local Maven repository
uses: actions/cache@v3
distribution: temurin
- uses: gradle/gradle-build-action@v2
with:
path: ~/.m2/repository
key: maven-detekt-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-detekt-
# when running detekt with type resolution, we need to have all project modules compiled too
- name: running deteKT
run: mvn -B compile dependency:build-classpath@detekt detekt:check@detekt -DskipPluginMarker
gradle-version: wrapper
arguments: |
detektAll
--build-cache
--continue
-PgprUser=${{ github.actor }}
-PgprKey=${{ secrets.GITHUB_TOKEN }}
- name: Upload SARIF report to Github
uses: github/codeql-action/upload-sarif@v2
if: ${{ always() }}
with:
sarif_file: build/detekt-sarif-reports/detekt-merged.sarif
- name: Upload SARIF artifacts
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: sarif-reports
path: "**/build/detekt-sarif-reports/"
retention-days: 1
Loading