File tree Expand file tree Collapse file tree 1 file changed +36
-4
lines changed Expand file tree Collapse file tree 1 file changed +36
-4
lines changed Original file line number Diff line number Diff line change 11@file:Repository(" https://jitpack.io" )
2- @file:DependsOn(" com.github.gabrielfeo:gradle-enterprise-api-kotlin:0.4" )
2+ @file:DependsOn(" com.github.gabrielfeo:gradle-enterprise-api-kotlin:0.9" )
3+
4+ /*
5+ * Counts how many developers don't run tests on their local machine
6+ */
37
48import com.gabrielfeo.gradle.enterprise.api.*
9+ import kotlinx.coroutines.*
10+ import kotlinx.coroutines.flow.*
11+ import java.time.*
12+
13+ val oneMonthAgo = LocalDate .now()
14+ .minusMonths(1 )
15+ .atStartOfDay()
16+ .toInstant(ZoneOffset .UTC )
17+ .toEpochMilli()
18+
19+ runBlocking {
20+
21+ // Filter builds from the API
22+ val buildsByUser = api.getGradleAttributesFlow(since = oneMonthAgo)
23+ .filter { " CI" !in it.tags }
24+ .toList()
25+ .groupBy { it.environment.username }
26+ check(buildsByUser.isNotEmpty()) { " No builds found!" }
27+
28+ // Count users
29+ val userCount = buildsByUser.size
30+ val userCountDoesntRunTestsLocally = buildsByUser.count { (_, userBuilds) ->
31+ userBuilds.none { build ->
32+ build.requestedTasks.any { task -> " test" in task.lowercase() }
33+ }
34+ }
35+
36+ // Present result
37+ val percent = " %.2f" .format(userCountDoesntRunTestsLocally / userCount.toDouble() * 100 )
38+ print (" $percent % of developers don't run tests on their local machine" )
39+ shutdown()
540
6- val builds = api.getBuilds(since = 0 , maxBuilds = 3 ).execute().body()!!
7- builds.forEach {
8- println (it)
941}
You can’t perform that action at this time.
0 commit comments