diff --git a/.github/workflows/AccessibilityDemo.yml b/.github/workflows/AccessibilityDemo.yml new file mode 100644 index 00000000..a4cb4eae --- /dev/null +++ b/.github/workflows/AccessibilityDemo.yml @@ -0,0 +1,21 @@ +name: AccessibilityDemo + +on: + push: + branches: + - main + paths: + - '.github/workflows/AccessibilityDemo.yml' + - 'AccessibilityDemo/**' + pull_request: + paths: + - '.github/workflows/AccessibilityDemo.yml' + - 'AccessibilityDemo/**' + workflow_dispatch: + +jobs: + build: + uses: ./.github/workflows/build-sample-without-format-check.yml + with: + name: AccessibilityDemo + path: AccessibilityDemo \ No newline at end of file diff --git a/.github/workflows/ClassicsKotlin.yml b/.github/workflows/ClassicsKotlin.yml new file mode 100644 index 00000000..e90b653f --- /dev/null +++ b/.github/workflows/ClassicsKotlin.yml @@ -0,0 +1,21 @@ +name: ClassicsKotlin + +on: + push: + branches: + - main + paths: + - '.github/workflows/ClassicsKotlin.yml' + - 'ClassicsKotlin/**' + pull_request: + paths: + - '.github/workflows/ClassicsKotlin.yml' + - 'ClassicsKotlin/**' + workflow_dispatch: + +jobs: + build: + uses: ./.github/workflows/build-sample-without-check.yml + with: + name: ClassicsKotlin + path: ClassicsKotlin \ No newline at end of file diff --git a/.github/workflows/JetStreamCompose.yml b/.github/workflows/JetStreamCompose.yml new file mode 100644 index 00000000..9d592fb7 --- /dev/null +++ b/.github/workflows/JetStreamCompose.yml @@ -0,0 +1,21 @@ +name: JetStreamCompose + +on: + push: + branches: + - main + paths: + - '.github/workflows/JetStreamCompose.yml' + - 'JetStreamCompose/**' + pull_request: + paths: + - '.github/workflows/JetStreamCompose.yml' + - 'JetStreamCompose/**' + workflow_dispatch: + +jobs: + build: + uses: ./.github/workflows/build-sample.yml + with: + name: JetStreamCompose + path: JetStreamCompose \ No newline at end of file diff --git a/.github/workflows/Leanback.yml b/.github/workflows/Leanback.yml new file mode 100644 index 00000000..97fef9af --- /dev/null +++ b/.github/workflows/Leanback.yml @@ -0,0 +1,21 @@ +name: Leanback + +on: + push: + branches: + - main + paths: + - '.github/workflows/Leanback.yml' + - 'Leanback/**' + pull_request: + paths: + - '.github/workflows/Leanback.yml' + - 'Leanback/**' + workflow_dispatch: + +jobs: + build: + uses: ./.github/workflows/build-sample-without-check.yml + with: + name: Leanback + path: Leanback \ No newline at end of file diff --git a/.github/workflows/LeanbackShowcase.yml b/.github/workflows/LeanbackShowcase.yml new file mode 100644 index 00000000..3d9ece2a --- /dev/null +++ b/.github/workflows/LeanbackShowcase.yml @@ -0,0 +1,21 @@ +name: LeanbackShowcase + +on: + push: + branches: + - main + paths: + - '.github/workflows/LeanbackShowcase.yml' + - 'LeanbackShowcase/**' + pull_request: + paths: + - '.github/workflows/LeanbackShowcase.yml' + - 'LeanbackShowcase/**' + workflow_dispatch: + +jobs: + build: + uses: ./.github/workflows/build-sample-without-check.yml + with: + name: LeanbackShowcase + path: LeanbackShowcase \ No newline at end of file diff --git a/.github/workflows/ReferenceAppKotlin.yml b/.github/workflows/ReferenceAppKotlin.yml new file mode 100644 index 00000000..8e6fc86f --- /dev/null +++ b/.github/workflows/ReferenceAppKotlin.yml @@ -0,0 +1,21 @@ +name: ReferenceAppKotlin + +on: + push: + branches: + - main + paths: + - '.github/workflows/ReferenceAppKotlin.yml' + - 'ReferenceAppKotlin/**' + pull_request: + paths: + - '.github/workflows/ReferenceAppKotlin.yml' + - 'ReferenceAppKotlin/**' + workflow_dispatch: + +jobs: + build: + uses: ./.github/workflows/build-sample-without-check.yml + with: + name: ReferenceAppKotlin + path: ReferenceAppKotlin \ No newline at end of file diff --git a/.github/workflows/TvMaterialCatalog.yml b/.github/workflows/TvMaterialCatalog.yml new file mode 100644 index 00000000..03bfbf40 --- /dev/null +++ b/.github/workflows/TvMaterialCatalog.yml @@ -0,0 +1,21 @@ +name: TvMaterialCatalog + +on: + push: + branches: + - main + paths: + - '.github/workflows/TvMaterialCatalog.yml' + - 'TvMaterialCatalog/**' + pull_request: + paths: + - '.github/workflows/TvMaterialCatalog.yml' + - 'TvMaterialCatalog/**' + workflow_dispatch: + +jobs: + build: + uses: ./.github/workflows/build-sample-without-check.yml + with: + name: TvMaterialCatalog + path: TvMaterialCatalog \ No newline at end of file diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml deleted file mode 100644 index 079eaad1..00000000 --- a/.github/workflows/android.yml +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (C) 2020 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: Android CI - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - - build: - name: Build - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Build project - run: .github/scripts/gradlew_recursive.sh assembleDebug - - name: Zip artifacts - run: zip -r assemble.zip . -i '**/build/*.apk' '**/build/*.aab' '**/build/*.aar' '**/build/*.so' - - name: Upload artifacts - uses: actions/upload-artifact@v1 - with: - name: assemble - path: assemble.zip diff --git a/.github/workflows/build-sample-without-check.yml b/.github/workflows/build-sample-without-check.yml new file mode 100644 index 00000000..8ec3539f --- /dev/null +++ b/.github/workflows/build-sample-without-check.yml @@ -0,0 +1,78 @@ +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Build sample(legacy) +# This action is for the sample app wihtout buildscript/init.gradle.kts +# This action will be removed once all sample app has the kts file + +on: + workflow_call: + inputs: + name: + required: true + type: string + path: + required: true + type: string + +concurrency: + group: ${{ inputs.name }}-build-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: "zulu" + + - name: Generate cache key + run: ./scripts/checksum.sh ${{ inputs.path }} checksum.txt + + - uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches/modules-* + ~/.gradle/caches/jars-* + ~/.gradle/caches/build-cache-* + key: gradle-${{ hashFiles('checksum.txt') }} + + - name: Build debug + working-directory: ${{ inputs.path }} + run: ./gradlew assembleDebug --stacktrace + + - name: Build release + working-directory: ${{ inputs.path }} + run: ./gradlew assembleRelease --stacktrace + + - name: Upload build outputs (APKs) + uses: actions/upload-artifact@v4 + with: + name: build-outputs + path: ${{ inputs.path }}/app/build/outputs + + - name: Upload build reports + if: always() + uses: actions/upload-artifact@v4 + with: + name: build-reports + path: ${{ inputs.path }}/app/build/reports \ No newline at end of file diff --git a/.github/workflows/build-sample.yml b/.github/workflows/build-sample.yml new file mode 100644 index 00000000..a6c7b951 --- /dev/null +++ b/.github/workflows/build-sample.yml @@ -0,0 +1,88 @@ +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Build sample + +on: + workflow_call: + inputs: + name: + required: true + type: string + path: + required: true + type: string + +concurrency: + group: ${{ inputs.name }}-build-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: "zulu" + + - name: Generate cache key + run: ./scripts/checksum.sh ${{ inputs.path }} checksum.txt + + - uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches/modules-* + ~/.gradle/caches/jars-* + ~/.gradle/caches/build-cache-* + key: gradle-${{ hashFiles('checksum.txt') }} + + - name: Check formatting + working-directory: ${{ inputs.path }} + run: ./gradlew --init-script buildscripts/init.gradle.kts spotlessCheck --stacktrace + + - name: Check lint + working-directory: ${{ inputs.path }} + run: ./gradlew lintDebug --stacktrace + + - name: Build debug + working-directory: ${{ inputs.path }} + run: ./gradlew assembleDebug --stacktrace + + - name: Build release + working-directory: ${{ inputs.path }} + run: ./gradlew assembleRelease --stacktrace + + - name: Run local tests + working-directory: ${{ inputs.path }} + run: ./gradlew testDebug --stacktrace + + - name: Upload build outputs (APKs) + uses: actions/upload-artifact@v4 + with: + name: build-outputs + path: ${{ inputs.path }}/app/build/outputs + + - name: Upload build reports + if: always() + uses: actions/upload-artifact@v4 + with: + name: build-reports + path: ${{ inputs.path }}/app/build/reports \ No newline at end of file diff --git a/scripts/checksum.sh b/scripts/checksum.sh new file mode 100755 index 00000000..bc8732f5 --- /dev/null +++ b/scripts/checksum.sh @@ -0,0 +1,40 @@ +# +# Copyright 2022 Google, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +#!/bin/bash +SAMPLE=$1 +RESULT_FILE=$2 + +if [ -f $RESULT_FILE ]; then + rm $RESULT_FILE +fi +touch $RESULT_FILE + +checksum_file() { + echo $(openssl md5 $1 | awk '{print $2}') +} + +FILES=() +while read -r -d ''; do + FILES+=("$REPLY") +done < <(find $SAMPLE -type f \( -name "build.gradle*" -o -name "gradle-wrapper.properties" -o -name "robolectric.properties" \) -print0) + +# Loop through files and append MD5 to result file +for FILE in ${FILES[@]}; do + echo $(checksum_file $FILE) >> $RESULT_FILE +done +# Now sort the file so that it is idempotent +sort $RESULT_FILE -o $RESULT_FILE