Skip to content

Commit 015c44b

Browse files
committed
👾 Release 0.1.2
1 parent 243a899 commit 015c44b

7 files changed

Lines changed: 41 additions & 29 deletions

File tree

ReleaseNotes.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
# Omni Reporter Commons Release Notes
22

3-
4-
#### Release 0.1.2 - Upcoming
3+
#### Release 0.1.3 - Upcoming
54

65
###### Features
76

8-
1. ~~Reports in the same folder are merged and average, (We assume thart if there are different reports in the same folder, it only means that there are different brands in there.)~~ Unfortunately, by doing so, the results may become inconsistent for reports that do not report coverage for certain files. Please make sure not to have different report brands (i.e. Clover and LCov together) for the same files. In that case, line coverage will be reported duplicate.
7+
1. ~~Reports in the same folder are merged and average, (We assume thart if there are different reports in the same folder, it only means that there are different brands in there.)~~ Unfortunately, by doing so, the results may become inconsistent for reports that do not report coverage for certain
8+
files. Please make sure not to have different report brands (i.e. Clover and LCov together) for the same files. In that case, line coverage will be reported duplicate.
99
2. Exclude report option (Since the above, may be difficult to manage in some situations, we can then use this option to exclude a report that for some reason we don't want to consider for the overall coverage calculation)
1010
3. Support for Group Coverage with Branch Coverage (mostly Coveralls)
1111
4. Source encoding gets automatically chosen unless we configure flag `failOnNoEncoding` to `true`
1212

13+
#### Release 0.1.2 - 2022/01/31
14+
15+
###### Features
16+
17+
1. Create flag `fetchBranchNameFromEnv` to fetch the branch name from environment variables
18+
1319
#### Release 0.1.1 - 2022/01/31
1420

1521
###### Bugs
@@ -22,6 +28,7 @@
2228
###### Features
2329

2430
> !! Breaking Changes !!
31+
2532
1. Support for [CoveragePy](https://coverage.readthedocs.io/)
2633
2. Support for [LCov](https://wiki.documentfoundation.org/Development/Lcov)
2734
3. Support for [Jacoco.exec](https://www.jacoco.org/jacoco/) files
@@ -31,11 +38,10 @@
3138

3239
1. Root Path fix for internal elements
3340

34-
3541
#### Release 0.0.1 - 2022/01/22
3642

37-
It was found that under certain circumstances (i.e. use of Gradle INFO level), the Http Google Clients lets client logs output go to the console. This represents a security risk because access keys to the coverage API's would be exposed in that way.
38-
This release covers that and avoids this way of credentials being exposed in the logs.
43+
It was found that under certain circumstances (i.e. use of Gradle INFO level), the Http Google Clients lets client logs output go to the console. This represents a security risk because access keys to the coverage API's would be exposed in that way. This release covers that and avoids this way of
44+
credentials being exposed in the logs.
3945

4046
#### Release 0.0.0 - 2022/01/21
4147

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.jesperancinha.plugins</groupId>
88
<artifactId>omni-coveragereporter-commons</artifactId>
9-
<version>0.1.1</version>
9+
<version>0.1.2</version>
1010

1111
<packaging>jar</packaging>
1212

@@ -36,7 +36,7 @@
3636
<connection>scm:git:git://github.com/JEsperancinhaOrg.git</connection>
3737
<developerConnection>scm:git:git://github.com/JEsperancinhaOrg.git</developerConnection>
3838
<url>https://github.com/JEsperancinhaOrg/omni-reporter-commons</url>
39-
<tag>0.1.1</tag>
39+
<tag>0.1.2</tag>
4040
</scm>
4141
<distributionManagement>
4242
<snapshotRepository>

src/main/kotlin/org/jesperancinha/plugins/omni/reporter/pipelines/Pipelines.kt

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.jesperancinha.plugins.omni.reporter.pipelines
22

33
import org.jesperancinha.plugins.omni.reporter.domain.api.CUSTOM
44
import org.jesperancinha.plugins.omni.reporter.domain.api.GITLAB
5+
import org.jesperancinha.plugins.omni.reporter.pipelines.GitHubPipeline.Companion.GITHUB_BASE_REF
56
import org.jesperancinha.plugins.omni.reporter.pipelines.GitHubPipeline.Companion.GITHUB_REPOSITORY
67
import org.jesperancinha.plugins.omni.reporter.pipelines.GitHubPipeline.Companion.GITHUB_RUN_ID
78
import org.jesperancinha.plugins.omni.reporter.pipelines.GitHubPipeline.Companion.GITHUB_RUN_NUMBER
@@ -36,9 +37,10 @@ private val allEnv = listOf(
3637
CI_EXTERNAL_PULL_REQUEST_ID,
3738
CI_EXTERNAL_PULL_REQUEST_IID,
3839

39-
//GitHubs
40+
//GitHub
4041
GITHUB_RUN_NUMBER,
4142
GITHUB_RUN_ID,
43+
GITHUB_BASE_REF,
4244
GITHUB_SERVER_URL,
4345
GITHUB_REPOSITORY
4446

@@ -54,11 +56,13 @@ interface Pipeline {
5456
val serviceJobId: String?
5557
val codecovServiceName: String?
5658
val buildUrl: String?
59+
val fetchBranchNameFromEnv: Boolean
5760
}
5861

5962
abstract class PipelineImpl(
6063
override val branchName: String? = null,
61-
override val buildUrl: String? = null
64+
override val buildUrl: String? = null,
65+
override val fetchBranchNameFromEnv: Boolean = false,
6266
) : Pipeline {
6367

6468
override fun toString() = "* System Variables\n" +
@@ -68,11 +72,13 @@ abstract class PipelineImpl(
6872
"- Service Number (Build) = $serviceNumber\n" +
6973
"- Service Job Id = $serviceJobId"
7074

75+
7176
companion object {
72-
val currentPipeline: Pipeline = when {
73-
environment[GITHUB_RUN_ID] != null -> GitHubPipeline()
74-
environment[CI_JOB_ID] != null -> GitLabPipeline()
75-
else -> LocalPipeline()
77+
78+
fun currentPipeline(fetchBranchNameFromEnv: Boolean): Pipeline = when {
79+
environment[GITHUB_RUN_ID] != null -> GitHubPipeline(fetchBranchNameFromEnv = fetchBranchNameFromEnv)
80+
environment[CI_JOB_ID] != null -> GitLabPipeline(fetchBranchNameFromEnv = fetchBranchNameFromEnv)
81+
else -> LocalPipeline(fetchBranchNameFromEnv = fetchBranchNameFromEnv)
7682
}.also {
7783
it.toString().lines().forEach { logLine -> logger.info(logLine) }
7884
}
@@ -104,39 +110,37 @@ class GitHubPipeline(
104110
override val serviceJobId: String? = findServiceJobId {
105111
findSystemVariableValue(GITHUB_RUN_ID)
106112
},
107-
override val branchRef: String? = null,
113+
override val fetchBranchNameFromEnv: Boolean,
114+
override val branchRef: String? = if (fetchBranchNameFromEnv) findSystemVariableValue(GITHUB_BASE_REF) else null,
108115
override val codecovServiceName: String? = CUSTOM,
109116
override val buildUrl: String? = "${findSystemVariableValue(GITHUB_SERVER_URL)}/${
110117
findSystemVariableValue(
111118
GITHUB_REPOSITORY
112119
)
113-
}/actions/runs/${findSystemVariableValue(GITHUB_RUN_ID)}"
120+
}/actions/runs/${findSystemVariableValue(GITHUB_RUN_ID)}",
114121
) : PipelineImpl() {
115122
companion object {
116123
const val GITHUB_RUN_NUMBER = "GITHUB_RUN_NUMBER"
117124
const val GITHUB_RUN_ID = "GITHUB_RUN_ID"
125+
const val GITHUB_BASE_REF = "GITHUB_BASE_REF"
118126
const val GITHUB_SERVER_URL = "GITHUB_SERVER_URL"
119127
const val GITHUB_REPOSITORY = "GITHUB_REPOSITORY"
120128
}
121129
}
122130

123131
class GitLabPipeline(
124132
override val serviceName: String = findServiceName { "gitlab-ci" },
125-
override val serviceNumber: String? = findServiceNumber {
126-
findSystemVariableValue(CI_CONCURRENT_ID)
127-
},
128-
override val serviceJobId: String? = findServiceJobId {
129-
findSystemVariableValue(CI_JOB_ID)
130-
},
131-
override val branchRef: String? = null,
133+
override val serviceNumber: String? = findServiceNumber { findSystemVariableValue(CI_CONCURRENT_ID) },
134+
override val serviceJobId: String? = findServiceJobId { findSystemVariableValue(CI_JOB_ID) },
135+
override val fetchBranchNameFromEnv: Boolean,
136+
override val branchRef: String? = if (fetchBranchNameFromEnv) findSystemVariableValue(CI_COMMIT_REF_NAME) else null,
132137
override val branchName: String? = findSystemVariableValue(CI_COMMIT_REF_NAME),
133138
override val codecovServiceName: String? = GITLAB,
134139
override val buildUrl: String? = "${findSystemVariableValue(CI_PROJECT_URL)}/-/pipelines/${
135140
findSystemVariableValue(
136141
CI_PIPELINE_ID
137142
)
138143
}"
139-
140144
) : PipelineImpl() {
141145
companion object {
142146
const val CI_CONCURRENT_ID = "CI_CONCURRENT_ID"
@@ -155,6 +159,7 @@ class LocalPipeline(
155159
override val serviceJobId: String? = findServiceJobId { null },
156160
override val branchRef: String? = null,
157161
override val codecovServiceName: String? = CUSTOM,
162+
override val fetchBranchNameFromEnv: Boolean,
158163
) : PipelineImpl() {
159164

160165
companion object {

src/test/kotlin/org/jesperancinha/plugins/omni/reporter/domain/CodacyCoverallsSourceFileTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ internal class CodacyCoverallsSourceFileTest {
5050
val root = resource.toURI().toPath().toFile()
5151
JacocoParserToCodacy(
5252
"",
53-
pipeline = GitHubPipeline(),
53+
pipeline = GitHubPipeline(fetchBranchNameFromEnv = false),
5454
root = root,
5555
failOnUnknown = false,
5656
language = KOTLIN

src/test/kotlin/org/jesperancinha/plugins/omni/reporter/domain/CoverallsClientTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal class CoverallsClientTest {
2323
val jacocoReport = resource.toURI().toPath().toFile()
2424
jacocoReport.shouldNotBeNull()
2525
val jacocoParser = ReportingParserToCoveralls(
26-
token = "token", LocalPipeline(), root,
26+
token = "token", LocalPipeline(fetchBranchNameFromEnv = false), root,
2727
failOnUnknown = false,
2828
includeBranchCoverage = false,
2929
useCoverallsCount = false

src/test/kotlin/org/jesperancinha/plugins/omni/reporter/parsers/JacocoParserTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import java.io.File
1414
internal class JacocoParserTest {
1515
private val jacocoParser = ReportingParserToCoveralls(
1616
"token",
17-
LocalPipeline(),
17+
LocalPipeline(fetchBranchNameFromEnv = false),
1818
root,
1919
failOnUnknown = false,
2020
includeBranchCoverage = false,
@@ -81,7 +81,8 @@ internal class JacocoParserTest {
8181

8282
jacocoParser.parseInput(OmniJacocoFileAdapter(jacocoResult, false, root, root), listOf(root))
8383

84-
val sourceFiles = jacocoParser.parseInput(OmniJacocoFileAdapter(jacocoResult, false, root, root)
84+
val sourceFiles = jacocoParser.parseInput(
85+
OmniJacocoFileAdapter(jacocoResult, false, root, root)
8586
).sourceFiles
8687

8788
sourceFiles.shouldNotBeNull()

src/test/kotlin/org/jesperancinha/plugins/omni/reporter/transformers/AllParserToCodecovTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal class AllParserToCodecovTest {
3030

3131
val parseInput = AllParserToCodecov(
3232
token = "token",
33-
pipeline = GitLabPipeline(),
33+
pipeline = GitLabPipeline(fetchBranchNameFromEnv = false),
3434
root = root,
3535
failOnUnknown = false
3636
).parseInput(

0 commit comments

Comments
 (0)