OXYGENHUB
# bd1d3ad70c70 oxygenhub-android / .flow / pipeline.kdl
4.1 KiB · last changed CI builds on disks of its own for the app's build output and Gradle's cache (refs #28) 9 days ago source blame history raw
1
// The OxygenHub Android app's pipeline (OxygenFlow, #19). Every push runs
2
// the unit tests with coverage and a debug build in OxygenFlow's Android
3
// image, with no network: the JDK, the Android SDK and NDK, Gradle,
4
// cargo-ndk, rust-core's crates and the app's Gradle dependencies are all
5
// in the image (oxygenflow/images/android). Rebuild and re-pin it when the
6
// app's SDK, Gradle or dependency versions change, or rust-core's
7
// Cargo.lock does. Locally, ./gradlew :app:createDebugUnitTestCoverageReport
8
// runs the same tests.
9
schema-version 1
10
11
sandbox "android" {
12
    runtime "microvm"
13
    rootfs "cas://blob/cceb10ea42f539bed31c4bbe16e4f49961533f80a2397ca4981afb483a066d0a"
14
    memory-limit "8GiB"
15
    cpu-limit 4
16
    network "isolated"
17
    // Gradle reads dependencies from the image's read-only cache and
18
    // writes its own state under /tmp.
19
    env {
20
        ANDROID_HOME "/opt/android-sdk"
21
        JAVA_HOME "/usr/lib/jvm/java-17-openjdk-amd64"
22
        GRADLE_RO_DEP_CACHE "/opt/gradle-home/caches"
23
        GRADLE_USER_HOME "/tmp/gradle"
24
        CARGO_INCREMENTAL "0"
25
    }
26
}
27
28
job "test" {
29
    sandbox "android"
30
    timeout "60m"
31
    // rust-core (with oxy-core and the runner) for two ABIs is most of the
32
    // build: kept from the last passing run, so only what changed builds.
33
    mount {
34
        source "ephemeral://disk"
35
        target "/src/rust-core/target"
36
        size "20GiB"
37
        cache "rust-core-target"
38
        key "rust-core/Cargo.lock"
39
    }
40
    // The workspace has room for the checkout and a little more: the app's
41
    // build output and Gradle's project cache get disks of their own.
42
    mount {
43
        source "ephemeral://disk"
44
        target "/src/app/build"
45
        size "8GiB"
46
    }
47
    mount {
48
        source "ephemeral://disk"
49
        target "/src/.gradle"
50
        size "2GiB"
51
    }
52
    exec "bash" "scripts/ci.sh"
53
    output {
54
        artifact "junit" {
55
            path "/src/junit.xml"
56
            when "always"
57
        }
58
        artifact "coverage" {
59
            path "/src/coverage.xml"
60
            when "always"
61
        }
62
    }
63
}
64
65
// The release's secrets checked in seconds, with no build (#7): the
66
// keystore's SHA-256, the key its password opens and Firebase's JSON.
67
// By hand only: oh run start --job release-check.
68
job "release-check" {
69
    sandbox "android"
70
    timeout "5m"
71
    on {
72
        manual
73
    }
74
    secret "android-keystore" {
75
        mount-path "/run/secrets/android-keystore"
76
    }
77
    secret "android-keystore-password" {
78
        mount-path "/run/secrets/android-keystore-password"
79
    }
80
    secret "firebase-config" {
81
        mount-path "/run/secrets/firebase-config"
82
    }
83
    exec "bash" "scripts/release-check.sh"
84
}
85
86
// A signed release APK when the version in gradle.properties changes (#7),
87
// for a release on oxygenhub.io. The keystore and its password are the
88
// repository's secrets, mounted as files (never in the environment).
89
job "release" {
90
    sandbox "android"
91
    timeout "60m"
92
    depends-on "test"
93
    scope "gradle.properties"
94
    mount {
95
        source "ephemeral://disk"
96
        target "/src/rust-core/target"
97
        size "20GiB"
98
        cache "rust-core-target"
99
        key "rust-core/Cargo.lock"
100
    }
101
    // The workspace has room for the checkout and a little more: the app's
102
    // build output and Gradle's project cache get disks of their own.
103
    mount {
104
        source "ephemeral://disk"
105
        target "/src/app/build"
106
        size "8GiB"
107
    }
108
    mount {
109
        source "ephemeral://disk"
110
        target "/src/.gradle"
111
        size "2GiB"
112
    }
113
    secret "android-keystore" {
114
        mount-path "/run/secrets/android-keystore"
115
    }
116
    secret "android-keystore-password" {
117
        mount-path "/run/secrets/android-keystore-password"
118
    }
119
    // Firebase's client settings (google-services.json) for alerts (#16).
120
    secret "firebase-config" {
121
        mount-path "/run/secrets/firebase-config"
122
    }
123
    exec "bash" "scripts/release.sh"
124
    output {
125
        artifact "oxygenhub-android-universal.apk" {
126
            path "/src/dist/oxygenhub-android-universal.apk"
127
        }
128
        artifact "SHA256SUMS" {
129
            path "/src/dist/SHA256SUMS"
130
        }
131
    }
132
}