Skip to content

Commit

Permalink
Merge pull request #956 from RDIL/master
Browse files Browse the repository at this point in the history
Add Cirrus CI support
  • Loading branch information
orta authored Nov 11, 2019
2 parents 2803ede + da4f66d commit 0cd4f3a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
50 changes: 50 additions & 0 deletions source/ci_source/providers/Cirrus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Env, CISource } from "../ci_source"
import { ensureEnvKeysExist, ensureEnvKeysAreInt } from "../ci_source_helpers"

/**
* ### CI Setup
*
* You need to edit your `.cirrus.yml` to add a `script` like this:
*
* ```yaml
* danger_script:
* - yarn danger ci
* ```
*
* ### Token Setup
*
* You need to add the `DANGER_GITHUB_API_TOKEN` environment variable, to do this,
* go to your repo's settings, by clicking the gear at `https://cirrus-ci.com/github/[user]/[repo]`.
* Generate the encrypted value, and add it to your `env` block.
*
* Once you have added it, trigger a build.
*/
export class Cirrus implements CISource {
constructor(private readonly env: Env) {}

get name(): string {
return "Cirrus CI"
}

get isCI(): boolean {
return ensureEnvKeysExist(this.env, ["CIRRUS_CI"])
}

get isPR(): boolean {
const mustHave = ["CIRRUS_CI", "CIRRUS_PR", "CIRRUS_REPO_FULL_NAME"]
const mustBeInts = ["CIRRUS_PR"]
return ensureEnvKeysExist(this.env, mustHave) && ensureEnvKeysAreInt(this.env, mustBeInts)
}

get pullRequestID(): string {
return this.env.CIRRUS_PR
}

get repoSlug(): string {
return this.env.CIRRUS_REPO_FULL_NAME
}

get ciRunURL() {
return `https://cirrus-ci.com/task/${this.env.CIRRUS_TASK_ID}`
}
}
3 changes: 3 additions & 0 deletions source/ci_source/providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { TeamCity } from "./TeamCity"
import { Travis } from "./Travis"
import { VSTS } from "./VSTS"
import { BitbucketPipelines } from "./BitbucketPipelines"
import { Cirrus } from "./Cirrus"

const providers = [
FakeCI,
Expand Down Expand Up @@ -50,6 +51,7 @@ const providers = [
Codefresh,
AppCenter,
BitbucketPipelines,
Cirrus,
]

// Mainly used for Dangerfile linting
Expand All @@ -76,6 +78,7 @@ const realProviders = [
CodeBuild,
Codefresh,
AppCenter,
Cirrus
]

export { providers, realProviders }

0 comments on commit 0cd4f3a

Please sign in to comment.