From dfdea81c2c2691946b9c97a83c82c8881037718e Mon Sep 17 00:00:00 2001 From: Ali M AlDirawi Date: Sat, 4 Jan 2025 19:32:58 +0200 Subject: [PATCH] feat: Add ci workflow for the repo An event will trigger when every new pull request is created or pushed to the main branch, which includes the following actions: - checkout the branch. - build gradle. - build the project. - run lint to check build errors. - run unit test. --- .github/workflows/android-kotlin-ci.yml | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/android-kotlin-ci.yml diff --git a/.github/workflows/android-kotlin-ci.yml b/.github/workflows/android-kotlin-ci.yml new file mode 100644 index 0000000..da917db --- /dev/null +++ b/.github/workflows/android-kotlin-ci.yml @@ -0,0 +1,59 @@ +name: Kotlin Android CI Workflow + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # Step 1: Checkout the code + - name: Checkout code + uses: actions/checkout@v3 + + # Step 2: Set up JDK for Android + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '17' + + # Step 3: Set up Android SDK + - name: Set up Android SDK + uses: android-actions/setup-android@v2 + + # Step 4: Cache Gradle dependencies + - name: Cache Gradle dependencies + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + gradle- + + # Step 5: Grant executable permissions to the gradlew script + - name: Grant execute permission for Gradlew + run: chmod +x ./gradlew + + # Step 5: Build the project + - name: Build with Gradle + run: ./gradlew assembleDebug + + # Step 6: Run Lint checks + - name: Run Kotlin Lint + run: ./gradlew lintDebug + + # Step 7: Run unit tests + - name: Run Unit Tests + run: ./gradlew testDebugUnitTest + + # Step 8: Run Instrumentation Tests (Optional) + # Uncomment this step if you have instrumentation tests configured + # - name: Run Instrumented Tests + # run: ./gradlew connectedAndroidTest