Skip to content

Commit

Permalink
feat(ci): Initialize CI/CD workflow for Android build and tests.
Browse files Browse the repository at this point in the history
feat(ci): Add ISSUE_TEMPLATE for github issue.
  • Loading branch information
azrael8576 committed Nov 30, 2023
1 parent df06c21 commit 21f953b
Show file tree
Hide file tree
Showing 12 changed files with 427 additions and 12 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Bug Report
description: File a bug report
title: "[Bug]: "
labels: ["bug", "triage me"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search to see if an issue already exists for the bug you encountered.
options:
- label: I have searched the existing issues
required: true
- type: checkboxes
attributes:
label: Is there a StackOverflow question about this issue?
description: Please search [StackOverflow](https://stackoverflow.com/questions/tagged/android-jetpack) if an issue with an answer already exists for the bug you encountered.
options:
- label: I have searched StackOverflow
required: true
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?
placeholder: Tell us what you see!
value: "A bug happened!"
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant logcat output
description: Please copy and paste any relevant logcat output. This will be automatically formatted into code, so no need for backticks.
render: shell
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/docs_issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Documentation issue
description: File an issue or make a suggestion for the project documentation
title: "[Documentation]: "
labels: ["documentation"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to improve our documentation!
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search to see if an issue already exists for the documentation issue you encountered.
options:
- label: I have searched the existing issues
required: true
- type: input
id: page-url
attributes:
label: Page URL (type "NEW" for a new page suggestion)
validations:
required: true
- type: textarea
id: what-needs-improving
attributes:
label: What's the documentation problem or suggestion?
placeholder: Tell us what should be improved!
value: "Docs need improving!"
validations:
required: true
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Feature request
description: File a feature request
title: "[FR]: "
labels: ["enhancement", "triage me"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to propose a new feature!
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search to see if an issue already exists for this feature request.
options:
- label: I have searched the existing issues
required: true
- type: textarea
id: describe-problem
attributes:
label: Describe the problem
description: Is your feature request related to a problem? Please describe.
placeholder: I'm always frustrated when...
validations:
required: true
- type: textarea
id: solution
attributes:
label: Describe the solution
description: Please describe the solution you'd like. A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
id: context
attributes:
label: Additional context
description: Add any other context or screenshots about the feature request here.
validations:
required: false

46 changes: 46 additions & 0 deletions .github/ISSUE_TEMPLATE/setup_improvement.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Project Setup Improvement
description: Submit an improvement or suggestion related to project setup
title: "[Setup Improvement]: "
labels: ["setup improvement", "triage me"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to propose an improvement to our project setup!
- type: checkboxes
attributes:
label: Preliminary Checks
description: Please make sure you've conducted the following checks before submitting an improvement.
options:
- label: I have searched the existing issues to ensure this is not a duplicate request.
required: true
- label: This setup improvement does not introduce breaking changes to the existing project structure.
required: true
- label: I have consulted the project's documentation and guidelines before suggesting this improvement.
required: false

- type: textarea
id: describe-problem
attributes:
label: Describe the Problem or Limitation
description: Is your improvement related to a problem or limitation in the current setup? Please describe.
placeholder: Every time I try to..., I am hindered by...
validations:
required: true

- type: textarea
id: solution
attributes:
label: Proposed Solution
description: Please describe the solution or change you'd like to see implemented. Be as detailed as possible.
validations:
required: true

- type: textarea
id: context
attributes:
label: Additional Context or References
description: Provide any further context, references, or screenshots that might help in understanding the proposed improvement.
validations:
required: false
21 changes: 21 additions & 0 deletions .github/ci-gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Disables the use of the Gradle daemon, which is a background process for speeding up Gradle commands.
# With this set to false, a new Gradle process will be started for each build.
org.gradle.daemon=false

# Enables the parallel execution of tasks that do not depend on each other. This can speed up the overall build process.
org.gradle.parallel=true

# Sets the maximum number of worker processes that Gradle can use for executing tasks (e.g., compilation).
# Here, it is limited to 2 worker processes.
org.gradle.workers.max=2

# Disables the incremental compilation feature of Kotlin. With incremental compilation, only the changed source files get recompiled.
kotlin.incremental=false

# Determines how the Kotlin compiler runs. 'in-process' means the compiler runs inside the Gradle process, not as a separate process.
kotlin.compiler.execution.strategy=in-process

# Controls whether warnings in Kotlin code should be treated as errors during the compilation process.
# This setting is useful for CI environments where you might not want a build to fail just because of warnings.
# Set to true if you want to treat warnings as errors in your local setup.
warningsAsErrors=false
18 changes: 18 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Pull request
about: Create a pull request
label: 'triage me'
---
Thank you for opening a Pull Request!
Before submitting your PR, please make sure you:

- [ ] Include a PR description which states **what you've done and why**
- [ ] Open a GitHub issue as a bug/feature request before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
- [ ] Ensure the tests and linter pass (`./gradlew --init-script gradle/init.gradle.kts spotlessApply` to automatically apply formatting)
- [ ] Update any relevant documentation

Are you a first-time contributor?
- [ ] Ensure you've read and understood the contributing guidelines
- [ ] Familiarize yourself with the project structure and the codebase

Fixes #<issue_number_goes_here> 🦕
172 changes: 172 additions & 0 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: Android CI

on:
push:
branches:
- main
pull_request:

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

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 90

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

# If the test fails, execute the following command to apply fixes.
# ./gradlew spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache
- name: Check spotless
run: ./gradlew spotlessCheck --init-script gradle/init.gradle.kts --no-configuration-cache

- name: Build all build type and flavor permutations
run: ./gradlew assemble

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

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

test:
runs-on: ubuntu-latest

permissions:
contents: write

timeout-minutes: 60

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 all local screenshot tests (Roborazzi)
id: screenshotsverify
continue-on-error: true
run: ./gradlew verifyRoborazziDemoDebug

- name: Prevent pushing new screenshots if this is a fork
id: checkfork
continue-on-error: false
if: steps.screenshotsverify.outcome == 'failure' && github.event.pull_request.head.repo.full_name != github.repository
run: |
echo "::error::Screenshot tests failed, please create a PR in your fork first." && exit 1
# Runs if previous job failed
- name: Generate new screenshots if verification failed and it's a PR
id: screenshotsrecord
if: steps.screenshotsverify.outcome == 'failure' && github.event_name == 'pull_request'
run: |
./gradlew recordRoborazziDemoDebug
- name: Push new screenshots if available
uses: stefanzweifel/git-auto-commit-action@v4
if: steps.screenshotsrecord.outcome == 'success'
with:
file_pattern: '*/*.png'
disable_globbing: true
commit_message: "🤖 Updates screenshots"

# Run local tests after screenshot tests to avoid wrong UP-TO-DATE. TODO: Ignore screenshots.
- name: Run local tests
if: always()
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'

- name: Check lint
run: ./gradlew :app:lintProdRelease

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

androidTest:
needs: build
runs-on: macOS-latest # enables hardware acceleration in the virtual machine
timeout-minutes: 55
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'
Loading

0 comments on commit 21f953b

Please sign in to comment.