Skip to content

Commit be76239

Browse files
authored
Merge pull request #177 from komodgn/infra/ci-refactoring
Infra/ci refactoring
2 parents cb589ad + 315f17d commit be76239

3 files changed

Lines changed: 87 additions & 45 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: 'Setup Android Environment'
2+
description: 'Installs JDK 21, Android SDK, configures Gradle caches, and generates local.properties for Android CI jobs.'
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Setup JDK 21
8+
uses: actions/setup-java@v4
9+
with:
10+
java-version: '21'
11+
distribution: 'temurin'
12+
cache: gradle
13+
14+
- name: Setup Android SDK
15+
uses: android-actions/setup-android@v3
16+
17+
- name: Cache Gradle Wrapper
18+
uses: actions/cache@v4
19+
with:
20+
path: ~/.gradle/wrapper
21+
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
22+
restore-keys: |
23+
${{ runner.os }}-gradle-wrapper-
24+
25+
- name: Cache Build Cache
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.gradle/caches/build-cache-1
29+
key: ${{ runner.os }}-build-cache-${{ hashFiles('**/build.gradle*', '**/gradle-wrapper.properties') }}-${{ github.sha }}
30+
restore-keys: |
31+
${{ runner.os }}-build-cache-${{ hashFiles('**/build.gradle*', '**/gradle-wrapper.properties') }}
32+
${{ runner.os }}-build-cache-
33+
34+
- name: Generate local.properties
35+
shell: bash
36+
run: |
37+
echo '${{ env.LOCAL_PROPERTIES }}' | base64 -d > ./local.properties
38+
39+
- name: Grant execute permission for gradlew
40+
shell: bash
41+
run: chmod +x gradlew

.github/workflows/android-ci.yml

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,10 @@ jobs:
2020
- name: Checkout Repository
2121
uses: actions/checkout@v4
2222

23-
- name: Setup JDK 21
24-
uses: actions/setup-java@v4
25-
with:
26-
java-version: '21'
27-
distribution: 'temurin'
28-
cache: gradle
29-
30-
- name: Setup Android SDK
31-
uses: android-actions/setup-android@v2
32-
33-
- name: Cache Gradle Wrapper
34-
uses: actions/cache@v4
35-
with:
36-
path: ~/.gradle/wrapper
37-
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
38-
restore-keys: |
39-
${{ runner.os }}-gradle-wrapper-
40-
41-
- name: Cache Build Cache
42-
uses: actions/cache@v4
43-
with:
44-
path: ~/.gradle/caches/build-cache-1
45-
key: ${{ runner.os }}-build-cache-${{ hashFiles('**/build.gradle*', '**/gradle-wrapper.properties') }}-${{ github.sha }}
46-
restore-keys: |
47-
${{ runner.os }}-build-cache-${{ hashFiles('**/build.gradle*', '**/gradle-wrapper.properties') }}
48-
${{ runner.os }}-build-cache-
49-
50-
- name: Generate local.properties
51-
run: echo '${{ secrets.LOCAL_PROPERTIES }}' | base64 -d > ./local.properties
52-
53-
- name: Grant execute permission for gradlew
54-
run: chmod +x gradlew
23+
- name: Setup
24+
uses: ./.github/actions/setup-android
25+
env:
26+
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }}
5527

5628
- name: Code Style Check
5729
id: ktlint
@@ -61,14 +33,6 @@ jobs:
6133
end=$(date +%s)
6234
echo "time=$((end-start))" >> $GITHUB_OUTPUT
6335
64-
- name: Unit Test
65-
id: test
66-
run: |
67-
start=$(date +%s)
68-
./gradlew testDebugUnitTest --parallel
69-
end=$(date +%s)
70-
echo "time=$((end-start))" >> $GITHUB_OUTPUT
71-
7236
- name: Debug Build with Gradle
7337
id: assemble
7438
run: |
@@ -91,11 +55,6 @@ jobs:
9155
with:
9256
script: |
9357
const results = {
94-
test: {
95-
status: '${{ steps.test.outcome }}',
96-
name: 'Unit Test',
97-
time: '${{ steps.test.outputs.time }}'
98-
},
9958
assemble: {
10059
status: '${{ steps.assemble.outcome }}',
10160
name: 'Debug Build',

.github/workflows/unit-test.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: unit-test
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- '**.md'
7+
8+
run-name: "unit-test by ${{ github.actor }}"
9+
10+
permissions:
11+
contents: read
12+
pull-requests: write
13+
actions: write
14+
15+
jobs:
16+
unit-test:
17+
runs-on: ubuntu-latest
18+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-ci') }}
19+
timeout-minutes: 30
20+
21+
steps:
22+
- name: Checkout Repository
23+
uses: actions/checkout@v4
24+
25+
- name: Setup
26+
uses: ./.github/actions/setup-android
27+
env:
28+
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }}
29+
30+
- name: Run Unit Tests and Record Screenshots
31+
id: test
32+
run: ./gradlew testDebugUnitTest --parallel --stacktrace
33+
34+
- name: Upload Test Reports and Screenshots
35+
if: always()
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: test-reports
39+
path: |
40+
**/build/reports/tests
41+
**/build/outputs/roborazzi
42+
retention-days: 7

0 commit comments

Comments
 (0)