OXYGENHUB
◆ oh-comment-body-file oxygenhub / .flow / pipeline.kdl
5.6 KiB · last changed dist: release the hub server for Linux x86_64 on PostgreSQL 20 days ago source blame history raw
1
// OxygenHub's pipeline (OxygenFlow, docs in the oxygenflow repository).
2
// Every push to a bookmark on OxygenHub runs it in Firecracker microVMs on
3
// Earth; the jobs appear as checks on the change. oxygen and oxygenflow come
4
// from the pinned subrepos in deps/, which the runner puts in the workspace.
5
schema-version 1
6
7
// The OxygenFlow build image: Rust with rustfmt and clippy, Node, every
8
// crate of Cargo.lock vendored, and this workspace's dependencies prebuilt
9
// in /opt/warm/oxygenhub, which .flow/warm-target.sh copies onto a job's
10
// target disk (oxygenflow/images/rust). Rebuild and re-pin it when
11
// Cargo.lock changes; until then only the changed crates are compiled.
12
sandbox "rust" {
13
    runtime "microvm"
14
    rootfs "cas://blob/57aa0b34c0cadd541cfe90ac2711200be46879ac9968778e3a3417eca04357e3"
15
    memory-limit "8GiB"
16
    cpu-limit 4
17
    // Tests serve and connect on 127.0.0.1; nothing leaves the guest.
18
    network "loopback"
19
    // CI builds are thrown away: no incremental state, and no debug info
20
    // (the release profile keeps line tables for the binary Earth runs,
21
    // which is built outside CI), so less to compile, link and write.
22
    env {
23
        CARGO_INCREMENTAL "0"
24
        CARGO_PROFILE_DEV_DEBUG "0"
25
        CARGO_PROFILE_TEST_DEBUG "0"
26
        CARGO_PROFILE_RELEASE_DEBUG "0"
27
        // One build identity for every CI state, so a cached target stays
28
        // fresh from one push to the next (oxygenflow#52); dist sets the
29
        // release's own.
30
        OXY_BUILD "ci"
31
    }
32
}
33
34
sandbox "rust-small" {
35
    runtime "microvm"
36
    rootfs "cas://blob/57aa0b34c0cadd541cfe90ac2711200be46879ac9968778e3a3417eca04357e3"
37
    memory-limit "1GiB"
38
    cpu-limit 1
39
    network "isolated"
40
}
41
42
job "fmt" {
43
    sandbox "rust-small"
44
    // Only this workspace's packages: --all would also check the path
45
    // dependencies in deps/, which follow their own formatting.
46
    exec "cargo" "fmt" "--check" "-p" "oxygenhub" "-p" "hub-api" "-p" "oh"
47
}
48
49
job "clippy" {
50
    sandbox "rust"
51
    depends-on "fmt"
52
    mount {
53
        source "ephemeral://disk"
54
        target "/src/target"
55
        size "24GiB"
56
        // Kept from this job's last passing run (oxygenflow#28): cargo
57
        // builds only what changed since.
58
        cache "target"
59
        key "Cargo.lock"
60
    }
61
    exec "sh" ".flow/warm-target.sh" "cargo" "clippy" "--workspace" "--all-targets" "--locked" "--" "-D" "warnings"
62
}
63
64
job "test" {
65
    sandbox "rust"
66
    depends-on "fmt"
67
    mount {
68
        source "ephemeral://disk"
69
        target "/src/target"
70
        size "24GiB"
71
        // Kept from this job's last passing run (oxygenflow#28): cargo
72
        // builds only what changed since.
73
        cache "target"
74
        key "Cargo.lock"
75
    }
76
    exec "sh" ".flow/warm-target.sh" "cargo" "test" "--workspace" "--locked"
77
}
78
79
// The hub's tests again on PostgreSQL (#211, docs/postgres.md), against a
80
// server the job starts in its own guest.
81
job "test-postgres" {
82
    sandbox "rust"
83
    depends-on "fmt"
84
    mount {
85
        source "ephemeral://disk"
86
        target "/src/target"
87
        size "24GiB"
88
        cache "target"
89
        key "Cargo.lock"
90
    }
91
    exec "sh" ".flow/test-postgres.sh"
92
}
93
94
job "build" {
95
    sandbox "rust"
96
    depends-on "fmt"
97
    mount {
98
        source "ephemeral://disk"
99
        target "/src/target"
100
        size "24GiB"
101
        // Kept from this job's last passing run (oxygenflow#28): cargo
102
        // builds only what changed since.
103
        cache "target"
104
        key "Cargo.lock"
105
    }
106
    exec "sh" ".flow/warm-target.sh" "cargo" "build" "--release" "--locked"
107
}
108
109
// Release files for every platform (oxygen#59): scripts/dist.sh in the
110
// build image's cross toolchains. A push runs it only when it touches
111
// these paths (a release moves Cargo.toml's version); "Run pipeline" and
112
// reruns always do. The files are kept as this run's artifacts, named by
113
// its signed receipt, and attached to the release from there, so the
114
// release's trust page shows each as built here.
115
job "dist" {
116
    sandbox "rust"
117
    depends-on "fmt"
118
    scope "Cargo.toml" "scripts/dist.sh" "packaging/**"
119
    mount {
120
        source "ephemeral://disk"
121
        target "/src/target"
122
        size "24GiB"
123
        // Kept from this job's last passing run (oxygenflow#28): cargo
124
        // builds only what changed since.
125
        cache "target"
126
        key "Cargo.lock"
127
    }
128
    env {
129
        DIST_FLAT "/src/target/dist-flat"
130
        ZIG_GLOBAL_CACHE_DIR "/src/target/zig-cache"
131
    }
132
    exec "bash" "scripts/dist.sh"
133
    output {
134
        artifact "oh-linux-x86_64.tar.gz" {
135
            path "/src/target/dist-flat/oh-linux-x86_64.tar.gz"
136
        }
137
        artifact "oh-linux-arm64.tar.gz" {
138
            path "/src/target/dist-flat/oh-linux-arm64.tar.gz"
139
        }
140
        artifact "oh-linux-riscv64.tar.gz" {
141
            path "/src/target/dist-flat/oh-linux-riscv64.tar.gz"
142
        }
143
        artifact "oh-macos-x86_64.tar.gz" {
144
            path "/src/target/dist-flat/oh-macos-x86_64.tar.gz"
145
        }
146
        artifact "oh-macos-arm64.tar.gz" {
147
            path "/src/target/dist-flat/oh-macos-arm64.tar.gz"
148
        }
149
        artifact "oh-windows-x86_64.zip" {
150
            path "/src/target/dist-flat/oh-windows-x86_64.zip"
151
        }
152
        artifact "oh_amd64.deb" {
153
            path "/src/target/dist-flat/oh_amd64.deb"
154
        }
155
        artifact "oh_arm64.deb" {
156
            path "/src/target/dist-flat/oh_arm64.deb"
157
        }
158
        artifact "oh_riscv64.deb" {
159
            path "/src/target/dist-flat/oh_riscv64.deb"
160
        }
161
        artifact "oxygenhub-server-linux-x86_64.tar.gz" {
162
            path "/src/target/dist-flat/oxygenhub-server-linux-x86_64.tar.gz"
163
        }
164
        artifact "SHA256SUMS" {
165
            path "/src/target/dist-flat/SHA256SUMS"
166
        }
167
    }
168
}