Skip to content

Commit

Permalink
Add support for Github Actions #6
Browse files Browse the repository at this point in the history
  • Loading branch information
sagiegurari committed Sep 29, 2019
1 parent 8b2040d commit 1d3e9ac
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/ci_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ fn setup_env(vars: Vec<(&str, &str)>) {
"DRONE_BUILD_EVENT",
"pull_request",
"DSARI",
"GITHUB_ACTIONS",
"GITHUB_EVENT_NAME",
"GITLAB_CI",
"GO_PIPELINE_LABEL",
"HUDSON_URL",
Expand Down Expand Up @@ -374,6 +376,45 @@ fn get_dsari() {
assert_eq!(info.name.unwrap(), "dsari");
}

#[test]
fn get_no_pr_github_actions() {
setup_env(vec![("GITHUB_ACTIONS", "")]);

let info = get();

assert!(info.ci);
assert!(!info.pr.unwrap());
assert_eq!(info.vendor.unwrap(), Vendor::GitHubActions);
assert_eq!(info.name.unwrap(), "GitHub Actions");
}

#[test]
fn get_no_pr2_github_actions() {
setup_env(vec![("GITHUB_ACTIONS", ""), ("GITHUB_EVENT_NAME", "test")]);

let info = get();

assert!(info.ci);
assert!(!info.pr.unwrap());
assert_eq!(info.vendor.unwrap(), Vendor::GitHubActions);
assert_eq!(info.name.unwrap(), "GitHub Actions");
}

#[test]
fn get_pr_github_actions() {
setup_env(vec![
("GITHUB_ACTIONS", ""),
("GITHUB_EVENT_NAME", "pull_request"),
]);

let info = get();

assert!(info.ci);
assert!(info.pr.unwrap());
assert_eq!(info.vendor.unwrap(), Vendor::GitHubActions);
assert_eq!(info.name.unwrap(), "GitHub Actions");
}

#[test]
fn get_gitlab_ci() {
setup_env(vec![("GITLAB_CI", "")]);
Expand Down
10 changes: 10 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ pub(crate) fn create() -> Vec<VendorConfig> {
pr_env: None,
});

config.push(VendorConfig {
name: "GitHub Actions".to_string(),
vendor: Vendor::GitHubActions,
ci_env: EnvValue::Exists("GITHUB_ACTIONS".to_string()),
pr_env: Some(EnvValue::Value(
"GITHUB_EVENT_NAME".to_string(),
"pull_request".to_string(),
)),
});

config.push(VendorConfig {
name: "GitLab CI".to_string(),
vendor: Vendor::GitLabCI,
Expand Down
2 changes: 2 additions & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub enum Vendor {
/// CI vendor
GitLabCI,
/// CI vendor
GitHubActions,
/// CI vendor
GoCD,
/// CI vendor
Hudson,
Expand Down

0 comments on commit 1d3e9ac

Please sign in to comment.