Skip to content

Commit 1c1eac1

Browse files
feat: optimize github workflows
1 parent 63a83e3 commit 1c1eac1

File tree

3 files changed

+107
-4
lines changed

3 files changed

+107
-4
lines changed

.github/cache-config.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Cache configuration for GitHub Actions
2+
# This file helps manage cache size and optimize build performance
3+
4+
# Cache size limits and cleanup strategies
5+
cache:
6+
# Maximum cache size per workflow (in GB)
7+
max_size_gb: 10
8+
9+
# Cache retention period (in days)
10+
retention_days: 7
11+
12+
# Cache cleanup strategies
13+
cleanup:
14+
# Remove old cache entries
15+
remove_old: true
16+
17+
# Compress cache entries
18+
compress: true
19+
20+
# Exclude patterns from cache
21+
exclude:
22+
- "**/build/tmp/**"
23+
- "**/build/intermediates/**"
24+
- "**/.gradle/daemon/**"
25+
- "**/.gradle/wrapper/dists/**"
26+
- "**/node_modules/**"
27+
- "**/.git/**"
28+
29+
# Gradle-specific cache optimizations
30+
gradle:
31+
# Cache directories to include
32+
cache_paths:
33+
- "~/.gradle/caches"
34+
- "~/.gradle/wrapper"
35+
- ".gradle"
36+
- "buildSrc/.gradle"
37+
38+
# Cache key strategy
39+
cache_key: "${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}"
40+
41+
# Restore keys for fallback
42+
restore_keys:
43+
- "${{ runner.os }}-gradle-"
44+
- "${{ runner.os }}-"
45+
46+
# Build optimizations
47+
build:
48+
# Parallel execution
49+
parallel: true
50+
51+
# Maximum workers
52+
max_workers: 4
53+
54+
# Memory settings
55+
memory:
56+
gradle_daemon: "2g"
57+
kotlin_daemon: "1g"
58+
build_heap: "3g"
59+
60+
# Incremental builds
61+
incremental: false # Disable for CI to ensure clean builds

.github/workflows/detekt.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,21 @@ jobs:
2222
with:
2323
distribution: 'temurin' # See 'Supported distributions' for available options
2424
java-version: '17'
25+
cache: 'gradle'
26+
27+
- name: Cache Gradle packages
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
~/.gradle/caches
32+
~/.gradle/wrapper
33+
.gradle
34+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
35+
restore-keys: |
36+
${{ runner.os }}-gradle-
2537
2638
- name: Run Detekt
27-
run: ./gradlew detektAll
39+
run: ./gradlew detektAll $CI_GRADLE_ARG_PROPERTIES
2840

2941
- name: Upload report
3042
uses: github/codeql-action/upload-sarif@v3

.github/workflows/unit_tests.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,47 @@ jobs:
2727
# Ensure we are building the branch and not the branch after being merged on develop
2828
# https://github.com/actions/checkout/issues/881
2929
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
30+
3031
- name: ☕️ Use JDK 17
31-
uses: actions/setup-java@v3
32+
uses: actions/setup-java@v4
3233
with:
3334
distribution: 'temurin' # See 'Supported distributions' for available options
3435
java-version: '17'
36+
cache: 'gradle'
37+
38+
- name: Cache Gradle packages
39+
uses: actions/cache@v4
40+
with:
41+
path: |
42+
~/.gradle/caches
43+
~/.gradle/wrapper
44+
.gradle
45+
buildSrc/.gradle
46+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
47+
restore-keys: |
48+
${{ runner.os }}-gradle-
49+
${{ runner.os }}-
50+
51+
- name: Cache size check
52+
run: |
53+
echo "Checking cache size..."
54+
du -sh ~/.gradle/caches || echo "No Gradle cache found"
55+
du -sh .gradle || echo "No local Gradle cache found"
56+
3557
- name: Configure gradle
36-
uses: gradle/gradle-build-action@v2.6.1
58+
uses: gradle/gradle-build-action@v2.8.1
3759
with:
3860
cache-read-only: ${{ github.ref != 'refs/heads/develop' }}
61+
arguments: ${{ env.CI_GRADLE_ARG_PROPERTIES }}
62+
gradle-home-cache-cleanup: true
63+
cache-metadata-path: .gradle-cache-metadata
64+
cache-exact-key: true
65+
cache-enabled: true
66+
cache-write-only: false
67+
3968
- name: Generate mock files
40-
run: ./gradlew generateMockedRawFile
69+
run: ./gradlew generateMockedRawFile $CI_GRADLE_ARG_PROPERTIES
70+
4171
- name: Run unit tests
4272
run: ./gradlew testProdDebugUnitTest $CI_GRADLE_ARG_PROPERTIES
4373

0 commit comments

Comments
 (0)