Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Setup github workflows, lint + format repo, fix unit tests #64

Merged
merged 25 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
13c20d4
ci: add build & release workflows from https://github.com/android/now…
deepanchal Aug 3, 2023
e70b363
fix(ci): add missing ci-gradle.properties file for build workflow
deepanchal Aug 3, 2023
53846a1
ci: improve build & release workflows
deepanchal Aug 3, 2023
6f0c01b
feat(spotless): add necessary files for spotless check
deepanchal Aug 3, 2023
b5ea692
chore(tools): set java distribution to zulu from adoptopenjdk
deepanchal Aug 18, 2023
3e13cda
chore(tools): specify full version for java as asdf can't recognize it
deepanchal Aug 18, 2023
7f95149
refactor(androidTest): replace wildcard imports with specific imports…
deepanchal Aug 18, 2023
71c08d9
feat(spotless): remove copyright texts from spotless copyright files …
deepanchal Aug 18, 2023
aa9d483
feat(gradle): disable no-wildcard-imports & filename rules in ktlint
deepanchal Aug 18, 2023
1da26d1
chore: add .git-blame-ignore-revs
deepanchal Aug 18, 2023
5992ee6
ci(build): use assembleDemoDebug for build all step
deepanchal Aug 18, 2023
74fb5b3
ci(build): increase timeout for build and test jobs
deepanchal Aug 18, 2023
f2f8ca2
test(unit): fix coordinatesToTileCoordinates test in `TileCoordinates…
deepanchal Aug 21, 2023
81b4945
test(unit): fix param in assertUpdatedWrongLocationFlag test in `Loca…
deepanchal Aug 21, 2023
65b69bc
test(unit): fix issues with `AuthenticationViewModelTest`
deepanchal Aug 21, 2023
8f42274
test(unit): skip all tests in `AuthenticationViewModelTest` as auth f…
deepanchal Aug 21, 2023
f308463
test(unit): remove undefined import from AuthenticationViewModelTest
deepanchal Aug 21, 2023
657a04e
test(unit): fix missing Locale import in `CrisisCleanupAppStateTest`
deepanchal Aug 21, 2023
bf4ae0d
test(unit): add missing allowAnalytics option in `AuthenticatedViewMo…
deepanchal Aug 21, 2023
a55f283
ci(build): disable androidTest & androidTest-GMD jobs since packageDe…
deepanchal Aug 21, 2023
01ce3d5
style(format): run `./gradlew --init-script gradle/init.gradle.kts --…
deepanchal Aug 21, 2023
7b06a6d
ci(build): split gradle task steps into separate jobs (build, lint, u…
deepanchal Aug 21, 2023
7444017
ci(main): rename build.yml to main.yml, update workflow name
deepanchal Aug 21, 2023
71bf506
ci(main): fix unit-test job name
deepanchal Aug 21, 2023
d9e0de7
ci(main): fix concurrency group name for main workflow
deepanchal Aug 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# style(format): run spotlessApply cmd on codebase to fix lint + format issues
cc43a9f0e1550a50d6025abb2bba2d143e799709
# style(format): run `./gradlew --init-script gradle/init.gradle.kts spotlessApply` to format + lint all files
1fb424562e796ea572d9f9d6d8d88c3bc9f3bb0c
28 changes: 28 additions & 0 deletions .github/ci-gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright 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
#
# 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.
#

org.gradle.daemon=false
org.gradle.parallel=true
org.gradle.workers.max=2

kotlin.incremental=false
kotlin.compiler.execution.strategy=in-process

# Controls KotlinOptions.allWarningsAsErrors.
# This value used in CI and is currently set to false.
# If you want to treat warnings as errors locally, set this property to true
# in your ~/.gradle/gradle.properties file.
warningsAsErrors=false
225 changes: 225 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
name: Main

on:
push:
branches:
- main
pull_request:

concurrency:
group: build-${{ github.job }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build 🏗️
runs-on: ubuntu-latest
timeout-minutes: 120

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Validate Gradle Wrapper 📝
uses: gradle/wrapper-validation-action@v1

- name: Copy CI gradle.properties 📋
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Set up JDK 17 ⚙️
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17

- name: Setup Gradle ⚙️
uses: gradle/gradle-build-action@v2

- name: Build all build type and flavor permutations 🏗️
run: ./gradlew assembleDemoDebug

- name: 📊 Upload build outputs (APKs)
uses: actions/upload-artifact@v3
with:
name: APKs
path: '**/build/outputs/apk/**/*.apk'

spotless-check:
name: Spotless Check 📝
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Validate Gradle Wrapper 📝
uses: gradle/wrapper-validation-action@v1

- name: Copy CI gradle.properties 📋
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Set up JDK 17 ⚙️
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17

- name: Setup Gradle ⚙️
uses: gradle/gradle-build-action@v2

- name: Check spotless 📝
run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache

lint:
name: Lint Check 💅
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Validate Gradle Wrapper 📝
uses: gradle/wrapper-validation-action@v1

- name: Copy CI gradle.properties 📋
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Set up JDK 17 ⚙️
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17

- name: Setup Gradle ⚙️
uses: gradle/gradle-build-action@v2

- name: Check lint 💅
run: ./gradlew lintDemoDebug

- name: 📊 Upload lint reports (HTML)
if: always()
uses: actions/upload-artifact@v3
with:
name: lint-reports
path: '**/build/reports/lint-results-*.html'

unit-test:
name: Unit Test 🧪
runs-on: ubuntu-latest
timeout-minutes: 120

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Validate Gradle Wrapper 📝
uses: gradle/wrapper-validation-action@v1

- name: Copy CI gradle.properties 📋
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Set up JDK 17 ⚙️
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17

- name: Setup Gradle ⚙️
uses: gradle/gradle-build-action@v2

- name: Run local tests 🧪
run: ./gradlew testDemoDebug testProdDebug

- name: 📊 Upload test results (XML)
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results
path: '**/build/test-results/test*UnitTest/**.xml'

androidTest:
if: false # disabled bc packageDemoDebugAndroidTest is failing
name: Android Test 🧪
needs: build
runs-on: macos-latest # enables hardware acceleration in the virtual machine
timeout-minutes: 90
strategy:
matrix:
api-level: [26, 30]

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Copy CI gradle.properties 📋
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Set up JDK 17 ⚙️
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17

- name: Setup Gradle ⚙️
uses: gradle/gradle-build-action@v2

- name: Build AndroidTest apps 🏗️
run: ./gradlew packageDemoDebug packageDemoDebugAndroidTest --daemon

- name: Run instrumentation tests 🧪
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
disable-animations: true
disk-size: 6000M
heap-size: 600M
script: ./gradlew connectedDemoDebugAndroidTest --daemon

- name: 📊 Upload test reports
if: always()
uses: actions/upload-artifact@v3
with:
name: test-reports-${{ matrix.api-level }}
path: '**/build/reports/androidTests'

androidTest-GMD:
if: false # disabled bc packageDemoDebugAndroidTest is failing
name: Android Test GMD 🧪
needs: build
runs-on: macos-latest # enables hardware acceleration in the virtual machine
timeout-minutes: 90

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Copy CI gradle.properties 📋
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Set up JDK 17 ⚙️
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17

- name: Setup Gradle ⚙️
uses: gradle/gradle-build-action@v2

- name: Accept Android licenses ✔️
run: yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --licenses || true

- name: Build AndroidTest apps 🏗️
run: ./gradlew packageDemoDebug packageDemoDebugAndroidTest

- name: Run instrumented tests with GMD 🧪
run: ./gradlew cleanManagedDevices --unused-only &&
./gradlew ciDemoDebugAndroidTest -Dorg.gradle.workers.max=1
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" -Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true

- name: 📊 Upload test reports
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: test-reports
path: '**/build/reports/androidTests'
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: GitHub Release with APKs

on:
push:
tags:
- 'v*'

jobs:
build:
name: Build and Release 🏷️
runs-on: ubuntu-latest
timeout-minutes: 45

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Validate Gradle Wrapper 📝
uses: gradle/wrapper-validation-action@v1

- name: Copy CI gradle.properties 📋
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Set up JDK 17 ⚙️
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17

- name: Build app 🏗️
run: ./gradlew :app:assembleDemoRelease

- name: Create Release 🚀
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false

- name: Upload app 📤
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: app/build/outputs/apk/demo/release/app-demo-release.apk
asset_name: app-demo-release.apk
asset_content_type: application/vnd.android.package-archive
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
java adoptopenjdk-17.0.8+7
java zulu-17.44.17
direnv 2.32.3
maestro 1.31.0
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ class ExampleInstrumentedTest {
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
Assert.assertEquals("com.crisiscleanup.demo.debug", appContext.packageName)
}
}
}
Loading