OXYGENHUB
◆ v0.4.5 oxygen / .flow / pipeline.kdl
5.3 KiB · last changed ci: keep each build job's target from its last passing run (refs andymccall/oxygenflow#28) 22 days ago source blame history raw
1
// Oxygen's own 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.
4
schema-version 1
5
6
// The OxygenFlow build image: Rust with rustfmt and clippy, Node, and every
7
// crate of Cargo.lock vendored (oxygenflow/images/rust). Rebuild and re-pin
8
// it when Cargo.lock changes.
9
sandbox "rust" {
10
    runtime "microvm"
11
    rootfs "cas://blob/3fa57d4c1dc8aa5d4d92665bc13f332357f55042f658543dc21b1540b3aced69"
12
    memory-limit "8GiB"
13
    cpu-limit 4
14
    // Tests serve and connect on 127.0.0.1; nothing leaves the guest.
15
    network "loopback"
16
    // CI builds are thrown away: no incremental state and no debug info,
17
    // so less to compile, link and write (as in oxygenhub's pipeline).
18
    env {
19
        CARGO_INCREMENTAL "0"
20
        CARGO_PROFILE_DEV_DEBUG "0"
21
        CARGO_PROFILE_TEST_DEBUG "0"
22
        CARGO_PROFILE_RELEASE_DEBUG "0"
23
    }
24
}
25
26
sandbox "rust-small" {
27
    runtime "microvm"
28
    rootfs "cas://blob/3fa57d4c1dc8aa5d4d92665bc13f332357f55042f658543dc21b1540b3aced69"
29
    memory-limit "1GiB"
30
    cpu-limit 1
31
    network "isolated"
32
}
33
34
job "fmt" {
35
    sandbox "rust-small"
36
    exec "cargo" "fmt" "--all" "--check"
37
}
38
39
job "clippy" {
40
    sandbox "rust"
41
    depends-on "fmt"
42
    mount {
43
        source "ephemeral://disk"
44
        target "/src/target"
45
        size "24GiB"
46
        // Kept from this job's last passing run (oxygenflow#28): cargo
47
        // builds only what changed since.
48
        cache "target"
49
        key "Cargo.lock"
50
    }
51
    // One build identity for every CI state, so the cached target stays
52
    // fresh from one push to the next (oxygenflow#52).
53
    env {
54
        OXY_BUILD "ci"
55
    }
56
    exec "sh" ".flow/warm-target.sh" "cargo" "clippy" "--workspace" "--all-targets" "--locked" "--" "-D" "warnings"
57
}
58
59
// The tests, run under cargo-llvm-cov so the hub's Coverage tab
60
// (oxygenhub#113) gets a report: the same tests, instrumented, and an LCOV
61
// file kept as the job's `coverage` artifact.
62
job "test" {
63
    sandbox "rust"
64
    depends-on "fmt"
65
    mount {
66
        source "ephemeral://disk"
67
        target "/src/target"
68
        size "24GiB"
69
        // Kept from this job's last passing run (oxygenflow#28): cargo
70
        // builds only what changed since.
71
        cache "target"
72
        key "Cargo.lock"
73
    }
74
    // One build identity for every CI state, so the cached target stays
75
    // fresh from one push to the next (oxygenflow#52).
76
    env {
77
        OXY_BUILD "ci"
78
    }
79
    exec "cargo" "llvm-cov" "--workspace" "--locked" "--lcov" "--output-path" "/src/target/lcov.info"
80
    output {
81
        artifact "coverage" {
82
            path "/src/target/lcov.info"
83
        }
84
    }
85
}
86
87
job "build" {
88
    sandbox "rust"
89
    depends-on "fmt"
90
    mount {
91
        source "ephemeral://disk"
92
        target "/src/target"
93
        size "24GiB"
94
        // Kept from this job's last passing run (oxygenflow#28): cargo
95
        // builds only what changed since.
96
        cache "target"
97
        key "Cargo.lock"
98
    }
99
    exec "sh" ".flow/warm-target.sh" "cargo" "build" "--release" "--locked"
100
    // The binary, kept as a blob of this repository and named by the
101
    // job's signed receipt; the run page links it.
102
    output {
103
        artifact "oxy" {
104
            path "/src/target/release/oxy"
105
        }
106
    }
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 "oxy-linux-x86_64.tar.gz" {
135
            path "/src/target/dist-flat/oxy-linux-x86_64.tar.gz"
136
        }
137
        artifact "oxy-linux-arm64.tar.gz" {
138
            path "/src/target/dist-flat/oxy-linux-arm64.tar.gz"
139
        }
140
        artifact "oxy-linux-riscv64.tar.gz" {
141
            path "/src/target/dist-flat/oxy-linux-riscv64.tar.gz"
142
        }
143
        artifact "oxy-macos-x86_64.tar.gz" {
144
            path "/src/target/dist-flat/oxy-macos-x86_64.tar.gz"
145
        }
146
        artifact "oxy-macos-arm64.tar.gz" {
147
            path "/src/target/dist-flat/oxy-macos-arm64.tar.gz"
148
        }
149
        artifact "oxy-windows-x86_64.zip" {
150
            path "/src/target/dist-flat/oxy-windows-x86_64.zip"
151
        }
152
        artifact "oxy_amd64.deb" {
153
            path "/src/target/dist-flat/oxy_amd64.deb"
154
        }
155
        artifact "oxy_arm64.deb" {
156
            path "/src/target/dist-flat/oxy_arm64.deb"
157
        }
158
        artifact "oxy_riscv64.deb" {
159
            path "/src/target/dist-flat/oxy_riscv64.deb"
160
        }
161
        artifact "SHA256SUMS" {
162
            path "/src/target/dist-flat/SHA256SUMS"
163
        }
164
    }
165
}