Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace old GitHub action with updated one. #247

Merged
merged 9 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'GitHub CI'

on:
push:
branches:
- master
- main
pull_request:

jobs:
build:

strategy:
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
jdk: [17, 21]

runs-on: ${{ matrix.platform }}
name: on ${{ matrix.platform }} with JDK ${{ matrix.jdk }}

steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.jdk }}
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '${{ matrix.jdk }}'
check-latest: true
cache: 'maven'
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6
- name: Build with Maven
env:
BROWSER: chrome-container
run: mvn -V --color always -ntp clean verify --file pom.xml '-Djenkins.test.timeout=5000' '-Dgpg.skip'
43 changes: 0 additions & 43 deletions .github/workflows/maven.yml

This file was deleted.

13 changes: 9 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
def configurations = [
[ platform: "linux", jdk: "11" ],
[ platform: "windows", jdk: "11" ]
[ platform: "linux", jdk: "21" ],
[ platform: "windows", jdk: "17" ]
]

buildPlugin(failFast: false, configurations: configurations,
def params = [
failFast: false,
configurations: configurations,
checkstyle: [qualityGates: [[threshold: 1, type: 'NEW', unstable: true]]],
pmd: [qualityGates: [[threshold: 1, type: 'NEW', unstable: true]]] )
spotbugs: [qualityGates: [[threshold: 1, type: 'NEW', unstable: true]]]
]

