Blob .ayllu-build.jsonnet
-rw-r--r-- 3.7 KiB
1local target = 'x86_64-alpine-linux-musl';
2local build_image = 'ayllu-arch';
3local version = '0.5.1';
4local arch_package = 'ayllu-dev-' + version + '-1-x86_64.pkg.tar.zst';
5local cargo_target_dir = '/home/ayllu/cargo-target';
6local debian_package = 'ayllu-' + version + '.deb';
7
8local cargo_cache = {
9 name: 'cargo-cache',
10 path: '/home/ayllu/.cargo/registry',
11};
12
13local build_cache = {
14 name: 'build-cache',
15 path: cargo_target_dir,
16 transient: true,
17};
18
19local binaries = [
20 'ayllu-build',
21 'ayllu-dispatch',
22 'ayllu-keys',
23 'ayllu-migrate',
24 'ayllu-shell',
25 'ayllu-web',
26 'quipu',
27];
28
29local compile_binary(name) = {
30 name: 'Cargo Build ' + name,
31 input: 'cargo build --frozen --release --bin=' + name,
32 environment: {
33 AYLLU_VERSION: version,
34 CARGO_TARGET_DIR: cargo_target_dir,
35 },
36};
37
38local short_step(name, input) = {
39 name: name,
40 input: input,
41 environment: {
42 AYLLU_VERSION: version,
43 CARGO_TARGET_DIR: cargo_target_dir,
44 },
45};
46
47{
48 workflows: [
49 {
50 name: 'Lint',
51 image: build_image,
52 steps: [
53 short_step('Cargo Lint', 'cargo fmt --check'),
54 ],
55 cache: [cargo_cache, build_cache],
56 },
57 {
58 name: 'Metadata',
59 image: build_image,
60 networking: true,
61 steps: [
62 short_step('Fetch', 'cargo fetch --locked'),
63 short_step('Metadata', 'cargo metadata > metadata.json'),
64 ],
65 cache: [cargo_cache, build_cache],
66 outputs: [{
67 path: 'metadata.json',
68 sha256sum: null,
69 }],
70 depends_on: ['Lint'],
71 },
72 {
73 name: 'Test',
74 image: build_image,
75 steps: [
76 short_step('Cargo Test', 'cargo test --frozen --release'),
77 ],
78 cache: [cargo_cache, build_cache],
79 depends_on: ['Lint'],
80 },
81 {
82 name: 'Compile Binaries',
83 image: build_image,
84 steps: std.flattenArrays(
85 [
86 [
87 // NOTE: Somewhat oddly man pages are embedded in the ayllu-web binary
88 // and so this task must always be ran before compiling ayllu-web.
89 short_step('Man Pages', 'cargo run --frozen --package xtask -- --gen-man'),
90 ],
91 [
92 compile_binary(binary)
93 for binary in binaries
94 ],
95 ]
96 ),
97 cache: [cargo_cache, build_cache],
98 depends_on: ['Test'],
99 },
100 {
101 name: 'Arch Distribution',
102 image: build_image,
103 steps: [
104 short_step('Man Pages', 'cargo run --frozen --package xtask -- --gen-man'),
105 short_step('Shell Completion', 'cargo run --frozen --package xtask -- --gen-complete'),
106 short_step('Makepkg', 'makepkg'),
107 ],
108 cache: [cargo_cache, build_cache],
109 depends_on: ['Compile Binaries'],
110 outputs: [
111 {
112 path: arch_package,
113 sha256sum: null,
114 },
115 ],
116 },
117 {
118 name: 'Debian Distribution',
119 image: 'ayllu-debian',
120 steps: std.flattenArrays(
121 [
122 [
123
124 short_step('Fetch', 'cargo fetch --locked'),
125 short_step('Cargo Test', 'cargo test --frozen --release'),
126 short_step('Man Pages', 'cargo run --frozen --package xtask -- --gen-man'),
127 short_step('Shell Completion', 'cargo run --frozen --package xtask -- --gen-complete'),
128 ],
129 [compile_binary(binary) for binary in binaries],
130 [short_step('Dpkg', 'scripts/build_deb.sh')]
131 ]
132 ),
133 // NOTE: Build cache is excluded here
134 cache: [cargo_cache, {
135 name: "build-cache-debian",
136 path: cargo_target_dir,
137 transient: true
138 }],
139 depends_on: ['Arch Distribution'],
140 // depends_on: ['Arch Distribution'],
141 outputs: [
142 {
143 path: debian_package,
144 sha256sum: null,
145 },
146 ],
147 },
148 ],
149}