-
Notifications
You must be signed in to change notification settings - Fork 0
/
rust.go
50 lines (42 loc) · 1.06 KB
/
rust.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package internal
import (
"github.com/CircleCI-Public/circleci-config/config"
"github.com/CircleCI-Public/circleci-config/labeling/labels"
)
const rustDockerImage = "cimg/rust:1.70"
const cargoCacheKey = `cargo-{{ checksum "Cargo.lock" }}`
func rustInitialSteps(ls labels.LabelSet) []config.Step {
return []config.Step{checkoutStep(ls[labels.DepsRust]), {
Type: config.RestoreCache,
CacheKey: cargoCacheKey,
}}
}
func rustTestJob(ls labels.LabelSet) *Job {
steps := rustInitialSteps(ls)
steps = append(steps, []config.Step{
{
Type: config.Run,
Command: "cargo test",
},
{
Type: config.SaveCache,
CacheKey: cargoCacheKey,
Path: "~/.cargo",
},
}...)
return &Job{
Job: config.Job{
Name: "test-rust",
DockerImages: []string{rustDockerImage},
WorkingDirectory: workingDirectory(ls[labels.DepsRust]),
Steps: steps,
},
Type: TestJob,
}
}
func GenerateRustJobs(ls labels.LabelSet) (jobs []*Job) {
if !ls[labels.DepsRust].Valid {
return nil
}
return append(jobs, rustTestJob(ls))
}