buildPlugin(params)
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private Pair<String, String> processStageOrBranchRow(final FlowGraphTable.Row ro
if (row.getNode().isActive()) {
nodeTextBuilder.append(" *(running)*");
}
else if (row.getDurationMillis() > 0) {
else {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timja I removed the guard as FlowGraphTable.Row correctly handles the case where duration = 0. This makes the test run on all platforms now.

nodeTextBuilder.append(String.format(" *(%s)*", row.getDurationString()));
}
nodeTextBuilder.append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,20 @@
*/
@SuppressWarnings({"PMD.AddEmptyString", "checkstyle:LambdaBodyLength"})
@SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
class BuildStatusChecksPublisherITest extends IntegrationTestWithJenkinsPerTest {

private CapturingChecksPublisher.Factory getFactory() {
return getJenkins().getInstance().getExtensionList(ChecksPublisherFactory.class)
.stream()
.filter(f -> f instanceof CapturingChecksPublisher.Factory)
.map(f -> (CapturingChecksPublisher.Factory) f)
.findAny()
.orElseThrow(() -> new AssertionError("No CapturingChecksPublisher registered as @TestExtension?"));
}

/**
* Clean captured checks between tests.
*/
@AfterEach

Check warning on line 47 in src/test/java/io/jenkins/plugins/checks/status/BuildStatusChecksPublisherITest.java

View check run for this annotation

ci.jenkins.io / CPD

CPD

LOW: Found duplicated code.
Raw output
<pre><code>class BuildStatusChecksPublisherITest extends IntegrationTestWithJenkinsPerTest { private CapturingChecksPublisher.Factory getFactory() { return getJenkins().getInstance().getExtensionList(ChecksPublisherFactory.class) .stream() .filter(f -&gt; f instanceof CapturingChecksPublisher.Factory) .map(f -&gt; (CapturingChecksPublisher.Factory) f) .findAny() .orElseThrow(() -&gt; new AssertionError(&#34;No CapturingChecksPublisher registered as &#64;TestExtension?&#34;)); } /** * Clean captured checks between tests. */ &#64;AfterEach</code></pre>
public void clearChecks() {
getFactory().getPublishedChecks().clear();
}
Expand Down Expand Up @@ -100,19 +99,19 @@

ChecksDetails details = getFactory().getPublishedChecks().get(0);

assertThat(details.getName()).isPresent().get().isEqualTo("Test Status");
assertThat(details.getName()).contains("Test Status");
assertThat(details.getStatus()).isEqualTo(ChecksStatus.QUEUED);
assertThat(details.getConclusion()).isEqualTo(ChecksConclusion.NONE);

details = getFactory().getPublishedChecks().get(1);

assertThat(details.getName()).isPresent().get().isEqualTo("Test Status");
assertThat(details.getName()).contains("Test Status");
assertThat(details.getStatus()).isEqualTo(ChecksStatus.IN_PROGRESS);
assertThat(details.getConclusion()).isEqualTo(ChecksConclusion.NONE);

details = getFactory().getPublishedChecks().get(2);

assertThat(details.getName()).isPresent().get().isEqualTo("Test Status");
assertThat(details.getName()).contains("Test Status");
assertThat(details.getStatus()).isEqualTo(ChecksStatus.COMPLETED);
assertThat(details.getConclusion()).isEqualTo(ChecksConclusion.SUCCESS);
}
Expand Down Expand Up @@ -156,34 +155,34 @@
ChecksDetails details = checksDetails.get(0);
assertThat(details.getStatus()).isEqualTo(ChecksStatus.QUEUED);
assertThat(details.getConclusion()).isEqualTo(ChecksConclusion.NONE);
assertThat(details.getName()).isPresent().contains("Test Status");
assertThat(details.getName()).contains("Test Status");
assertThat(details.getOutput()).isNotPresent();

// Details 1, first stage
details = checksDetails.get(1);
assertThat(details.getStatus()).isEqualTo(ChecksStatus.IN_PROGRESS);
assertThat(details.getConclusion()).isEqualTo(ChecksConclusion.NONE);
assertThat(details.getOutput()).isPresent().get().satisfies(output -> {
assertThat(output.getTitle()).isPresent().contains("In progress");
assertThat(output.getTitle()).contains("In progress");
assertThat(output.getSummary()).isPresent().get().satisfies(StringUtils::isBlank);
assertThat(output.getText()).isPresent().get().asString().contains("* Simple Stage *(running)*");

Check warning on line 168 in src/test/java/io/jenkins/plugins/checks/status/BuildStatusChecksPublisherITest.java

View check run for this annotation

ci.jenkins.io / CPD

CPD

LOW: Found duplicated code.
Raw output
<pre><code>assertThat(details.getConclusion()).isEqualTo(ChecksConclusion.NONE); assertThat(details.getOutput()).isPresent().get().satisfies(output -&gt; { assertThat(output.getTitle()).contains(&#34;In progress&#34;); assertThat(output.getSummary()).isPresent().get().satisfies(StringUtils::isBlank); assertThat(output.getText()).isPresent().get().asString().contains(&#34;* Simple Stage *(running)*&#34;);</code></pre>
});

// Details 2, first stage finished, parallel started
details = checksDetails.get(2);
assertThat(details.getOutput()).isPresent().get().satisfies(output -> {
assertThat(output.getTitle()).contains("In progress");
assertThat(output.getSummary()).isPresent().get().satisfies(StringUtils::isBlank);
assertThat(output.getText()).isPresent().get().satisfies(text -> {

Check warning on line 176 in src/test/java/io/jenkins/plugins/checks/status/BuildStatusChecksPublisherITest.java

View check run for this annotation

ci.jenkins.io / CPD

CPD

LOW: Found duplicated code.
Raw output
<pre><code>assertThat(details.getConclusion()).isEqualTo(ChecksConclusion.NONE); assertThat(details.getOutput()).isPresent().get().satisfies(output -&gt; { assertThat(output.getTitle()).contains(&#34;In progress&#34;); assertThat(output.getSummary()).isPresent().get().satisfies(StringUtils::isBlank); assertThat(output.getText()).isPresent().get().asString().contains(&#34;* Simple Stage *(running)*&#34;);</code></pre>
assertThat(output.getTitle()).isPresent().contains("In progress");
assertThat(text).doesNotContain("* Simple Stage *(running)*");
assertThat(text).contains("* Simple Stage", "* In parallel *(running)*");
assertThat(text).matches(Pattern.compile(".*\\* Simple Stage \\*\\([^)]+\\)\\*.*", Pattern.DOTALL));
assertThat(text).contains(" * In parallel *(running)*");
});
});

// Details 6, p1s1 has finished and emitted unstable
details = checksDetails.get(6);
assertThat(details.getOutput()).isPresent().get().satisfies(output -> {
assertThat(output.getTitle()).isPresent().contains("In parallel/p1/p1s1: warning in 'unstable' step");
assertThat(output.getTitle()).contains("In parallel/p1/p1s1: warning in 'unstable' step");
assertThat(output.getSummary()).isPresent().get().asString().isEqualToIgnoringNewLines(""
+ "### `In parallel / p1 / p1s1 / Set stage result to unstable`\n"
+ "Warning in `unstable` step, with arguments `something went wrong`.\n"
Expand All @@ -192,21 +191,21 @@
+ "```\n"
+ "\n");
assertThat(output.getText()).isPresent().get().asString().matches(Pattern.compile(".*"
+ " \\* Simple Stage \\*\\([^)]+\\)\\*\n"
+ " \\* In parallel \\*\\(running\\)\\*\n"
+ " \\* p1 \\*\\(running\\)\\*\n"
+ " \\* p1s1 \\*\\([^)]+\\)\\*\n"
+ " \\*\\*Unstable\\*\\*: \\*something went wrong\\*\n"
+ " \\* p1s2 \\*\\(running\\)\\*\n"
+ " \\* p2 \\*\\([^)]+\\)\\*\n.*", Pattern.DOTALL));
+ " \\* Simple Stage \\*\\([^)]+\\)\\*\\s+"
+ " \\* In parallel \\*\\(running\\)\\*\\s+"
+ " \\* p1 \\*\\(running\\)\\*\\s+"
+ " \\* p1s1 \\*\\([^)]+\\)\\*\\s+"
+ " \\*\\*Unstable\\*\\*: \\*something went wrong\\*\\s+"
+ " \\* p1s2 \\*\\(running\\)\\*\\s+"
+ " \\* p2 \\*\\([^)]+\\)\\*\\s+.*", Pattern.DOTALL));
});

// Details 8, final checks
details = checksDetails.get(8);
assertThat(details.getStatus()).isEqualTo(ChecksStatus.COMPLETED);
assertThat(details.getConclusion()).isEqualTo(ChecksConclusion.FAILURE);
assertThat(details.getOutput()).isPresent().get().satisfies(output -> {
assertThat(output.getTitle()).isPresent().get().isEqualTo("Fails: error in 'error' step");
assertThat(output.getTitle()).contains("Fails: error in 'error' step");
assertThat(output.getSummary()).isPresent().get().asString().matches(Pattern.compile(".*"
+ "### `In parallel / p1 / p1s1 / Set stage result to unstable`\\s+"
+ "Warning in `unstable` step, with arguments `something went wrong`\\.\\s+"
Expand All @@ -218,16 +217,16 @@
+ "```\\s+"
+ "a fatal error occurs\\s+"
+ "```\\s+", Pattern.DOTALL));
assertThat(output.getText()).isPresent().asString().matches(Pattern.compile(".*"
+ " \\* Simple Stage \\*\\([^)]+\\)\\*\n"
+ " \\* In parallel \\*\\([^)]+\\)\\*\n"
+ " \\* p1 \\*\\([^)]+\\)\\*\n"
+ " \\* p1s1 \\*\\([^)]+\\)\\*\n"
+ " \\*\\*Unstable\\*\\*: \\*something went wrong\\*\n"
+ " \\* p1s2 \\*\\([^)]+\\)\\*\n"
+ " \\* p2 \\*\\([^)]+\\)\\*\n"
+ " \\* Fails \\*\\([^)]+\\)\\*\n"
+ " \\*\\*Error\\*\\*: \\*a fatal error occurs\\*\n.*",
assertThat(output.getText()).isPresent().get().asString().matches(Pattern.compile(".*"
+ " \\* Simple Stage \\*\\([^)]+\\)\\*\\s+"
+ " \\* In parallel \\*\\([^)]+\\)\\*\\s+"
+ " \\* p1 \\*\\([^)]+\\)\\*\\s+"
+ " \\* p1s1 \\*\\([^)]+\\)\\*\\s+"
+ " \\*\\*Unstable\\*\\*: \\*something went wrong\\*\\s+"
+ " \\* p1s2 \\*\\([^)]+\\)\\*\\s+"
+ " \\* p2 \\*\\([^)]+\\)\\*\\s+"
+ " \\* Fails \\*\\([^)]+\\)\\*\\s+"
+ " \\*\\*Error\\*\\*: \\*a fatal error occurs\\*\\s+.*",
Pattern.DOTALL));
});
}
Expand Down Expand Up @@ -271,7 +270,7 @@
assertThat(details.getStatus()).isEqualTo(ChecksStatus.COMPLETED);
assertThat(details.getConclusion()).isEqualTo(ChecksConclusion.FAILURE);
assertThat(details.getOutput()).isPresent().get().satisfies(output -> {
assertThat(output.getTitle()).isPresent().get().isEqualTo("Fails: error in 'archiveArtifacts' step");
assertThat(output.getTitle()).contains("Fails: error in 'archiveArtifacts' step");
assertThat(output.getSummary()).isPresent().get().asString().matches(Pattern.compile(".*"
+ "### `In parallel / p1 / p1s1 / Set stage result to unstable`\\s+"
+ "Warning in `unstable` step, with arguments `something went wrong`\\.\\s+"
Expand All @@ -284,15 +283,15 @@
+ "No artifacts found that match the file pattern \"oh dear\"\\. Configuration error\\?\\s+"
+ "```\\s+", Pattern.DOTALL));
assertThat(output.getText()).isPresent().asString().matches(Pattern.compile(".*"
+ " \\* Simple Stage \\*\\([^)]+\\)\\*\n"
+ " \\* In parallel \\*\\([^)]+\\)\\*\n"
+ " \\* p1 \\*\\([^)]+\\)\\*\n"
+ " \\* p1s1 \\*\\([^)]+\\)\\*\n"
+ " \\*\\*Unstable\\*\\*: \\*something went wrong\\*\n"
+ " \\* p1s2 \\*\\([^)]+\\)\\*\n"
+ " \\* p2 \\*\\([^)]+\\)\\*\n"
+ " \\* Fails \\*\\([^)]+\\)\\*\n"
+ " \\*\\*Error\\*\\*: \\*No artifacts found that match the file pattern \"oh dear\". Configuration error\\?\\*\n.*",
+ " \\* Simple Stage \\*\\([^)]+\\)\\*\\s+"
+ " \\* In parallel \\*\\([^)]+\\)\\*\\s+"
+ " \\* p1 \\*\\([^)]+\\)\\*\\s+"
+ " \\* p1s1 \\*\\([^)]+\\)\\*\\s+"
+ " \\*\\*Unstable\\*\\*: \\*something went wrong\\*\\s+"
+ " \\* p1s2 \\*\\([^)]+\\)\\*\\s+"
+ " \\* p2 \\*\\([^)]+\\)\\*\\s+"
+ " \\* Fails \\*\\([^)]+\\)\\*\\s+"
+ " \\*\\*Error\\*\\*: \\*No artifacts found that match the file pattern \"oh dear\". Configuration error\\?\\*\\s+.*",
Pattern.DOTALL));
});
}
Expand All @@ -317,7 +316,7 @@
List<ChecksDetails> checksDetails = getFactory().getPublishedChecks();

ChecksDetails details = checksDetails.get(1);
assertThat(details.getOutput()).isPresent().get().satisfies(output -> assertThat(output.getTitle()).isPresent().get().isEqualTo("Success"));
assertThat(details.getOutput()).isPresent().get().satisfies(output -> assertThat(output.getTitle()).contains("Success"));
}

/**
Expand Down
Loading