Skip to content

Commit 2e21126

Browse files
committed
Add JUnit XML
1 parent 1c14a48 commit 2e21126

37 files changed

+1848
-0
lines changed

.github/renovate.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"github>cucumber/renovate-config"
5+
]
6+
}

.github/workflows/release-github.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Release GitHub
2+
3+
on:
4+
push:
5+
branches: [release/*]
6+
7+
jobs:
8+
create-github-release:
9+
name: Create GitHub Release and Git tag
10+
runs-on: ubuntu-latest
11+
environment: Release
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: cucumber/[email protected]
17+
with:
18+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-mvn.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Release Maven
2+
3+
on:
4+
push:
5+
branches: [release/*]
6+
7+
jobs:
8+
publish-mvn:
9+
name: Publish Maven Package
10+
runs-on: ubuntu-latest
11+
environment: Release
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-java@v4
15+
with:
16+
distribution: 'temurin'
17+
java-version: '21'
18+
cache: 'maven'
19+
- uses: cucumber/[email protected]
20+
with:
21+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
22+
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
23+
nexus-username: cukebot
24+
nexus-password: ${{ secrets.SONATYPE_PASSWORD }}
25+
working-directory: java

.github/workflows/test-java.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: test-java
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- renovate/**
8+
pull_request:
9+
branches:
10+
- main
11+
workflow_call:
12+
13+
jobs:
14+
test-java:
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os:
20+
- ubuntu-latest
21+
java: [ "21"]
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- uses: actions/setup-java@v4
27+
with:
28+
distribution: "zulu"
29+
java-version: ${{ matrix.java }}
30+
cache: "maven"
31+
32+
- run: mvn verify
33+
working-directory: java
34+

.github/workflows/test-testdata.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: test-testdata
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test-testdata:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
cache: 'npm'
22+
cache-dependency-path: testdata/package-lock.json
23+
24+
- run: npm ci
25+
working-directory: testdata
26+
27+
- name: check repository is not dirty
28+
run: "[[ -z $(git status --porcelain) ]]"
29+
30+
- name: show diff
31+
if: ${{ failure() }}
32+
run: git status --porcelain

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea/
2+
*.iml
3+
target/
4+
pom.xml.versionsBackup

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
# messages-cli
22
Commandline interface to work with Cucumber Messages
3+
4+
5+
## TODO:
6+
7+
- Support TestNG XML
8+
- Support Gherkin
9+
- Publish as a CLI tool
10+
- Write README.

java/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Test droppings
2+
minimal.feature.xml

java/pom.xml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>io.cucumber</groupId>
8+
<artifactId>cucumber-parent</artifactId>
9+
<version>4.2.0</version>
10+
</parent>
11+
12+
<artifactId>messages-cli</artifactId>
13+
<version>0.5.1-SNAPSHOT</version>
14+
<packaging>jar</packaging>
15+
<name>Messages CLI</name>
16+
<description>A commandline interface to work with Cucumber Messages</description>
17+
<url>https://github.com/cucumber/messages-cli</url>
18+
19+
<properties>
20+
<java.version>21</java.version>
21+
<project.build.outputTimestamp>1719064372</project.build.outputTimestamp>
22+
<project.Automatic-Module-Name>io.cucumber.messages.cli</project.Automatic-Module-Name>
23+
</properties>
24+
25+
<scm>
26+
<connection>scm:git:git://github.com/cucumber/messages-cli.git</connection>
27+
<developerConnection>scm:git:[email protected]:cucumber/messages-cli.git</developerConnection>
28+
<url>git://github.com/cucumber/messages-cli.git</url>
29+
<tag>HEAD</tag>
30+
</scm>
31+
32+
<dependencyManagement>
33+
<dependencies>
34+
<dependency>
35+
<groupId>org.junit</groupId>
36+
<artifactId>junit-bom</artifactId>
37+
<version>5.11.3</version>
38+
<type>pom</type>
39+
<scope>import</scope>
40+
</dependency>
41+
42+
<dependency>
43+
<groupId>com.fasterxml.jackson</groupId>
44+
<artifactId>jackson-bom</artifactId>
45+
<version>2.18.0</version>
46+
<type>pom</type>
47+
<scope>import</scope>
48+
</dependency>
49+
</dependencies>
50+
</dependencyManagement>
51+
52+
<dependencies>
53+
<dependency>
54+
<groupId>info.picocli</groupId>
55+
<artifactId>picocli</artifactId>
56+
<version>4.7.6</version>
57+
</dependency>
58+
59+
<dependency>
60+
<groupId>io.cucumber</groupId>
61+
<artifactId>junit-xml-formatter</artifactId>
62+
<version>0.5.0</version>
63+
</dependency>
64+
<dependency>
65+
<groupId>com.fasterxml.jackson.core</groupId>
66+
<artifactId>jackson-databind</artifactId>
67+
</dependency>
68+
69+
<dependency>
70+
<groupId>com.fasterxml.jackson.datatype</groupId>
71+
<artifactId>jackson-datatype-jdk8</artifactId>
72+
</dependency>
73+
<dependency>
74+
<groupId>com.fasterxml.jackson.module</groupId>
75+
<artifactId>jackson-module-parameter-names</artifactId>
76+
</dependency>
77+
78+
<dependency>
79+
<groupId>org.assertj</groupId>
80+
<artifactId>assertj-core</artifactId>
81+
<version>3.26.3</version>
82+
<scope>test</scope>
83+
</dependency>
84+
85+
<dependency>
86+
<groupId>org.junit.jupiter</groupId>
87+
<artifactId>junit-jupiter-engine</artifactId>
88+
<scope>test</scope>
89+
</dependency>
90+
91+
<dependency>
92+
<groupId>org.junit.jupiter</groupId>
93+
<artifactId>junit-jupiter-params</artifactId>
94+
<scope>test</scope>
95+
</dependency>
96+
</dependencies>
97+
98+
<build>
99+
<plugins>
100+
<plugin>
101+
<groupId>org.apache.maven.plugins</groupId>
102+
<artifactId>maven-jar-plugin</artifactId>
103+
<configuration>
104+
<archive>
105+
<manifest>
106+
<mainClass>io.cucumber.messages.cli.Main</mainClass>
107+
</manifest>
108+
</archive>
109+
</configuration>
110+
</plugin>
111+
</plugins>
112+
</build>
113+
</project>
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
package io.cucumber.messages.cli;
2+
3+
import picocli.CommandLine;
4+
import picocli.CommandLine.Model.CommandSpec;
5+
6+
import java.io.IOException;
7+
import java.io.InputStream;
8+
import java.io.OutputStream;
9+
import java.nio.file.Files;
10+
import java.nio.file.Path;
11+
import java.util.function.BiFunction;
12+
13+
import static java.nio.file.Files.newOutputStream;
14+
import static java.nio.file.StandardOpenOption.CREATE;
15+
import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
16+
import static java.util.Objects.requireNonNull;
17+
18+
final class CommonOptions {
19+
private final CommandSpec spec;
20+
private final Path source;
21+
private final Path output;
22+
private final BiFunction<String, Integer, String> fileNameGenerator;
23+
24+
25+
CommonOptions(CommandSpec spec, Path source, Path output, BiFunction<String, Integer, String> fileNameGenerator) {
26+
this.spec = requireNonNull(spec);
27+
this.source = requireNonNull(source);
28+
this.output = output;
29+
this.fileNameGenerator = requireNonNull(fileNameGenerator);
30+
31+
if (isSourceSystemIn()) {
32+
if (isDestinationDirectory()) {
33+
throw new CommandLine.ParameterException(
34+
spec.commandLine(),
35+
("Invalid value '%s' for option '--output': When " +
36+
"reading from standard input, output can not " +
37+
"be a directory").formatted(output)
38+
);
39+
}
40+
}
41+
42+
}
43+
44+
private boolean isSourceSystemIn() {
45+
var fileName = source.getFileName();
46+
return fileName != null && fileName.toString().equals("-");
47+
}
48+
49+
private boolean isDestinationDirectory() {
50+
return output != null && Files.isDirectory(output);
51+
}
52+
53+
OutputStream outputPrintWriter() {
54+
if (output == null) {
55+
return System.out;
56+
}
57+
58+
Path path = outputPath();
59+
try {
60+
return newOutputStream(path, CREATE, TRUNCATE_EXISTING);
61+
} catch (IOException e) {
62+
throw new CommandLine.ParameterException(
63+
spec.commandLine(),
64+
("Invalid value '%s' for option '--output': Could not " +
65+
"write to '%s'"
66+
).formatted(output, path), e);
67+
}
68+
}
69+
70+
private Path outputPath() {
71+
if (!isDestinationDirectory()) {
72+
return output;
73+
}
74+
75+
// Given a directory, decide on a file name
76+
var fileName = source.getFileName().toString();
77+
var index = fileName.lastIndexOf(".");
78+
if (index >= 0) {
79+
fileName = fileName.substring(0, index);
80+
}
81+
var candidate = output.resolve(fileName + ".xml");
82+
83+
// Avoid overwriting existing files when we decided the file name.
84+
var counter = 1;
85+
while (Files.exists(candidate)) {
86+
candidate = output.resolve(fileNameGenerator.apply(fileName, counter++));
87+
}
88+
return candidate;
89+
}
90+
91+
InputStream sourceInputStream() {
92+
if (isSourceSystemIn()) {
93+
return System.in;
94+
}
95+
try {
96+
return Files.newInputStream(source);
97+
} catch (IOException e) {
98+
throw new CommandLine.ParameterException(spec.commandLine(), "Invalid argument, could not read '%s'".formatted(source), e);
99+
}
100+
}
101+
}

0 commit comments

Comments
 (0)