Skip to content

Commit

Permalink
Merge pull request #562 from Goooler/main
Browse files Browse the repository at this point in the history
Speed up checks on CI
  • Loading branch information
kizitonwose authored Jul 19, 2024
2 parents 4b87a40 + af2ed18 commit 5673c78
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 147 deletions.
125 changes: 60 additions & 65 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,24 @@ name: Check
on:
workflow_dispatch:
pull_request:
# Run whenever we update this file
push:
paths:
- '.github/workflows/check.yml'
branches:
- main

jobs:
ktlint:
name: Ktlint
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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -135,17 +100,47 @@ 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:
api-level: ${{ matrix.api-level }}
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 }}
15 changes: 15 additions & 0 deletions .github/workflows/gradle-wrapper.yaml
Original file line number Diff line number Diff line change
@@ -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
48 changes: 13 additions & 35 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
43 changes: 0 additions & 43 deletions .github/workflows/publish-snapshot.yml

This file was deleted.

5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ allprojects {
}
}
}

tasks.withType<Test>().configureEach {
// https://docs.gradle.org/8.8/userguide/performance.html#execute_tests_in_parallel
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
}
}

apiValidation {
Expand Down
8 changes: 7 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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

Expand Down
18 changes: 15 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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()
}
}
Expand Down

0 comments on commit 5673c78

Please sign in to comment.