-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kent Rancourt <[email protected]>
- Loading branch information
Showing
31 changed files
with
2,027 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { events, Event, Job, ConcurrentGroup } from "@brigadecore/brigadier" | ||
|
||
const goImg = "brigadecore/go-tools:v0.1.0" | ||
const localPath = "/workspaces/brigade-foundations" | ||
|
||
// MakeTargetJob is just a job wrapper around a make target. | ||
class MakeTargetJob extends Job { | ||
constructor(target: string, img: string, event: Event, env?: {[key: string]: string}) { | ||
super(target, img, event) | ||
this.primaryContainer.sourceMountPath = localPath | ||
this.primaryContainer.workingDirectory = localPath | ||
this.primaryContainer.environment = env || {} | ||
this.primaryContainer.environment["SKIP_DOCKER"] = "true" | ||
this.primaryContainer.command = [ "make" ] | ||
this.primaryContainer.arguments = [ target ] | ||
} | ||
} | ||
|
||
// A map of all jobs. When a check_run:rerequested event wants to re-run a | ||
// single job, this allows us to easily find that job by name. | ||
const jobs: {[key: string]: (event: Event) => Job } = {} | ||
|
||
const testUnitJobName = "test-unit" | ||
const testUnitJob = (event: Event) => { | ||
return new MakeTargetJob(testUnitJobName, goImg, event) | ||
} | ||
jobs[testUnitJobName] = testUnitJob | ||
|
||
const lintJobName = "lint" | ||
const lintJob = (event: Event) => { | ||
return new MakeTargetJob(lintJobName, goImg, event) | ||
} | ||
jobs[lintJobName] = lintJob | ||
|
||
// Run the entire suite of tests WITHOUT publishing anything initially. If | ||
// EVERYTHING passes AND this was a push (merge, presumably) to the master | ||
// branch, then publish an "edge" image. | ||
async function runSuite(event: Event): Promise<void> { | ||
await new ConcurrentGroup( // Basic tests | ||
testUnitJob(event), | ||
lintJob(event), | ||
).run() | ||
} | ||
|
||
// Either of these events should initiate execution of the entire test suite. | ||
events.on("brigade.sh/github", "check_suite:requested", runSuite) | ||
events.on("brigade.sh/github", "check_suite:rerequested", runSuite) | ||
|
||
// This event indicates a specific job is to be re-run. | ||
events.on("brigade.sh/github", "check_run:rerequested", async event => { | ||
// Check run names are of the form <project name>:<job name>, so we strip | ||
// event.project.id.length + 1 characters off the start of the check run name | ||
// to find the job name. | ||
const jobName = JSON.parse(event.payload).check_run.name.slice(event.project.id.length + 1) | ||
const job = jobs[jobName] | ||
if (job) { | ||
await job(event).run() | ||
return | ||
} | ||
throw new Error(`No job found with name: ${jobName}`) | ||
}) | ||
|
||
events.process() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "brigade-foundations-ci-cd", | ||
"dependencies": { | ||
"@brigadecore/brigadier": "^2.0.0-beta.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/brigadecore/brigade/v2/v2/apiserver/schemas/project.json | ||
apiVersion: brigade.sh/v2-beta | ||
kind: Project | ||
metadata: | ||
id: brigade-foundations | ||
description: Brigade Foundations built with Brigade 2! | ||
spec: | ||
eventSubscriptions: | ||
- source: brigade.sh/github | ||
qualifiers: | ||
repo: brigadecore/brigade-foundations | ||
types: | ||
- check_run:rerequested | ||
- check_suite:requested | ||
- check_suite:rerequested | ||
- push | ||
workerTemplate: | ||
git: | ||
cloneURL: https://github.com/brigadecore/brigade-foundations.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
"@brigadecore/brigadier@^2.0.0-beta.1": | ||
version "2.0.0-beta.1" | ||
resolved "https://registry.yarnpkg.com/@brigadecore/brigadier/-/brigadier-2.0.0-beta.1.tgz#8abd9461d445d1d13c83404cec22c16f3cbc2104" | ||
integrity sha512-PoDfSAYMpqXyhTP+DBE7B1xHXtCxuW7SCLcH9/yQyr4kgeKxsAyYvy1baQx1G5ujpWcKX4ULmxf7dsJdHPX+3w== | ||
dependencies: | ||
"@types/node" "^14.14.11" | ||
|
||
"@types/node@^14.14.11": | ||
version "14.17.6" | ||
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.17.6.tgz#cc61c8361c89e70c468cda464d1fa3dd7e5ebd62" | ||
integrity sha512-iBxsxU7eswQDGhlr3AiamBxOssaYxbM+NKXVil8jg9yFXvrfEFbDumLD/2dMTB+zYyg7w+Xjt8yuxfdbUHAtcQ== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.gocache/ | ||
coverage.txt | ||
.DS_Store | ||
.brigade/node_modules/ | ||
.brigade/secrets.yaml | ||
|
||
# IDEs | ||
.vscode/ | ||
.devcontainer/ | ||
.idea/ | ||
.swp |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This file is described here: https://help.github.com/en/articles/about-code-owners | ||
|
||
# Global Owners: These members are Core Maintainers of Brigade | ||
* @brigadecore/maintainers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Contributing Guide | ||
|
||
See our Brigade project [Contributing Guide](https://github.com/brigadecore/community/blob/master/contributing.md). |
Oops, something went wrong.