+1
-1
.fluentci/mod.ts
+1
-1
.fluentci/mod.ts
-39
.fluentci/src/aws/README.md
-39
.fluentci/src/aws/README.md
···
1
-
# AWS CodePipeline
2
-
3
-
[](https://pkg.fluentci.io/rust_pipeline)
4
-
[](https://deno.land/x/rust_pipeline)
5
-

6
-
[](https://codecov.io/gh/fluent-ci-templates/rust-pipeline)
7
-
8
-
The following command will generate a `buildspec.yml` file in your project:
9
-
10
-
```bash
11
-
fluentci ac init -t rust_pipeline
12
-
```
13
-
14
-
Generated file:
15
-
16
-
```yaml
17
-
# Do not edit this file directly. It is generated by https://deno.land/x/fluent_aws_codepipeline
18
-
19
-
version: 0.2
20
-
phases:
21
-
install:
22
-
commands:
23
-
- curl -fsSL https://deno.land/x/install/install.sh | sh
24
-
- export DENO_INSTALL="$HOME/.deno"
25
-
- export PATH="$DENO_INSTALL/bin:$PATH"
26
-
- deno install -A -r https://cli.fluentci.io -n fluentci
27
-
- curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
28
-
- mv bin/dagger /usr/local/bin
29
-
- dagger version
30
-
build:
31
-
commands:
32
-
- fluentci run rust_pipeline test build
33
-
post_build:
34
-
commands:
35
-
- echo Build completed on `date`
36
-
37
-
```
38
-
39
-
Feel free to edit the template generator at `.fluentci/src/aws/config.ts` to your needs.
-24
.fluentci/src/aws/config.ts
-24
.fluentci/src/aws/config.ts
···
1
-
import { BuildSpec } from "fluent_aws_codepipeline";
2
-
3
-
export function generateYaml(): BuildSpec {
4
-
const buildspec = new BuildSpec();
5
-
buildspec
6
-
.phase("install", {
7
-
commands: [
8
-
"curl -fsSL https://deno.land/x/install/install.sh | sh",
9
-
'export DENO_INSTALL="$HOME/.deno"',
10
-
'export PATH="$DENO_INSTALL/bin:$PATH"',
11
-
"deno install -A -r https://cli.fluentci.io -n fluentci",
12
-
"curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh",
13
-
"mv bin/dagger /usr/local/bin",
14
-
"dagger version",
15
-
],
16
-
})
17
-
.phase("build", {
18
-
commands: ["fluentci run rust_pipeline test build"],
19
-
})
20
-
.phase("post_build", {
21
-
commands: ["echo Build completed on `date`"],
22
-
});
23
-
return buildspec;
24
-
}
-9
.fluentci/src/aws/config_test.ts
-9
.fluentci/src/aws/config_test.ts
···
1
-
import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts";
2
-
import { generateYaml } from "./config.ts";
3
-
4
-
Deno.test(function generateAWSCodePipelineTest() {
5
-
const buildspec = generateYaml();
6
-
const actual = buildspec.toString();
7
-
const expected = Deno.readTextFileSync("./fixtures/buildspec.yml");
8
-
assertEquals(actual, expected);
9
-
});
-3
.fluentci/src/aws/init.ts
-3
.fluentci/src/aws/init.ts
-42
.fluentci/src/azure/README.md
-42
.fluentci/src/azure/README.md
···
1
-
# Azure Pipelines
2
-
3
-
[](https://pkg.fluentci.io/rust_pipeline)
4
-
[](https://deno.land/x/rust_pipeline)
5
-

6
-
[](https://codecov.io/gh/fluent-ci-templates/rust-pipeline)
7
-
8
-
The following command will generate a `azure-pipelines.yml` file in your project:
9
-
10
-
```bash
11
-
fluentci ap init -t rust_pipeline
12
-
```
13
-
14
-
Generated file:
15
-
16
-
```yaml
17
-
# Do not edit this file directly. It is generated by https://deno.land/x/fluent_azure_pipelines
18
-
19
-
trigger:
20
-
- main
21
-
pool:
22
-
name: Default
23
-
vmImage: ubuntu-latest
24
-
steps:
25
-
- script: |
26
-
curl -fsSL https://deno.land/x/install/install.sh | sh
27
-
export DENO_INSTALL="$HOME/.deno"
28
-
export PATH="$DENO_INSTALL/bin:$PATH"
29
-
displayName: Install Deno
30
-
- script: deno install -A -r https://cli.fluentci.io -n fluentci
31
-
displayName: Setup Fluent CI CLI
32
-
- script: |
33
-
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
34
-
sudo mv bin/dagger /usr/local/bin
35
-
dagger version
36
-
displayName: Setup Dagger
37
-
- script: fluentci run rust_pipeline test build
38
-
displayName: Run Dagger Pipelines
39
-
40
-
```
41
-
42
-
Feel free to edit the template generator at `.fluentci/src/azure/config.ts` to your needs.
-41
.fluentci/src/azure/config.ts
-41
.fluentci/src/azure/config.ts
···
1
-
import { AzurePipeline } from "fluent_azure_pipelines";
2
-
3
-
export function generateYaml(): AzurePipeline {
4
-
const azurePipeline = new AzurePipeline();
5
-
6
-
const installDeno = `\
7
-
curl -fsSL https://deno.land/x/install/install.sh | sh
8
-
export DENO_INSTALL="$HOME/.deno"
9
-
export PATH="$DENO_INSTALL/bin:$PATH"
10
-
`;
11
-
12
-
const setupDagger = `\
13
-
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
14
-
sudo mv bin/dagger /usr/local/bin
15
-
dagger version
16
-
`;
17
-
18
-
azurePipeline
19
-
.trigger(["main"])
20
-
.pool({
21
-
name: "Default",
22
-
vmImage: "ubuntu-latest",
23
-
})
24
-
.step({
25
-
script: installDeno,
26
-
displayName: "Install Deno",
27
-
})
28
-
.step({
29
-
script: "deno install -A -r https://cli.fluentci.io -n fluentci",
30
-
displayName: "Setup Fluent CI CLI",
31
-
})
32
-
.step({
33
-
script: setupDagger,
34
-
displayName: "Setup Dagger",
35
-
})
36
-
.step({
37
-
script: "fluentci run rust_pipeline test build",
38
-
displayName: "Run Dagger Pipelines",
39
-
});
40
-
return azurePipeline;
41
-
}
-9
.fluentci/src/azure/config_test.ts
-9
.fluentci/src/azure/config_test.ts
···
1
-
import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts";
2
-
import { generateYaml } from "./config.ts";
3
-
4
-
Deno.test(function generateAzurePipelinesTest() {
5
-
const azurepipelines = generateYaml();
6
-
const actual = azurepipelines.toString();
7
-
const expected = Deno.readTextFileSync("./fixtures/azure-pipelines.yml");
8
-
assertEquals(actual, expected);
9
-
});
-3
.fluentci/src/azure/init.ts
-3
.fluentci/src/azure/init.ts
-47
.fluentci/src/circleci/README.md
-47
.fluentci/src/circleci/README.md
···
1
-
# Circle CI
2
-
3
-
[](https://pkg.fluentci.io/rust_pipeline)
4
-
[](https://deno.land/x/rust_pipeline)
5
-

6
-
[](https://codecov.io/gh/fluent-ci-templates/rust-pipeline)
7
-
8
-
9
-
The following command will generate a `.circleci/config.yml` file in your project:
10
-
11
-
```bash
12
-
fluentci cci init -t rust_pipeline
13
-
```
14
-
15
-
Generated file:
16
-
17
-
```yaml
18
-
# Do not edit this file directly. It is generated by https://deno.land/x/fluent_circleci
19
-
20
-
version: 2.1
21
-
jobs:
22
-
tests:
23
-
steps:
24
-
- checkout
25
-
- run: sudo apt-get update && sudo apt-get install -y curl unzip
26
-
- run: |
27
-
curl -fsSL https://deno.land/x/install/install.sh | sh
28
-
export DENO_INSTALL="$HOME/.deno"
29
-
export PATH="$DENO_INSTALL/bin:$PATH"
30
-
- run: deno install -A -r https://cli.fluentci.io -n fluentci
31
-
- run: |
32
-
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
33
-
sudo mv bin/dagger /usr/local/bin
34
-
dagger version
35
-
- run:
36
-
name: Upload Coverage
37
-
command: fluentci run rust_pipeline test build
38
-
machine:
39
-
image: ubuntu-2004:2023.07.1
40
-
workflows:
41
-
dagger:
42
-
jobs:
43
-
- tests
44
-
45
-
```
46
-
47
-
Feel free to edit the template generator at `.fluentci/src/circleci/config.ts` to your needs.
-37
.fluentci/src/circleci/config.ts
-37
.fluentci/src/circleci/config.ts
···
1
-
import { CircleCI, Job } from "fluent_circleci";
2
-
3
-
export function generateYaml(): CircleCI {
4
-
const circleci = new CircleCI();
5
-
6
-
const tests = new Job().machine({ image: "ubuntu-2004:2023.07.1" }).steps([
7
-
"checkout",
8
-
{
9
-
run: "sudo apt-get update && sudo apt-get install -y curl unzip",
10
-
},
11
-
{
12
-
run: `\
13
-
curl -fsSL https://deno.land/x/install/install.sh | sh
14
-
export DENO_INSTALL="$HOME/.deno"
15
-
export PATH="$DENO_INSTALL/bin:$PATH"`,
16
-
},
17
-
{
18
-
run: "deno install -A -r https://cli.fluentci.io -n fluentci",
19
-
},
20
-
{
21
-
run: `\
22
-
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
23
-
sudo mv bin/dagger /usr/local/bin
24
-
dagger version`,
25
-
},
26
-
{
27
-
run: {
28
-
name: "Run Dagger Pipelines",
29
-
command: "fluentci run rust_pipeline test build",
30
-
},
31
-
},
32
-
]);
33
-
34
-
circleci.jobs({ tests }).workflow("dagger", ["tests"]);
35
-
36
-
return circleci;
37
-
}
-9
.fluentci/src/circleci/config_test.ts
-9
.fluentci/src/circleci/config_test.ts
···
1
-
import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts";
2
-
import { generateYaml } from "./config.ts";
3
-
4
-
Deno.test(function generateCircleCITest() {
5
-
const circleci = generateYaml();
6
-
const actual = circleci.toString();
7
-
const expected = Deno.readTextFileSync("./fixtures/config.yml");
8
-
assertEquals(actual, expected);
9
-
});
-3
.fluentci/src/circleci/init.ts
-3
.fluentci/src/circleci/init.ts
.fluentci/src/dagger/index.ts
.fluentci/src/mod.ts
.fluentci/src/dagger/index.ts
.fluentci/src/mod.ts
-236
.fluentci/src/dagger/jobs.ts
-236
.fluentci/src/dagger/jobs.ts
···
1
-
import { dag } from "../../sdk/client.gen.ts";
2
-
import { buildRustFlags, getDirectory } from "./lib.ts";
3
-
4
-
export enum Job {
5
-
test = "test",
6
-
build = "build",
7
-
}
8
-
9
-
export const exclude = ["target", ".git", ".devbox", ".fluentci"];
10
-
11
-
export const test = async (src = ".", options: string[] = []) => {
12
-
const context = await getDirectory(src);
13
-
const ctr = dag
14
-
.container()
15
-
.from("rust:1.89-bullseye")
16
-
.withDirectory("/app", context, { exclude })
17
-
.withWorkdir("/app")
18
-
.withMountedCache("/app/target", dag.cacheVolume("target"))
19
-
.withMountedCache("/root/cargo/registry", dag.cacheVolume("registry"))
20
-
.withExec(["cargo", "test", ...options]);
21
-
22
-
return ctr.stdout();
23
-
};
24
-
25
-
export const build = async (src = ".") => {
26
-
const rustflags = buildRustFlags();
27
-
const context = await getDirectory(src);
28
-
const ctr = dag
29
-
.container()
30
-
.from("rust:1.89-bullseye")
31
-
.withExec(["dpkg", "--add-architecture", "armhf"])
32
-
.withExec(["dpkg", "--add-architecture", "arm64"])
33
-
.withExec(["apt-get", "update"])
34
-
.withExec([
35
-
"apt-get",
36
-
"install",
37
-
"-y",
38
-
"build-essential",
39
-
"libasound2-dev",
40
-
"protobuf-compiler",
41
-
])
42
-
.withExec([
43
-
"apt-get",
44
-
"install",
45
-
"-y",
46
-
"-qq",
47
-
"gcc-arm-linux-gnueabihf",
48
-
"libc6-armhf-cross",
49
-
"libc6-dev-armhf-cross",
50
-
"gcc-aarch64-linux-gnu",
51
-
"libc6-arm64-cross",
52
-
"libc6-dev-arm64-cross",
53
-
"libc6-armel-cross",
54
-
"libc6-dev-armel-cross",
55
-
"binutils-arm-linux-gnueabi",
56
-
"gcc-arm-linux-gnueabi",
57
-
"libncurses5-dev",
58
-
"bison",
59
-
"flex",
60
-
"libssl-dev",
61
-
"bc",
62
-
"pkg-config",
63
-
"libudev-dev",
64
-
"libdbus-1-dev",
65
-
])
66
-
.withExec(["mkdir", "-p", "/build/sysroot"])
67
-
.withExec([
68
-
"apt-get",
69
-
"download",
70
-
"libasound2:armhf",
71
-
"libasound2-dev:armhf",
72
-
"libdbus-1-dev:armhf",
73
-
"libdbus-1-3:armhf",
74
-
"libsystemd-dev:armhf",
75
-
"libsystemd0:armhf",
76
-
"libasound2:arm64",
77
-
"libasound2-dev:arm64",
78
-
"libdbus-1-dev:arm64",
79
-
"libdbus-1-3:arm64",
80
-
"libsystemd-dev:arm64",
81
-
"libsystemd0:arm64",
82
-
])
83
-
.withExec([
84
-
"dpkg",
85
-
"-x",
86
-
"libasound2-dev_1.2.4-1.1_arm64.deb",
87
-
"/build/sysroot/",
88
-
])
89
-
.withExec([
90
-
"dpkg",
91
-
"-x",
92
-
"libasound2_1.2.4-1.1_arm64.deb",
93
-
"/build/sysroot/",
94
-
])
95
-
.withExec([
96
-
"dpkg",
97
-
"-x",
98
-
"libasound2-dev_1.2.4-1.1_armhf.deb",
99
-
"/build/sysroot/",
100
-
])
101
-
.withExec([
102
-
"dpkg",
103
-
"-x",
104
-
"libasound2_1.2.4-1.1_armhf.deb",
105
-
"/build/sysroot/",
106
-
])
107
-
.withExec([
108
-
"dpkg",
109
-
"-x",
110
-
"libdbus-1-dev_1.12.28-0+deb11u1_armhf.deb",
111
-
"/build/sysroot/",
112
-
])
113
-
.withExec([
114
-
"dpkg",
115
-
"-x",
116
-
"libdbus-1-3_1.12.28-0+deb11u1_armhf.deb",
117
-
"/build/sysroot/",
118
-
])
119
-
.withExec([
120
-
"dpkg",
121
-
"-x",
122
-
"libsystemd-dev_247.3-7+deb11u7_armhf.deb",
123
-
"/build/sysroot/",
124
-
])
125
-
.withExec([
126
-
"dpkg",
127
-
"-x",
128
-
"libsystemd0_247.3-7+deb11u7_armhf.deb",
129
-
"/build/sysroot/",
130
-
])
131
-
.withExec([
132
-
"dpkg",
133
-
"-x",
134
-
"libdbus-1-dev_1.12.28-0+deb11u1_arm64.deb",
135
-
"/build/sysroot/",
136
-
])
137
-
.withExec([
138
-
"dpkg",
139
-
"-x",
140
-
"libdbus-1-3_1.12.28-0+deb11u1_arm64.deb",
141
-
"/build/sysroot/",
142
-
])
143
-
.withExec([
144
-
"dpkg",
145
-
"-x",
146
-
"libsystemd-dev_247.3-7+deb11u7_arm64.deb",
147
-
"/build/sysroot/",
148
-
])
149
-
.withExec([
150
-
"dpkg",
151
-
"-x",
152
-
"libsystemd0_247.3-7+deb11u7_arm64.deb",
153
-
"/build/sysroot/",
154
-
])
155
-
.withDirectory("/app", context, { exclude })
156
-
.withWorkdir("/app")
157
-
.withMountedCache("/app/target", dag.cacheVolume("target"))
158
-
.withMountedCache("/root/cargo/registry", dag.cacheVolume("registry"))
159
-
.withMountedCache("/assets", dag.cacheVolume("gh-release-assets"))
160
-
.withEnvVariable("RUSTFLAGS", rustflags)
161
-
.withEnvVariable(
162
-
"PKG_CONFIG_ALLOW_CROSS",
163
-
Deno.env.get("TARGET") !== "x86_64-unknown-linux-gnu" ? "1" : "0",
164
-
)
165
-
.withEnvVariable(
166
-
"C_INCLUDE_PATH",
167
-
Deno.env.get("TARGET") !== "x86_64-unknown-linux-gnu"
168
-
? "/build/sysroot/usr/include"
169
-
: "/usr/include",
170
-
)
171
-
.withEnvVariable("TAG", Deno.env.get("TAG") || "latest")
172
-
.withEnvVariable(
173
-
"TARGET",
174
-
Deno.env.get("TARGET") || "x86_64-unknown-linux-gnu",
175
-
)
176
-
.withExec([
177
-
"sh",
178
-
"-c",
179
-
"mv /usr/bin/protoc /usr/bin/_protoc && cp tools/protoc /usr/bin/protoc && chmod a+x /usr/bin/protoc",
180
-
])
181
-
.withExec(["sh", "-c", "rustup target add $TARGET"])
182
-
.withExec(["sh", "-c", "cargo build --release --target $TARGET"])
183
-
.withExec(["sh", "-c", "cp target/${TARGET}/release/tunein ."])
184
-
.withExec([
185
-
"sh",
186
-
"-c",
187
-
"tar czvf /assets/tunein_${TAG}_${TARGET}.tar.gz tunein README.md LICENSE",
188
-
])
189
-
.withExec([
190
-
"sh",
191
-
"-c",
192
-
"shasum -a 256 /assets/tunein_${TAG}_${TARGET}.tar.gz > /assets/tunein_${TAG}_${TARGET}.tar.gz.sha256",
193
-
])
194
-
.withExec(["sh", "-c", "cp /assets/tunein_${TAG}_${TARGET}.tar.gz ."])
195
-
.withExec([
196
-
"sh",
197
-
"-c",
198
-
"cp /assets/tunein_${TAG}_${TARGET}.tar.gz.sha256 .",
199
-
]);
200
-
201
-
const exe = await ctr.file(
202
-
`/app/tunein_${Deno.env.get("TAG")}_${Deno.env.get("TARGET")}.tar.gz`,
203
-
);
204
-
await exe.export(
205
-
`./tunein_${Deno.env.get("TAG")}_${Deno.env.get("TARGET")}.tar.gz`,
206
-
);
207
-
208
-
const sha = await ctr.file(
209
-
`/app/tunein_${Deno.env.get("TAG")}_${
210
-
Deno.env.get("TARGET")
211
-
}.tar.gz.sha256`,
212
-
);
213
-
await sha.export(
214
-
`./tunein_${Deno.env.get("TAG")}_${Deno.env.get("TARGET")}.tar.gz.sha256`,
215
-
);
216
-
return ctr.stdout();
217
-
};
218
-
219
-
export type JobExec = (src?: string) =>
220
-
| Promise<string>
221
-
| ((
222
-
src?: string,
223
-
options?: {
224
-
ignore: string[];
225
-
},
226
-
) => Promise<string>);
227
-
228
-
export const runnableJobs: Record<Job, JobExec> = {
229
-
[Job.test]: test,
230
-
[Job.build]: build,
231
-
};
232
-
233
-
export const jobDescriptions: Record<Job, string> = {
234
-
[Job.test]: "Run tests",
235
-
[Job.build]: "Build the project",
236
-
};
+22
-4
.fluentci/src/dagger/lib.ts
.fluentci/src/lib.ts
+22
-4
.fluentci/src/dagger/lib.ts
.fluentci/src/lib.ts
···
1
-
import { dag } from "../../sdk/client.gen.ts";
2
-
import { Directory, DirectoryID } from "../../deps.ts";
1
+
import { dag } from "../sdk/client.gen.ts";
2
+
import { Directory, DirectoryID } from "../deps.ts";
3
3
4
4
export const getDirectory = async (
5
5
src: string | Directory | undefined = ".",
···
27
27
let rustflags = "";
28
28
switch (Deno.env.get("TARGET")) {
29
29
case "aarch64-unknown-linux-gnu":
30
-
rustflags = `-Clink-arg=-lsystemd -C linker=aarch64-linux-gnu-gcc \
30
+
rustflags = `-Clink-arg=-lsystemd \
31
+
-Clink-arg=-lcap \
32
+
-Clink-arg=-lgcrypt \
33
+
-Clink-arg=-lgpg-error \
34
+
-Clink-arg=-lz4 \
35
+
-Clink-arg=-lzma \
36
+
-Clink-arg=-lpsx \
37
+
-Clink-arg=-lxxhash \
38
+
-Clink-arg=-lzstd \
39
+
-C linker=aarch64-linux-gnu-gcc \
31
40
-L/usr/aarch64-linux-gnu/lib \
32
41
-L/build/sysroot/usr/lib/aarch64-linux-gnu \
33
42
-L/build/sysroot/lib/aarch64-linux-gnu`;
34
43
break;
35
44
case "armv7-unknown-linux-gnueabihf":
36
-
rustflags = `-Clink-arg=-lsystemd -C linker=arm-linux-gnueabihf-gcc \
45
+
rustflags = `-Clink-arg=-lsystemd \
46
+
-Clink-arg=-lcap \
47
+
-Clink-arg=-lgcrypt \
48
+
-Clink-arg=-lgpg-error \
49
+
-Clink-arg=-lz4 \
50
+
-Clink-arg=-lzma \
51
+
-Clink-arg=-lpsx \
52
+
-Clink-arg=-lxxhash \
53
+
-Clink-arg=-lzstd \
54
+
-C linker=arm-linux-gnueabihf-gcc \
37
55
-L/usr/arm-linux-gnueabihf/lib \
38
56
-L/build/sysroot/usr/lib/arm-linux-gnueabihf \
39
57
-L/build/sysroot/lib/arm-linux-gnueabihf`;
+4
-4
.fluentci/src/dagger/list_jobs.ts
.fluentci/src/list_jobs.ts
+4
-4
.fluentci/src/dagger/list_jobs.ts
.fluentci/src/list_jobs.ts
···
1
-
import { brightGreen, stringifyTree } from "../../deps.ts";
2
-
import { runnableJobs, jobDescriptions, Job } from "./jobs.ts";
1
+
import { brightGreen, stringifyTree } from "../deps.ts";
2
+
import { Job, jobDescriptions, runnableJobs } from "./jobs.ts";
3
3
4
4
const tree = {
5
5
name: brightGreen("rust_pipeline"),
···
15
15
stringifyTree(
16
16
tree,
17
17
(t) => t.name,
18
-
(t) => t.children
19
-
)
18
+
(t) => t.children,
19
+
),
20
20
);
.fluentci/src/dagger/pipeline.ts
.fluentci/src/pipeline.ts
.fluentci/src/dagger/pipeline.ts
.fluentci/src/pipeline.ts
.fluentci/src/dagger/runner.ts
.fluentci/src/runner.ts
.fluentci/src/dagger/runner.ts
.fluentci/src/runner.ts
-50
.fluentci/src/github/README.md
-50
.fluentci/src/github/README.md
···
1
-
# Github Actions
2
-
3
-
[](https://pkg.fluentci.io/rust_pipeline)
4
-
[](https://deno.land/x/rust_pipeline)
5
-

6
-
[](https://codecov.io/gh/fluent-ci-templates/rust-pipeline)
7
-
8
-
The following command will generate a `.github/workflows/tests.yml` file in your project:
9
-
10
-
```bash
11
-
fluentci gh init -t rust_pipeline
12
-
```
13
-
14
-
Or, if you already have a `.fluentci` folder (generated from `fluentci init -t rust`) in your project:
15
-
16
-
```bash
17
-
fluentci gh init
18
-
```
19
-
20
-
Generated file:
21
-
22
-
```yaml
23
-
# Do not edit this file directly. It is generated by https://deno.land/x/fluent_github_actions
24
-
25
-
name: Test
26
-
on:
27
-
push:
28
-
branches:
29
-
- main
30
-
jobs:
31
-
test:
32
-
runs-on: ubuntu-latest
33
-
steps:
34
-
- uses: actions/checkout@v2
35
-
- uses: denoland/setup-deno@v1
36
-
with:
37
-
deno-version: v1.37
38
-
- name: Setup Fluent CI CLI
39
-
run: deno install -A -r https://cli.fluentci.io -n fluentci
40
-
- name: Setup Dagger
41
-
run: |
42
-
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
43
-
sudo mv bin/dagger /usr/local/bin
44
-
dagger version
45
-
- name: Run Tests and Build
46
-
run: fluentci run rust_pipeline test build
47
-
48
-
```
49
-
50
-
Feel free to edit the template generator at `.fluentci/src/github/config.ts` to your needs.
-45
.fluentci/src/github/config.ts
-45
.fluentci/src/github/config.ts
···
1
-
import { JobSpec, Workflow } from "fluent_github_actions";
2
-
3
-
export function generateYaml(): Workflow {
4
-
const workflow = new Workflow("Test");
5
-
6
-
const push = {
7
-
branches: ["main"],
8
-
};
9
-
10
-
const setupDagger = `\
11
-
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
12
-
sudo mv bin/dagger /usr/local/bin
13
-
dagger version`;
14
-
15
-
const test: JobSpec = {
16
-
"runs-on": "ubuntu-latest",
17
-
steps: [
18
-
{
19
-
uses: "actions/checkout@v2",
20
-
},
21
-
{
22
-
uses: "denoland/setup-deno@v1",
23
-
with: {
24
-
"deno-version": "v1.37",
25
-
},
26
-
},
27
-
{
28
-
name: "Setup Fluent CI CLI",
29
-
run: "deno install -A -r https://cli.fluentci.io -n fluentci",
30
-
},
31
-
{
32
-
name: "Setup Dagger",
33
-
run: setupDagger,
34
-
},
35
-
{
36
-
name: "Run Tests and Build",
37
-
run: "fluentci run rust_pipeline test build",
38
-
},
39
-
],
40
-
};
41
-
42
-
workflow.on({ push }).jobs({ test });
43
-
44
-
return workflow;
45
-
}
-9
.fluentci/src/github/config_test.ts
-9
.fluentci/src/github/config_test.ts
···
1
-
import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts";
2
-
import { generateYaml } from "./config.ts";
3
-
4
-
Deno.test(function generateGithubActionsWorkflowTest() {
5
-
const workflow = generateYaml();
6
-
const actual = workflow.toString();
7
-
const expected = Deno.readTextFileSync("./fixtures/workflow.yml");
8
-
assertEquals(actual, expected);
9
-
});
-3
.fluentci/src/github/init.ts
-3
.fluentci/src/github/init.ts
-48
.fluentci/src/gitlab/README.md
-48
.fluentci/src/gitlab/README.md
···
1
-
# Gitlab CI
2
-
3
-
[](https://pkg.fluentci.io/rust_pipeline)
4
-
[](https://deno.land/x/rust_pipeline)
5
-

6
-
[](https://codecov.io/gh/fluent-ci-templates/rust-pipeline)
7
-
8
-
The following command will generate a `.gitlab-ci.yml` file in your project:
9
-
10
-
```bash
11
-
fluentci gl init -t rust_pipeline
12
-
```
13
-
14
-
Generated file:
15
-
16
-
```yaml
17
-
18
-
# Do not edit this file directly. It is generated by https://deno.land/x/fluent_gitlab_ci
19
-
20
-
.docker:
21
-
image: denoland/deno:alpine
22
-
services:
23
-
- docker:${DOCKER_VERSION}-dind
24
-
variables:
25
-
DOCKER_HOST: tcp://docker:2376
26
-
DOCKER_TLS_VERIFY: "1"
27
-
DOCKER_TLS_CERTDIR: /certs
28
-
DOCKER_CERT_PATH: /certs/client
29
-
DOCKER_DRIVER: overlay2
30
-
DOCKER_VERSION: 20.10.16
31
-
32
-
.dagger:
33
-
extends: .docker
34
-
before_script:
35
-
- apk add docker-cli curl unzip
36
-
- deno install -A -r https://cli.fluentci.io -n fluentci
37
-
- curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
38
-
- mv bin/dagger /usr/local/bin
39
-
- dagger version
40
-
41
-
tests:
42
-
extends: .dagger
43
-
script:
44
-
- fluentci run rust_pipeline test build
45
-
46
-
```
47
-
48
-
Feel free to edit the template generator at `.fluentci/src/gitlab/config.ts` to your needs.
-34
.fluentci/src/gitlab/config.ts
-34
.fluentci/src/gitlab/config.ts
···
1
-
import { GitlabCI, Job } from "fluent_gitlab_ci";
2
-
3
-
export function generateYaml(): GitlabCI {
4
-
const docker = new Job()
5
-
.image("denoland/deno:alpine")
6
-
.services(["docker:${DOCKER_VERSION}-dind"])
7
-
.variables({
8
-
DOCKER_HOST: "tcp://docker:2376",
9
-
DOCKER_TLS_VERIFY: "1",
10
-
DOCKER_TLS_CERTDIR: "/certs",
11
-
DOCKER_CERT_PATH: "/certs/client",
12
-
DOCKER_DRIVER: "overlay2",
13
-
DOCKER_VERSION: "20.10.16",
14
-
});
15
-
16
-
const dagger = new Job().extends(".docker").beforeScript(
17
-
`
18
-
apk add docker-cli curl unzip
19
-
deno install -A -r https://cli.fluentci.io -n fluentci
20
-
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh
21
-
mv bin/dagger /usr/local/bin
22
-
dagger version
23
-
`
24
-
);
25
-
26
-
const tests = new Job()
27
-
.extends(".dagger")
28
-
.script("fluentci run rust_pipeline test build");
29
-
30
-
return new GitlabCI()
31
-
.addJob(".docker", docker)
32
-
.addJob(".dagger", dagger)
33
-
.addJob("tests", tests);
34
-
}
-9
.fluentci/src/gitlab/config_test.ts
-9
.fluentci/src/gitlab/config_test.ts
···
1
-
import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts";
2
-
import { generateYaml } from "./config.ts";
3
-
4
-
Deno.test(function generateGitlabCITest() {
5
-
const gitlabci = generateYaml();
6
-
const actual = gitlabci.toString();
7
-
const expected = Deno.readTextFileSync("./fixtures/.gitlab-ci.yml");
8
-
assertEquals(actual, expected);
9
-
});
-3
.fluentci/src/gitlab/init.ts
-3
.fluentci/src/gitlab/init.ts
+434
.fluentci/src/jobs.ts
+434
.fluentci/src/jobs.ts
···
1
+
import { dag } from "../sdk/client.gen.ts";
2
+
import { buildRustFlags, getDirectory } from "./lib.ts";
3
+
4
+
export enum Job {
5
+
test = "test",
6
+
build = "build",
7
+
}
8
+
9
+
export const exclude = ["target", ".git", ".devbox", ".fluentci"];
10
+
11
+
export const test = async (src = ".", options: string[] = []) => {
12
+
const context = await getDirectory(src);
13
+
const ctr = dag
14
+
.container()
15
+
.from("rust:1.89-bullseye")
16
+
.withDirectory("/app", context, { exclude })
17
+
.withWorkdir("/app")
18
+
.withMountedCache("/app/target", dag.cacheVolume("target"))
19
+
.withMountedCache("/root/cargo/registry", dag.cacheVolume("registry"))
20
+
.withExec(["cargo", "test", ...options]);
21
+
22
+
return ctr.stdout();
23
+
};
24
+
25
+
export const build = async (src = ".") => {
26
+
const rustflags = buildRustFlags();
27
+
const context = await getDirectory(src);
28
+
const ctr = dag
29
+
.container()
30
+
.from("rust:1.89-bullseye")
31
+
.withExec(["dpkg", "--add-architecture", "armhf"])
32
+
.withExec(["dpkg", "--add-architecture", "arm64"])
33
+
.withExec(["apt-get", "update"])
34
+
.withExec([
35
+
"apt-get",
36
+
"install",
37
+
"-y",
38
+
"build-essential",
39
+
"libasound2-dev",
40
+
"protobuf-compiler",
41
+
])
42
+
.withExec([
43
+
"apt-get",
44
+
"install",
45
+
"-y",
46
+
"-qq",
47
+
"gcc-arm-linux-gnueabihf",
48
+
"libc6-armhf-cross",
49
+
"libc6-dev-armhf-cross",
50
+
"gcc-aarch64-linux-gnu",
51
+
"libc6-arm64-cross",
52
+
"libc6-dev-arm64-cross",
53
+
"libc6-armel-cross",
54
+
"libc6-dev-armel-cross",
55
+
"binutils-arm-linux-gnueabi",
56
+
"gcc-arm-linux-gnueabi",
57
+
"libncurses5-dev",
58
+
"bison",
59
+
"flex",
60
+
"libssl-dev",
61
+
"bc",
62
+
"pkg-config",
63
+
"libudev-dev",
64
+
"libdbus-1-dev",
65
+
])
66
+
.withExec(["mkdir", "-p", "/build/sysroot"])
67
+
.withExec([
68
+
"apt-get",
69
+
"download",
70
+
"libasound2:armhf",
71
+
"libasound2-dev:armhf",
72
+
"libdbus-1-dev:armhf",
73
+
"libdbus-1-3:armhf",
74
+
"libsystemd-dev:armhf",
75
+
"libsystemd0:armhf",
76
+
"libcap2:armhf",
77
+
"libcap-dev:armhf",
78
+
"libgcrypt20:armhf",
79
+
"libgcrypt20-dev:armhf",
80
+
"libgpg-error0:armhf",
81
+
"libgpg-error-dev:armhf",
82
+
"liblz4-1:armhf",
83
+
"liblz4-dev:armhf",
84
+
"libxxhash0:armhf",
85
+
"libxxhash-dev:armhf",
86
+
"liblzma5:armhf",
87
+
"liblzma-dev:armhf",
88
+
"libzstd1:armhf",
89
+
"libzstd-dev:armhf",
90
+
91
+
"libasound2:arm64",
92
+
"libasound2-dev:arm64",
93
+
"libdbus-1-dev:arm64",
94
+
"libdbus-1-3:arm64",
95
+
"libsystemd-dev:arm64",
96
+
"libsystemd0:arm64",
97
+
"libcap2:arm64",
98
+
"libcap-dev:arm64",
99
+
"libgcrypt20:arm64",
100
+
"libgcrypt20-dev:arm64",
101
+
"libgpg-error0:arm64",
102
+
"libgpg-error-dev:arm64",
103
+
"liblz4-1:arm64",
104
+
"liblz4-dev:arm64",
105
+
"libxxhash0:arm64",
106
+
"libxxhash-dev:arm64",
107
+
"liblzma5:arm64",
108
+
"liblzma-dev:arm64",
109
+
"libzstd1:arm64",
110
+
"libzstd-dev:arm64",
111
+
])
112
+
.withExec([
113
+
"dpkg",
114
+
"-x",
115
+
"libasound2-dev_1.2.4-1.1_arm64.deb",
116
+
"/build/sysroot/",
117
+
])
118
+
.withExec([
119
+
"dpkg",
120
+
"-x",
121
+
"libasound2_1.2.4-1.1_arm64.deb",
122
+
"/build/sysroot/",
123
+
])
124
+
.withExec([
125
+
"dpkg",
126
+
"-x",
127
+
"libasound2-dev_1.2.4-1.1_armhf.deb",
128
+
"/build/sysroot/",
129
+
])
130
+
.withExec([
131
+
"dpkg",
132
+
"-x",
133
+
"libasound2_1.2.4-1.1_armhf.deb",
134
+
"/build/sysroot/",
135
+
])
136
+
.withExec([
137
+
"dpkg",
138
+
"-x",
139
+
"libdbus-1-dev_1.12.28-0+deb11u1_armhf.deb",
140
+
"/build/sysroot/",
141
+
])
142
+
.withExec([
143
+
"dpkg",
144
+
"-x",
145
+
"libdbus-1-3_1.12.28-0+deb11u1_armhf.deb",
146
+
"/build/sysroot/",
147
+
])
148
+
.withExec([
149
+
"dpkg",
150
+
"-x",
151
+
"libsystemd-dev_247.3-7+deb11u7_armhf.deb",
152
+
"/build/sysroot/",
153
+
])
154
+
.withExec([
155
+
"dpkg",
156
+
"-x",
157
+
"libsystemd0_247.3-7+deb11u7_armhf.deb",
158
+
"/build/sysroot/",
159
+
])
160
+
.withExec([
161
+
"dpkg",
162
+
"-x",
163
+
"libcap-dev_1%3a2.44-1+deb11u1_armhf.deb",
164
+
"/build/sysroot/",
165
+
])
166
+
.withExec([
167
+
"dpkg",
168
+
"-x",
169
+
"libcap2_1%3a2.44-1+deb11u1_armhf.deb",
170
+
"/build/sysroot/",
171
+
])
172
+
.withExec([
173
+
"dpkg",
174
+
"-x",
175
+
"libgcrypt20-dev_1.8.7-6_armhf.deb",
176
+
"/build/sysroot/",
177
+
])
178
+
.withExec([
179
+
"dpkg",
180
+
"-x",
181
+
"libgcrypt20_1.8.7-6_armhf.deb",
182
+
"/build/sysroot/",
183
+
])
184
+
.withExec([
185
+
"dpkg",
186
+
"-x",
187
+
"libgpg-error-dev_1.38-2_armhf.debeb",
188
+
"/build/sysroot/",
189
+
])
190
+
.withExec([
191
+
"dpkg",
192
+
"-x",
193
+
"libgpg-error0_1.38-2_armhf.deb",
194
+
"/build/sysroot/",
195
+
])
196
+
.withExec([
197
+
"dpkg",
198
+
"-x",
199
+
"liblz4-1_1.9.3-2_armhf.deb",
200
+
"/build/sysroot/",
201
+
])
202
+
.withExec([
203
+
"dpkg",
204
+
"-x",
205
+
"liblz4-dev_1.9.3-2_armhf.deb",
206
+
"/build/sysroot/",
207
+
])
208
+
.withExec([
209
+
"dpkg",
210
+
"-x",
211
+
"liblzma-dev_5.2.5-2.1~deb11u1_armhf.deb",
212
+
"/build/sysroot/",
213
+
])
214
+
.withExec([
215
+
"dpkg",
216
+
"-x",
217
+
"liblzma5_5.2.5-2.1~deb11u1_armhf.deb",
218
+
"/build/sysroot/",
219
+
])
220
+
.withExec([
221
+
"dpkg",
222
+
"-x",
223
+
"libxxhash-dev_0.8.0-2_armhf.deb",
224
+
"/build/sysroot/",
225
+
])
226
+
.withExec([
227
+
"dpkg",
228
+
"-x",
229
+
"libxxhash0_0.8.0-2_armhf.deb",
230
+
"/build/sysroot/",
231
+
])
232
+
.withExec([
233
+
"dpkg",
234
+
"-x",
235
+
"libzstd1_1.4.8+dfsg-2.1_armhf.deb",
236
+
"/build/sysroot/",
237
+
])
238
+
.withExec([
239
+
"dpkg",
240
+
"-x",
241
+
"libzstd-dev_1.4.8+dfsg-2.1_armhf.deb",
242
+
"/build/sysroot/",
243
+
])
244
+
.withExec([
245
+
"dpkg",
246
+
"-x",
247
+
"libdbus-1-dev_1.12.28-0+deb11u1_arm64.deb",
248
+
"/build/sysroot/",
249
+
])
250
+
.withExec([
251
+
"dpkg",
252
+
"-x",
253
+
"libdbus-1-3_1.12.28-0+deb11u1_arm64.deb",
254
+
"/build/sysroot/",
255
+
])
256
+
.withExec([
257
+
"dpkg",
258
+
"-x",
259
+
"libsystemd-dev_247.3-7+deb11u7_arm64.deb",
260
+
"/build/sysroot/",
261
+
])
262
+
.withExec([
263
+
"dpkg",
264
+
"-x",
265
+
"libsystemd0_247.3-7+deb11u7_arm64.deb",
266
+
"/build/sysroot/",
267
+
])
268
+
.withExec([
269
+
"dpkg",
270
+
"-x",
271
+
"libcap-dev_1%3a2.44-1+deb11u1_arm64.deb",
272
+
"/build/sysroot/",
273
+
])
274
+
.withExec([
275
+
"dpkg",
276
+
"-x",
277
+
"libcap2_1%3a2.44-1+deb11u1_arm64.deb",
278
+
"/build/sysroot/",
279
+
])
280
+
.withExec([
281
+
"dpkg",
282
+
"-x",
283
+
"libgcrypt20-dev_1.8.7-6_arm64.deb",
284
+
"/build/sysroot/",
285
+
])
286
+
.withExec([
287
+
"dpkg",
288
+
"-x",
289
+
"libgcrypt20_1.8.7-6_arm64.deb",
290
+
"/build/sysroot/",
291
+
])
292
+
.withExec([
293
+
"dpkg",
294
+
"-x",
295
+
"libgpg-error-dev_1.38-2_arm64.deb",
296
+
"/build/sysroot/",
297
+
])
298
+
.withExec([
299
+
"dpkg",
300
+
"-x",
301
+
"libgpg-error0_1.38-2_arm64.deb",
302
+
"/build/sysroot/",
303
+
])
304
+
.withExec([
305
+
"dpkg",
306
+
"-x",
307
+
"liblz4-1_1.9.3-2_arm64.deb",
308
+
"/build/sysroot/",
309
+
])
310
+
.withExec([
311
+
"dpkg",
312
+
"-x",
313
+
"liblz4-dev_1.9.3-2_arm64.deb",
314
+
"/build/sysroot/",
315
+
])
316
+
.withExec([
317
+
"dpkg",
318
+
"-x",
319
+
"liblzma-dev_5.2.5-2.1~deb11u1_arm64.deb",
320
+
"/build/sysroot/",
321
+
])
322
+
.withExec([
323
+
"dpkg",
324
+
"-x",
325
+
"liblzma5_5.2.5-2.1~deb11u1_arm64.deb",
326
+
"/build/sysroot/",
327
+
])
328
+
.withExec([
329
+
"dpkg",
330
+
"-x",
331
+
"libxxhash-dev_0.8.0-2_arm64.deb",
332
+
"/build/sysroot/",
333
+
])
334
+
.withExec([
335
+
"dpkg",
336
+
"-x",
337
+
"libxxhash0_0.8.0-2_arm64.deb",
338
+
"/build/sysroot/",
339
+
])
340
+
.withExec([
341
+
"dpkg",
342
+
"-x",
343
+
"libzstd1_1.4.8+dfsg-2.1_arm64.deb",
344
+
"/build/sysroot/",
345
+
])
346
+
.withExec([
347
+
"dpkg",
348
+
"-x",
349
+
"libzstd-dev_1.4.8+dfsg-2.1_arm64.deb",
350
+
"/build/sysroot/",
351
+
])
352
+
.withDirectory("/app", context, { exclude })
353
+
.withDirectory("/app", context, { exclude })
354
+
.withWorkdir("/app")
355
+
.withMountedCache("/app/target", dag.cacheVolume("target"))
356
+
.withMountedCache("/root/cargo/registry", dag.cacheVolume("registry"))
357
+
.withMountedCache("/assets", dag.cacheVolume("gh-release-assets"))
358
+
.withEnvVariable("RUSTFLAGS", rustflags)
359
+
.withEnvVariable(
360
+
"PKG_CONFIG_ALLOW_CROSS",
361
+
Deno.env.get("TARGET") !== "x86_64-unknown-linux-gnu" ? "1" : "0",
362
+
)
363
+
.withEnvVariable(
364
+
"C_INCLUDE_PATH",
365
+
Deno.env.get("TARGET") !== "x86_64-unknown-linux-gnu"
366
+
? "/build/sysroot/usr/include"
367
+
: "/usr/include",
368
+
)
369
+
.withEnvVariable("TAG", Deno.env.get("TAG") || "latest")
370
+
.withEnvVariable(
371
+
"TARGET",
372
+
Deno.env.get("TARGET") || "x86_64-unknown-linux-gnu",
373
+
)
374
+
.withExec([
375
+
"sh",
376
+
"-c",
377
+
"mv /usr/bin/protoc /usr/bin/_protoc && cp tools/protoc /usr/bin/protoc && chmod a+x /usr/bin/protoc",
378
+
])
379
+
.withExec(["sh", "-c", "rustup target add $TARGET"])
380
+
.withExec(["sh", "-c", "cargo build --release --target $TARGET"])
381
+
.withExec(["sh", "-c", "cp target/${TARGET}/release/tunein ."])
382
+
.withExec([
383
+
"sh",
384
+
"-c",
385
+
"tar czvf /assets/tunein_${TAG}_${TARGET}.tar.gz tunein README.md LICENSE",
386
+
])
387
+
.withExec([
388
+
"sh",
389
+
"-c",
390
+
"shasum -a 256 /assets/tunein_${TAG}_${TARGET}.tar.gz > /assets/tunein_${TAG}_${TARGET}.tar.gz.sha256",
391
+
])
392
+
.withExec(["sh", "-c", "cp /assets/tunein_${TAG}_${TARGET}.tar.gz ."])
393
+
.withExec([
394
+
"sh",
395
+
"-c",
396
+
"cp /assets/tunein_${TAG}_${TARGET}.tar.gz.sha256 .",
397
+
]);
398
+
399
+
const exe = await ctr.file(
400
+
`/app/tunein_${Deno.env.get("TAG")}_${Deno.env.get("TARGET")}.tar.gz`,
401
+
);
402
+
await exe.export(
403
+
`./tunein_${Deno.env.get("TAG")}_${Deno.env.get("TARGET")}.tar.gz`,
404
+
);
405
+
406
+
const sha = await ctr.file(
407
+
`/app/tunein_${Deno.env.get("TAG")}_${
408
+
Deno.env.get("TARGET")
409
+
}.tar.gz.sha256`,
410
+
);
411
+
await sha.export(
412
+
`./tunein_${Deno.env.get("TAG")}_${Deno.env.get("TARGET")}.tar.gz.sha256`,
413
+
);
414
+
return ctr.stdout();
415
+
};
416
+
417
+
export type JobExec = (src?: string) =>
418
+
| Promise<string>
419
+
| ((
420
+
src?: string,
421
+
options?: {
422
+
ignore: string[];
423
+
},
424
+
) => Promise<string>);
425
+
426
+
export const runnableJobs: Record<Job, JobExec> = {
427
+
[Job.test]: test,
428
+
[Job.build]: build,
429
+
};
430
+
431
+
export const jobDescriptions: Record<Job, string> = {
432
+
[Job.test]: "Run tests",
433
+
[Job.build]: "Build the project",
434
+
};