chore(ci): add brigade configuration (#166)
This commit is contained in:
parent
9a6542fea3
commit
4c4d692eb1
@ -12,6 +12,7 @@ policies:
|
||||
- test
|
||||
scopes:
|
||||
- ami
|
||||
- ci
|
||||
- conformance
|
||||
- hack
|
||||
- image
|
||||
|
64
brigade.js
Normal file
64
brigade.js
Normal file
@ -0,0 +1,64 @@
|
||||
const { events, Job, Group } = require("brigadier");
|
||||
|
||||
events.on("exec", function (e, project) {
|
||||
job = conform(e, project)
|
||||
job.run().then(result => {
|
||||
console.log(result.toString())
|
||||
})
|
||||
})
|
||||
|
||||
events.on("push", function (e, project) {
|
||||
job = conform(e, project)
|
||||
job.run().then(result => {
|
||||
console.log(result.toString())
|
||||
})
|
||||
})
|
||||
|
||||
events.on("pull_request", function (e, project) {
|
||||
start = notify("pending", `Build ${e.buildID} started`, e, project)
|
||||
job = conform(e, project)
|
||||
Group.runAll([start, job])
|
||||
.then(() => {
|
||||
return notify("success", `Build ${e.buildID} passed`, e, project).run()
|
||||
}).catch(err => {
|
||||
return notify("failure", `Build ${e.buildID} failed`, e, project).run()
|
||||
});
|
||||
})
|
||||
|
||||
function conform(e, project) {
|
||||
var job = new Job("dianemo", "autonomy/conform:latest")
|
||||
|
||||
job.env = {
|
||||
// "DOCKER_HOST": "tcp://docker:2375"
|
||||
"DOCKER_USERNAME": project.secrets.DOCKER_USERNAME,
|
||||
"DOCKER_PASSWORD": project.secrets.DOCKER_PASSWORD,
|
||||
}
|
||||
|
||||
job.tasks = [
|
||||
"apk --no-cache add docker",
|
||||
"cd /src",
|
||||
"conform enforce",
|
||||
"conform build",
|
||||
]
|
||||
|
||||
job.docker.enabled = true
|
||||
|
||||
// Unit is milliseconds, 14400000ms = 4h.
|
||||
job.timeout = 14400000
|
||||
|
||||
return job
|
||||
}
|
||||
|
||||
function notify(state, msg, e, project) {
|
||||
const gh = new Job(`notify-${state}`, "technosophos/github-notify:latest")
|
||||
gh.env = {
|
||||
GH_REPO: project.repo.name,
|
||||
GH_STATE: state,
|
||||
GH_DESCRIPTION: msg,
|
||||
GH_CONTEXT: "brigade",
|
||||
GH_TOKEN: project.secrets.GH_TOKEN,
|
||||
GH_COMMIT: e.revision.commit,
|
||||
GH_TARGET_URL: `https://ci.dev.autonomy.io/builds/${e.buildID}`,
|
||||
}
|
||||
return gh
|
||||
}
|
@ -4,10 +4,10 @@
|
||||
# options for analysis running
|
||||
run:
|
||||
# default concurrency is a available CPU number
|
||||
concurrency: 4
|
||||
# concurrency: 4
|
||||
|
||||
# timeout for analysis, e.g. 30s, 5m, default is 1m
|
||||
deadline: 5m
|
||||
deadline: 10m
|
||||
|
||||
# exit code when at least one issue was found, default is 1
|
||||
issues-exit-code: 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user