diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 24660920..fd8ba9f2 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -3,10 +3,9 @@ name: Check on: workflow_dispatch: pull_request: - # Run whenever we update this file push: - paths: - - '.github/workflows/check.yml' + branches: + - main jobs: ktlint: @@ -14,27 +13,14 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Cache Gradle - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches/ - ~/.gradle/wrapper/ - key: cache-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }} - restore-keys: cache-gradle- - - - name: Validate Gradle - uses: gradle/wrapper-validation-action@v1 - - - name: Setup Java - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 17 - + - uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true - name: Run Ktlint run: ./gradlew lintKotlin @@ -57,27 +43,14 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Cache Gradle - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches/ - ~/.gradle/wrapper/ - key: cache-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }} - restore-keys: cache-gradle- - - - name: Validate Gradle - uses: gradle/wrapper-validation-action@v1 - - - name: Setup Java - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 17 - + - uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true - name: Unit tests run: ./gradlew testDebugUnitTest @@ -91,27 +64,20 @@ jobs: # api-level: [ 24, 29, 33 ] # 33 is currently unreliable. api-level: [ 24, 29 ] steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Cache Gradle - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches/ - ~/.gradle/wrapper/ - key: cache-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }} - restore-keys: cache-gradle- - - - name: Validate Gradle - uses: gradle/wrapper-validation-action@v1 - - - name: Setup Java - uses: actions/setup-java@v3 + - name: Enable KVM group perms + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + ls /dev/kvm + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 17 - + - uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true # API 32+ emulators have no `default` system images. - name: Determine emulator target id: determine-target @@ -123,7 +89,6 @@ jobs: TARGET="google_apis" fi echo "::set-output name=TARGET::$TARGET" - # API 30+ emulators only have x86_64 system images. - name: Determine emulator arch id: determine-arch @@ -135,13 +100,23 @@ jobs: ARCH="x86_64" fi echo "::set-output name=ARCH::$ARCH" - - - name: Enable KVM group perms - run: | - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules - sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm - + - name: AVD cache + uses: actions/cache@v4 + id: avd-cache + with: + path: | + ~/.android/avd/* + ~/.android/adb* + key: avd-${{ matrix.api-level }} + - name: Create AVD and generate snapshot for caching + if: steps.avd-cache.outputs.cache-hit != 'true' + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: ${{ matrix.api-level }} + force-avd-creation: false + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: false + script: echo "Generated AVD snapshot for caching." - name: Instrumentation tests uses: reactivecircus/android-emulator-runner@v2 with: @@ -149,3 +124,23 @@ jobs: target: ${{ steps.determine-target.outputs.TARGET }} arch: ${{ steps.determine-arch.outputs.ARCH }} script: ./gradlew connectedDebugAndroidTest + + # Use macOS so iOS artifacts are published + publish-snapshot: + name: Publish Snapshot + runs-on: macos-latest + if: github.repository == 'kizitonwose/Calendar' && github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 17 + - uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true + - name: Deploy to Maven + run: ./gradlew publish + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} diff --git a/.github/workflows/gradle-wrapper.yaml b/.github/workflows/gradle-wrapper.yaml new file mode 100644 index 00000000..dd67e8b4 --- /dev/null +++ b/.github/workflows/gradle-wrapper.yaml @@ -0,0 +1,15 @@ +name: Gradle Wrapper Validation + +on: + pull_request: + paths: + - 'gradlew' + - 'gradlew.bat' + - 'gradle/wrapper/**' + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: gradle/actions/wrapper-validation@v3 diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index f7ee8973..8ed7f4c1 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -12,42 +12,20 @@ jobs: runs-on: macos-latest if: github.repository == 'kizitonwose/Calendar' steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Cache Gradle - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches/ - ~/.gradle/wrapper/ - key: cache-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }} - restore-keys: cache-gradle- - - - name: Setup Java - uses: actions/setup-java@v3 + - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 17 - - - name: Retrieve Version - run: | - echo "VERSION_NAME=$(cat gradle.properties | grep -w "VERSION_NAME" | cut -d'=' -f2)" >> $GITHUB_ENV - - - name: Deploy Release to Maven + - uses: gradle/actions/setup-gradle@v3 + with: + gradle-home-cache-cleanup: true + - name: Deploy to Maven run: ./gradlew publish - # if: "!endsWith(env.VERSION_NAME, '-SNAPSHOT')" - env: - ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} - ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} - ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SONATYPE_NEXUS_SIGNING_KEY }} - ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SONATYPE_NEXUS_SIGNING_KEY_ID }} - ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SONATYPE_NEXUS_SIGNING_KEY_PASSWORD }} - - # => MANUALLY RELEASE VIA SONATYPE UI FOR NOW <= - # - name: Publish Release to Maven - # run: ./gradlew closeAndReleaseRepository - # if: "!endsWith(env.VERSION_NAME, '-SNAPSHOT')" - # env: - # ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} - # ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} + with: + mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} + mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} + signingInMemoryKey: ${{ secrets.SONATYPE_NEXUS_SIGNING_KEY }} + signingInMemoryKeyId: ${{ secrets.SONATYPE_NEXUS_SIGNING_KEY_ID }} + signingInMemoryKeyPassword: ${{ secrets.SONATYPE_NEXUS_SIGNING_KEY_PASSWORD }} diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml deleted file mode 100644 index 9fbcc4ad..00000000 --- a/.github/workflows/publish-snapshot.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Publish Snapshot - -on: - workflow_dispatch: - push: - branches: - - main - -jobs: - # Use macOS so iOS artifacts are published - publish-snapshot: - name: Publish Snapshot - runs-on: macos-latest - if: github.repository == 'kizitonwose/Calendar' - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Cache Gradle - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches/ - ~/.gradle/wrapper/ - key: cache-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }} - restore-keys: cache-gradle- - - - name: Setup Java - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 17 - - - name: Retrieve Version - run: | - echo "VERSION_NAME=$(cat gradle.properties | grep -w "VERSION_NAME" | cut -d'=' -f2)" >> $GITHUB_ENV - - - name: Publish Snapshot to Maven - run: ./gradlew publish - # if: endsWith(env.VERSION_NAME, '-SNAPSHOT') - env: - ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} - ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} diff --git a/build.gradle.kts b/build.gradle.kts index d716f9e5..39dd17f5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,6 +25,11 @@ allprojects { } } } + + tasks.withType().configureEach { + // https://docs.gradle.org/8.8/userguide/performance.html#execute_tests_in_parallel + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) + } } apiValidation { diff --git a/gradle.properties b/gradle.properties index 76002a3d..b580b232 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,13 @@ -org.gradle.jvmargs=-Xmx1536m +android.defaults.buildfeatures.resvalues=false +android.defaults.buildfeatures.shaders=false android.useAndroidX=true + kotlin.code.style=official +org.gradle.caching=true +org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx4g +org.gradle.parallel=true + SONATYPE_HOST=S01 RELEASE_SIGNING_ENABLED=true diff --git a/settings.gradle.kts b/settings.gradle.kts index 5514c86a..e0d4c460 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,15 +1,27 @@ pluginManagement { repositories { - google() - gradlePluginPortal() + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + } + } mavenCentral() + gradlePluginPortal() } } @Suppress("UnstableApiUsage") dependencyResolutionManagement { // repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { - google() + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + } + } mavenCentral() } }