From 8e90b20366ab7908d1f2b0c6f40b1895755da618 Mon Sep 17 00:00:00 2001 From: behzoddev Date: Fri, 1 Sep 2023 02:51:26 +0900 Subject: [PATCH] chore: Add ci script for android --- .github/workflows/android.yml | 98 ++++++++++++++++++++++ .github/workflows/gradle-caches/action.yml | 17 ++++ 2 files changed, 115 insertions(+) create mode 100644 .github/workflows/android.yml create mode 100644 .github/workflows/gradle-caches/action.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 0000000..61e7e4e --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,98 @@ +name: Android CI + +on: + push: + branches: [ "main" ] + tags: + - 'v*' + pull_request: + branches: [ "main" ] + + +concurrency: + group: ${{ github.ref }} + +jobs: + lint: + name: Lint + runs-on: ubuntu-22.04 + steps: + - name: Check out code + uses: actions/checkout@v3.1.0 + - name: Set up JDK 11 + uses: actions/setup-java@v3.6.0 + with: + distribution: adopt + java-version: 11 + + - name: Cache gradle, wrapper and buildSrc + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Cache konan + uses: actions/cache@v3 + with: + path: | + ~/.konan/cache + ~/.konan/dependencies + ~/.konan/kotlin-native-macos* + ~/.konan/kotlin-native-mingw* + ~/.konan/kotlin-native-windows* + ~/.konan/kotlin-native-linux* + ~/.konan/kotlin-native-prebuilt-macos* + ~/.konan/kotlin-native-prebuilt-mingw* + ~/.konan/kotlin-native-prebuilt-windows* + ~/.konan/kotlin-native-prebuilt-linux* + key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-konan- + - name: Make gradlew executable + run: chmod +x ./gradlew + + - name: Spotless Apply + run: ./gradlew spotlessApply --scan + - name: Spotless + run: ./gradlew spotlessCheck + build: + name: Build + runs-on: ubuntu-22.04 + steps: + - name: Check out code + uses: actions/checkout@v3.1.0 + - name: Set up JDK 11 + uses: actions/setup-java@v3.6.0 + with: + distribution: adopt + java-version: 11 + - uses: ./.github/workflows/gradle-caches + with: + key-prefix: gradle-build + - name: Build + run: ./gradlew build + test: + name: Unit tests + runs-on: ubuntu-22.04 + steps: + - name: Check out code + uses: actions/checkout@v3.1.0 + - name: Set up JDK 11 + uses: actions/setup-java@v3.6.0 + with: + distribution: adopt + java-version: 11 + - uses: ./.github/workflows/gradle-caches + with: + key-prefix: gradle-test + - name: Unit tests + run: ./gradlew test + - name: Upload test results + uses: actions/upload-artifact@v3.1.0 + if: failure() + with: + name: testDebugUnitTest + path: ./**/build/reports/tests/testDebugUnitTest diff --git a/.github/workflows/gradle-caches/action.yml b/.github/workflows/gradle-caches/action.yml new file mode 100644 index 0000000..787becd --- /dev/null +++ b/.github/workflows/gradle-caches/action.yml @@ -0,0 +1,17 @@ +name: 'Gradle Cache' +description: 'Cache Gradle Build Cache to improve workflow execution time' +inputs: + key-prefix: + description: 'A prefix on the key used to store/restore cache' + required: true +runs: + using: "composite" + steps: + - uses: actions/cache@v3.0.11 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-${{ inputs.key-prefix }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-${{ inputs.key-prefix }}-