Skip to content

Commit

Permalink
Self-hosted runner templates
Browse files Browse the repository at this point in the history
  • Loading branch information
growse committed May 23, 2023
1 parent a0bf340 commit d9e58b2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 31 deletions.
40 changes: 18 additions & 22 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ name: Build and Test
jobs:
build-test-lint:
name: Build, test & lint
runs-on: macos-latest
runs-on: self-hosted
permissions:
contents: read
checks: write
Expand All @@ -36,12 +36,9 @@ jobs:
echo -n $KEYSTORE_BASE64 | base64 -d > project/owntracks.release.keystore.jks
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
- name: Gradle cache
uses: gradle/gradle-build-action@v2
- name: Gradle build
run: |
./project/gradlew -p project \
--scan \
assembleDebug \
assembleRelease \
assembleAndroidTest \
Expand All @@ -53,7 +50,7 @@ jobs:
:app:packageGmsDebugAndroidTest \
:app:packageOssDebugAndroidTest \
lint \
app:createGmsDebugUnitTestCoverageReport
app:createGmsDebugUnitTestCoverageReport --scan --stacktrace
env:
KEYSTORE_PASSPHRASE: ${{ secrets.KEYSTORE_PASSPHRASE }}
Expand Down Expand Up @@ -104,33 +101,31 @@ jobs:
espresso-test:
name: "Espresso test"
runs-on: macos-latest
runs-on: self-hosted
permissions:
contents: read
checks: write
needs: build-test-lint
strategy:
matrix:
android-api: [29]
android-api: [31]
steps:
- run: echo "/android-sdk/platform-tools/" >> $GITHUB_PATH
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 17

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

- name: AVD cache
uses: actions/cache@v3
id: avd-cache
- name: "Check snapshot exists"
id: check_snapshot_exists
uses: andstor/file-existence-action@v2
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.android-api }}
files: "/android-sdk/user_home/avd/test-${{ matrix.android-api }}.avd/snapshots/default_boot/screenshot.png"

- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
- name: Create AVD and generate snapshot for caching
if: steps.check_snapshot_exists.outputs.files_exists == 'false'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.android-api }}
Expand All @@ -139,11 +134,12 @@ jobs:
profile: pixel_3a
target: google_apis
ram-size: 6000M
avd-name: test-${{ matrix.android-api }}
disable-animations: true
arch: x86_64
sdcard-path-or-size: 1000M
emulator-build: 9936625
script: echo "Generated AVD snapshot for caching."
script: |
echo "Created AVD snapshot"
- name: Espresso Test
uses: reactivecircus/android-emulator-runner@v2
Expand All @@ -159,7 +155,7 @@ jobs:
ram-size: 6000M
disable-animations: true
arch: x86_64
cores: 3
cores: 2
sdcard-path-or-size: 1000M
emulator-build: 9936625
script: |
Expand Down
10 changes: 3 additions & 7 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
---
codecov:
notify:
after_n_builds: 3 # Unit and 2 Espresso
coverage:
status:
project:
status:
threshold: 1%
after_n_builds: 2
wait_for_ci: yes
max_report_age: off
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class RoomMqttClientPersistenceTest {
@Test
fun mqttClientPersistenceRemoveTest() {
val context = ApplicationProvider.getApplicationContext<Context>()
RoomMqttClientPersistence(context).run {
RoomMqttClientPersistence(context, true).run {
val key1 = "testKey1"
val header1 = "header1".toByteArray()
val payload1 = "payload1".toByteArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import org.eclipse.paho.client.mqttv3.internal.MqttPersistentData
/**
* Implementation of [MqttClientPersistence] that stores data in a Room database
*/
class RoomMqttClientPersistence(applicationContext: Context) : MqttClientPersistence {
class RoomMqttClientPersistence(applicationContext: Context, mainThreadQueries: Boolean = false) :
MqttClientPersistence {

private val db = Room.databaseBuilder(
applicationContext,
MqttPersistableDatabase::class.java,
"pahoMqttPersistence"
)
.apply { if (mainThreadQueries) this.allowMainThreadQueries() }
.build()

@Entity
Expand Down

0 comments on commit d9e58b2

Please sign in to comment.