Skip to content

Commit

Permalink
Add support for Drone CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jvia committed Apr 2, 2021
1 parent ca892b6 commit bda18d9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@ class ServiceInfoFactory {
'commit_sha' : env.get('GITHUB_SHA')
]
)
} else if (envIsDrone(env)) {
return new ServiceInfo(
serviceName: 'drone',
serviceNumber: env.get('DRONE_BUILD_NUMBER'),
serviceBranch: env.get('DRONE_BRANCH'),
repoToken: env.get('COVERALLS_REPO_TOKEN'),
servicePullRequest: env.get('DRONE_PULL_REQUEST'),
environment: [
'branch' : env.get('DRONE_BRANCH'),
'commit_sha': env.get('DRONE_COMMIT_SHA')]
)
} else {
return new ServiceInfo(
serviceName: env['CI_NAME'] ?: 'other',
Expand Down Expand Up @@ -182,6 +193,11 @@ class ServiceInfoFactory {
env.get('GITHUB_ACTIONS') != null
}

private static boolean envIsDrone(Map<String, String> env) {
env.get('DRONE') != null
}


private static boolean repoTokenIsSet(Map<String, String> env) {
env.get('COVERALLS_REPO_TOKEN') != null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,26 @@ class ServiceInfoFactoryTest {
assertEquals '8eee24aac46ace5cd156d351062dfce68e57e49e', serviceInfo.environment['commit_sha']
}

@Test
void testCreateFromEnvVarDrone() {
// test the case of drone
ServiceInfo serviceInfo = ServiceInfoFactory.createFromEnvVar(
DRONE: "true",
DRONE_BUILD_NUMBER: "123456789",
DRONE_BRANCH: "branchX",
DRONE_PULL_REQUEST: "11",
DRONE_COMMIT_SHA: "231asdfadsf424",
COVERALLS_REPO_TOKEN: 'ABCDEF'
)

assertEquals 'drone', serviceInfo.serviceName
assertEquals '123456789', serviceInfo.serviceNumber
assertEquals 'branchX', serviceInfo.serviceBranch
assertEquals 'ABCDEF', serviceInfo.repoToken
assertEquals '11', serviceInfo.servicePullRequest

assertEquals 'branchX', serviceInfo.environment['branch']
assertEquals '231asdfadsf424', serviceInfo.environment['commit_sha']
}

}

0 comments on commit bda18d9

Please sign in to comment.