Skip to content

Commit

Permalink
Modernize repo (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Jul 23, 2023
1 parent 08a8fc3 commit 0318d87
Show file tree
Hide file tree
Showing 202 changed files with 2,424 additions and 2,492 deletions.
112 changes: 66 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,85 @@
name: CI

on: [push, pull_request]
on:
# Only run push on main
push:
branches:
- main
paths-ignore:
- '**/*.md'
# Always run on PRs
pull_request:
branches: [ main ]
merge_group:

concurrency:
group: 'ci-${{ github.event.merge_group.head_ref || github.head_ref }}-${{ github.workflow }}'
cancel-in-progress: true

jobs:
build:
name: JDK ${{ matrix.java_version }}
runs-on: macOS-latest
strategy:
fail-fast: false
matrix:
java_version: [11]
env:
api-level: "18"
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1
- name: Install JDK ${{ matrix.java_version }}

- name: Install JDK
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: ${{ matrix.java_version }}
- name: Install Android SDK
uses: malinskiy/action-android/install-sdk@release/0.1.2
- run: sdkmanager platform-tools
# TODO Caching disabled for now due to the size of Gradle's cache rendering this super slow
# - name: Cache build .gradle dir
# uses: actions/cache@v1.0.1
# with:
# path: .gradle
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
# restore-keys: |
# ${{ runner.os }}-gradle-
# - name: Cache user .gradle dir
# uses: actions/cache@v1.0.1
# with:
# path: ~/.gradle
# key: ${{ runner.os }}-gradleuser-${{ hashFiles('**/*.gradle') }}
# restore-keys: |
# ${{ runner.os }}-gradleuser-
- name: Configure Gradle
# Initial gradle configuration, install dependencies, etc
run: ./gradlew help
- name: Spot check
# Run spotless first to fail fast on spotless issues
run: ./gradlew spotlessCheck --stacktrace
- name: Build project
run: ./gradlew assemble --stacktrace
java-version: '17'

- name: Gradle cache
uses: gradle/gradle-build-action@v2

# TODO split test and instrumentation into parallel builds
- name: Run tests
run: ./gradlew test --stacktrace
- name: Build and run unit tests
id: gradle
uses: gradle/gradle-build-action@v2
with:
arguments: check

- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.api-level }}

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.api-level }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: Run instrumentation tests
uses: malinskiy/action-android/emulator-run-cmd@release/0.1.2
uses: reactivecircus/android-emulator-runner@v2
with:
cmd: ./gradlew connectedCheck --stacktrace
api: 18
tag: default
abi: x86
- name: Reclaim memory
run: ./gradlew --stop && jps|grep -E 'KotlinCompileDaemon|GradleDaemon'| awk '{print $1}'| xargs kill -9
- name: Final checks
run: ./gradlew check --stacktrace
api-level: ${{ env.api-level }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew connectedCheck

- name: (Fail-only) Upload build reports
if: failure()
uses: actions/upload-artifact@v3
with:
name: reports
path: |
**/build/reports/**
- name: Upload snapshot (main only)
if: success() && github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
run: ./gradlew publish -PmavenCentralUsername="${{ secrets.SonatypeUsername }}" -PmavenCentralPassword="${{ secrets.SonatypePassword }}"
if: success() && github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && matrix.java_version == '11'
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ lint_result.txt
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
# virtual machine crash logs, see https://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*


Expand Down Expand Up @@ -107,7 +107,7 @@ annotations/

# Mkdocs
docs/1.x/*
docs/2.x/*
docs/api/2.x/*
docs/changelog.md
docs/contributing.md
docs/code-of-conduct.md

0 comments on commit 0318d87

Please sign in to comment.