Skip to content

Commit

Permalink
[Core] Replace create-meta with ci-environment
Browse files Browse the repository at this point in the history
closes: #2434
  • Loading branch information
mpkorstanje committed Dec 11, 2021
1 parent 8aa7859 commit 0448c7e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
doc string types.

### Changed
* [Core] Replaced `create-meta` dependency with `ci-environment` ([#2438](https://github.com/cucumber/cucumber-jvm/pull/2438) M.P. Korstanje)

### Deprecated

Expand Down
6 changes: 3 additions & 3 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<name>Cucumber-JVM: Bill of Materials</name>

<properties>
<create-meta.version>6.0.4</create-meta.version>
<ci-environment.version>7.0.1</ci-environment.version>
<cucumber-expressions.version>13.0.1</cucumber-expressions.version>
<datatable.version>4.1.0</datatable.version>
<html-formatter.version>17.0.0</html-formatter.version>
Expand Down Expand Up @@ -54,8 +54,8 @@
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>create-meta</artifactId>
<version>${create-meta.version}</version>
<artifactId>ci-environment</artifactId>
<version>${ci-environment.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>create-meta</artifactId>
<artifactId>ci-environment</artifactId>
</dependency>
<dependency>
<groupId>org.apiguardian</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package io.cucumber.core.runtime;

import io.cucumber.cienvironment.CiEnvironment;
import io.cucumber.core.eventbus.EventBus;
import io.cucumber.core.gherkin.Feature;
import io.cucumber.core.logging.Logger;
import io.cucumber.core.logging.LoggerFactory;
import io.cucumber.core.runner.Runner;
import io.cucumber.messages.ProtocolVersion;
import io.cucumber.messages.types.Ci;
import io.cucumber.messages.types.Envelope;
import io.cucumber.messages.types.Git;
import io.cucumber.messages.types.Meta;
import io.cucumber.messages.types.Product;
import io.cucumber.plugin.event.Result;
import io.cucumber.plugin.event.Status;
import io.cucumber.plugin.event.TestRunFinished;
Expand All @@ -18,8 +24,8 @@
import java.util.ResourceBundle;
import java.util.function.Consumer;

import static io.cucumber.cienvironment.DetectCiEnvironment.detectCiEnvironment;
import static io.cucumber.core.exception.ExceptionUtils.printStackTrace;
import static io.cucumber.createmeta.CreateMeta.createMeta;
import static io.cucumber.messages.TimeConversion.javaInstantToTimestamp;
import static java.util.Collections.singletonList;

Expand Down Expand Up @@ -48,10 +54,38 @@ public void startTestRun() {

private void emitMeta() {
Envelope envelope = new Envelope();
envelope.setMeta(createMeta("cucumber-jvm", VERSION, System.getenv()));
envelope.setMeta(createMeta());
bus.send(envelope);
}

private Meta createMeta() {
return new Meta(
ProtocolVersion.getVersion(),
new Product("cucumber-jvm", VERSION),
new Product(System.getProperty("java.vm.name"), System.getProperty("java.vm.version")),
new Product(System.getProperty("os.name"), null),
new Product(System.getProperty("os.arch"), null),
createCi());
}

private Ci createCi() {
CiEnvironment ciEnvironment = detectCiEnvironment(System.getenv());
if (ciEnvironment == null) {
return null;
}

CiEnvironment.Git git = ciEnvironment.getGit();
return new Ci(
ciEnvironment.getName(),
ciEnvironment.getUrl(),
ciEnvironment.getBuildNumber(),
new Git(
git.getRemote(),
git.getRevision(),
git.getBranch(),
git.getTag()));
}

private void emitTestRunStarted() {
log.debug(() -> "Sending run test started event");
start = bus.getInstant();
Expand Down

0 comments on commit 0448c7e

Please sign in to comment.