diff --git a/.github/actions/disk-cleanup/action.yml b/.github/actions/disk-cleanup/action.yml new file mode 100644 index 00000000000..862cfd95c92 --- /dev/null +++ b/.github/actions/disk-cleanup/action.yml @@ -0,0 +1,37 @@ +name: Disk cleanup +description: Clean up disk space by removing unnecessary files +runs: + using: 'composite' + steps: + - name: Clean up unnecessary files + shell: bash + run: | + # Remove Java JDKs + sudo rm -rf /usr/lib/jvm + + # Remove .NET SDKs + sudo rm -rf /usr/share/dotnet + + # Remove Swift toolchain + sudo rm -rf /usr/share/swift + + # Remove Haskell (GHC) + sudo rm -rf /usr/local/.ghcup + + # Remove Julia + sudo rm -rf /usr/local/julia* + + # Remove Chromium (optional if not using for browser tests) + sudo rm -rf /usr/local/share/chromium + + # Remove Microsoft/Edge and Google Chrome builds + sudo rm -rf /opt/microsoft /opt/google + + # Remove Azure CLI + sudo rm -rf /opt/az + + # Remove PowerShell + sudo rm -rf /usr/local/share/powershell + + # Remove toolcaches + sudo rm -rf /opt/hostedtoolcache diff --git a/.github/actions/disk-usage/action.yml b/.github/actions/disk-usage/action.yml new file mode 100644 index 00000000000..e146b8bdb16 --- /dev/null +++ b/.github/actions/disk-usage/action.yml @@ -0,0 +1,24 @@ +name: Disk usage +description: Show disk usage +runs: + using: 'composite' + steps: + - name: Total runner disk usage + shell: bash + run: df -h / + + - name: Workspace usage + shell: bash + run: du -sh $GITHUB_WORKSPACE || true + + - name: Gradle user home usage + shell: bash + run: du -sh ~/.gradle || true + + - name: Gradle cache usage + shell: bash + run: du -sh ~/.gradle/caches || true + + - name: Build outputs usage + shell: bash + run: du -sh build app-*/build || true diff --git a/.github/actions/gradle_cache/action.yml b/.github/actions/gradle_cache/action.yml deleted file mode 100644 index 58464b51132..00000000000 --- a/.github/actions/gradle_cache/action.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Gradle cache -description: Enable Gradle Wrapper caching (optimization) -runs: - using: 'composite' - steps: - - name: Enable Gradle Wrapper caching - uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # 4.2.4 - with: - path: - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- diff --git a/.github/actions/setup-gradle/action.yml b/.github/actions/setup-gradle/action.yml new file mode 100644 index 00000000000..53f19675878 --- /dev/null +++ b/.github/actions/setup-gradle/action.yml @@ -0,0 +1,34 @@ +name: Set up Gradle build environment +description: Prepares environment for building with JDK and Gradle +inputs: + run-release: + description: 'Whether to run in release mode (true/false). In release mode, Gradle cache is not used.' + required: false + default: 'false' + add-job-summary: + description: 'Whether to add a job summary (always, never, on-failure).' + required: false + default: 'always' + write-cache: + description: 'Whether to write to the cache (true/false).' + required: false + default: 'false' +runs: + using: 'composite' + steps: + - name: Copy CI gradle.properties + shell: bash + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties + + - name: Set up JDK + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 + with: + distribution: 'temurin' + java-version: '21' + + - name: Set up Gradle without cache + uses: gradle/actions/setup-gradle@748248ddd2a24f49513d8f472f81c3a07d4d50e1 # v4.4.4 + with: + cache-disabled: ${{ inputs.run-release }} + add-job-summary: ${{ inputs.add-job-summary }} + cache-read-only: ${{ inputs.write-cache == 'false' || inputs.run-release == 'true' }} diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml deleted file mode 100644 index f3446bfc3dd..00000000000 --- a/.github/actions/setup/action.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Set up build environment -description: Prepares environment for building with JDK and Gradle -runs: - using: 'composite' - steps: - - name: Copy CI gradle.properties - shell: bash - run: mkdir -p ~/.gradle ; cp .github/ci-gradle-android-pr-workflow.properties ~/.gradle/gradle.properties - - - name: Set up JDK - uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 - with: - distribution: 'temurin' - java-version: '21' - - - name: Set up Gradle - uses: gradle/actions/setup-gradle@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4.4.1 - - - name: Restore Gradle cache - uses: ./.github/actions/gradle_cache diff --git a/.github/ci-gradle-android-pr-workflow.properties b/.github/ci-gradle-android-pr-workflow.properties deleted file mode 100644 index aa7bdba98be..00000000000 --- a/.github/ci-gradle-android-pr-workflow.properties +++ /dev/null @@ -1,10 +0,0 @@ -org.gradle.daemon=false -org.gradle.parallel=true -org.gradle.caching=true -org.gradle.configuration-cache=true -org.gradle.configuration-cache.parallel=true -org.gradle.workers.max=4 -org.gradle.jvmargs=-Xmx10g -XX:MaxMetaspaceSize=4g -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:+HeapDumpOnOutOfMemoryError - -kotlin.incremental=true -kotlin.compiler.execution.strategy=in-process diff --git a/.github/ci-gradle.properties b/.github/ci-gradle.properties index 51c4e2f1d3f..d329ec204a9 100644 --- a/.github/ci-gradle.properties +++ b/.github/ci-gradle.properties @@ -1,7 +1,10 @@ -org.gradle.daemon=false +org.gradle.daemon=true org.gradle.parallel=true +org.gradle.caching=true +org.gradle.configuration-cache=true +org.gradle.configuration-cache.parallel=true org.gradle.workers.max=4 -org.gradle.jvmargs=-Xmx10g -XX:MaxMetaspaceSize=2g -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:+HeapDumpOnOutOfMemoryError +org.gradle.jvmargs=-Xmx10g -XX:MaxMetaspaceSize=4g -Dfile.encoding=UTF-8 -XX:+UseParallelGC kotlin.incremental=true kotlin.compiler.execution.strategy=in-process diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9206ebd8427..4d634ef05c9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,7 +1,11 @@ version: 2 updates: + # Dependabot does not support GitHub composite actions by default (.github/actions) + # so we need to add the folder by hand to the directories entry. - package-ecosystem: "github-actions" - directory: "/" + directories: + - "/" + - "/.github/actions/*" schedule: interval: "weekly" labels: diff --git a/.github/workflows/android-pr.yml b/.github/workflows/android-pr.yml index 594266fe9d8..281042c9865 100644 --- a/.github/workflows/android-pr.yml +++ b/.github/workflows/android-pr.yml @@ -30,8 +30,8 @@ jobs: - name: Checkout the repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - name: Prepares environment - uses: ./.github/actions/setup + - name: Setup Gradle environment + uses: ./.github/actions/setup-gradle - name: Build K9 application run: ./gradlew :app-k9mail:assemble @@ -44,8 +44,8 @@ jobs: - name: Checkout the repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - name: Prepares environment - uses: ./.github/actions/setup + - name: Setup Gradle environment + uses: ./.github/actions/setup-gradle - name: Build Thunderbird application run: ./gradlew :app-thunderbird:assemble @@ -58,8 +58,8 @@ jobs: - name: Checkout the repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - name: Prepares environment - uses: ./.github/actions/setup + - name: Setup Gradle environment + uses: ./.github/actions/setup-gradle - name: Build App UI-catalog application in Debug mode run: ./gradlew :app-ui-catalog:assembleDebug @@ -81,9 +81,9 @@ jobs: if: steps.changes.outputs.cli_tools_changed == 'true' uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - name: Prepares environment + - name: Setup Gradle environment if: steps.changes.outputs.cli_tools_changed == 'true' - uses: ./.github/actions/setup + uses: ./.github/actions/setup-gradle - name: Build CLI tools # run only if CLI tools were changed @@ -98,8 +98,8 @@ jobs: - name: Checkout the repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - name: Prepares environment - uses: ./.github/actions/setup + - name: Setup Gradle environment + uses: ./.github/actions/setup-gradle - name: Running Android lint run: ./gradlew lint @@ -112,8 +112,8 @@ jobs: - name: Checkout the repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - name: Prepares environment - uses: ./.github/actions/setup + - name: Setup Gradle environment + uses: ./.github/actions/setup-gradle - name: Running spotless check run: ./gradlew spotlessCheck @@ -126,8 +126,8 @@ jobs: - name: Checkout the repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - name: Prepares environment - uses: ./.github/actions/setup + - name: Setup Gradle environment + uses: ./.github/actions/setup-gradle - name: Running Detekt run: ./gradlew detekt @@ -149,8 +149,8 @@ jobs: - name: Checkout the repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - name: Prepares environment - uses: ./.github/actions/setup + - name: Setup Gradle environment + uses: ./.github/actions/setup-gradle - name: Running unit tests run: ./gradlew testsOnCi --parallel @@ -163,8 +163,8 @@ jobs: - name: Checkout the repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - name: Prepares environment - uses: ./.github/actions/setup + - name: Setup Gradle environment + uses: ./.github/actions/setup-gradle - name: Running Dependency Guard run: ./gradlew dependencyGuard @@ -177,8 +177,8 @@ jobs: - name: Checkout the repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - name: Prepares environment - uses: ./.github/actions/setup + - name: Setup Gradle environment + uses: ./.github/actions/setup-gradle - name: Running K9 Badging run: | diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml deleted file mode 100644 index 734f1898f8a..00000000000 --- a/.github/workflows/android.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Android CI - -on: - push: - branches: - - main - pull_request: - paths-ignore: - - '.idea/**' - - '.gitattributes' - - '.github/**.json' - - '.gitignore' - - '.gitmodules' - - '**.md' - - 'LICENSE' - - 'NOTICE' - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - timeout-minutes: 90 - - steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - - name: Copy CI gradle.properties - run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - - - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 - with: - distribution: 'temurin' - java-version: '21' - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@748248ddd2a24f49513d8f472f81c3a07d4d50e1 # v4.4.4 - - - name: Quality - Spotless - run: ./gradlew spotlessCheck - - - name: Quality - Detekt - run: ./gradlew detekt - - - name: Quality - Lint - run: ./gradlew lint - - - name: Quality - Dependency Guard - run: ./gradlew dependencyGuard - - - name: Build (run full build and tests) - run: ./gradlew build diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml new file mode 100644 index 00000000000..78b16f34837 --- /dev/null +++ b/.github/workflows/build-android.yml @@ -0,0 +1,72 @@ +name: Android CI + +on: + push: + branches: + - main + pull_request: + paths-ignore: + - '.idea/**' + - '.gitattributes' + - '.github/**.json' + - '.gitignore' + - '.gitmodules' + - '**.md' + - 'LICENSE' + - 'NOTICE' + +permissions: + contents: read + +concurrency: + group: android-ci-${{ github.ref }}-${{ github.event.pull_request.number || 'no-pr' }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + build-android: + name: Build Android application + runs-on: ubuntu-latest + timeout-minutes: 90 + + steps: + - name: Checkout the repo + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + fetch-depth: 1 + + - name: Show disk usage + uses: ./.github/actions/disk-usage + + - name: Cleanup disk + uses: ./.github/actions/disk-cleanup + + - name: Setup Gradle environment + uses: ./.github/actions/setup-gradle + with: + write-cache: ${{ github.ref == 'refs/heads/main' }} + + - name: Show disk usage + uses: ./.github/actions/disk-usage + + - name: Quality - Spotless + run: ./gradlew spotlessCheck + + - name: Quality - Detekt + run: ./gradlew detekt + + - name: Quality - Lint + run: ./gradlew lint + + - name: Show disk usage + uses: ./.github/actions/disk-usage + + - name: Quality - Dependency Guard + run: ./gradlew dependencyGuard + + - name: Build (run full build and tests) + run: ./gradlew build + + - name: Show disk usage + uses: ./.github/actions/disk-usage + + diff --git a/.github/workflows/markdown.yml b/.github/workflows/markdown.yml index 1c0acd30279..18bf77b8d43 100644 --- a/.github/workflows/markdown.yml +++ b/.github/workflows/markdown.yml @@ -22,16 +22,8 @@ jobs: - name: Install mdbook and extensions run: ./docs/install.sh - - name: Copy CI gradle.properties - run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - - - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 - with: - distribution: 'temurin' - java-version: '21' - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@748248ddd2a24f49513d8f472f81c3a07d4d50e1 # v4.4.4 + - name: Setup Gradle environment + uses: ./.github/actions/setup-gradle - name: Quality - Spotless Markdown Check run: ./gradlew spotlessFlexmarkCheck diff --git a/.github/workflows/shippable_builds.yml b/.github/workflows/shippable_builds.yml index 8a40f3c36a8..0e5dbcaf80e 100644 --- a/.github/workflows/shippable_builds.yml +++ b/.github/workflows/shippable_builds.yml @@ -220,22 +220,11 @@ jobs: fetch-depth: 0 token: ${{ steps.app-token.outputs.token || github.token }} - - name: Copy CI gradle.properties - if: ${{ contains(matrix.releaseTarget, 'github') || needs.dump_config.outputs.releaseType == 'daily' }} - shell: bash - run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - - - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 - if: ${{ contains(matrix.releaseTarget, 'github') || needs.dump_config.outputs.releaseType == 'daily' }} - with: - distribution: 'temurin' - java-version: '21' - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@748248ddd2a24f49513d8f472f81c3a07d4d50e1 # v4.4.4 + - name: Setup Gradle environment if: ${{ contains(matrix.releaseTarget, 'github') || needs.dump_config.outputs.releaseType == 'daily' }} + uses: ./.github/actions/setup-gradle with: - cache-disabled: "${{ contains(fromJSON('[\"beta\", \"release\"]'), needs.dump_config.outputs.releaseType) }}" + run-release: "${{ contains(fromJSON('[\"beta\", \"release\"]'), needs.dump_config.outputs.releaseType) }}" add-job-summary: never - name: Get application info @@ -470,19 +459,10 @@ jobs: with: ref: ${{ steps.sha.outputs.app_sha }} - - name: Copy CI gradle.properties - shell: bash - run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties - - - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 - with: - distribution: 'temurin' - java-version: '21' - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@748248ddd2a24f49513d8f472f81c3a07d4d50e1 # v4.4.4 + - name: Setup Gradle environment + uses: ./.github/actions/setup-gradle with: - cache-disabled: "${{ contains(fromJSON('[\"beta\", \"release\"]'), needs.dump_config.outputs.releaseType) }}" + run-release: "${{ contains(fromJSON('[\"beta\", \"release\"]'), needs.dump_config.outputs.releaseType) }}" add-job-summary: on-failure - name: Set Version Code for Daily diff --git a/quality/konsist/build.gradle.kts b/quality/konsist/build.gradle.kts index a9e018eeb37..6ea5a85ce68 100644 --- a/quality/konsist/build.gradle.kts +++ b/quality/konsist/build.gradle.kts @@ -3,7 +3,10 @@ plugins { } kotlin { - jvmToolchain(11) + jvmToolchain { + languageVersion = JavaLanguageVersion.of(11) + vendor = JvmVendorSpec.ADOPTIUM + } } dependencies { diff --git a/settings.gradle.kts b/settings.gradle.kts index 0e3a5216475..962b12f3974 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,6 +17,10 @@ pluginManagement { } } +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" +} + dependencyResolutionManagement { repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS repositories {