Skip to content

Commit

Permalink
Refresh plugin for October 2024 (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Oct 9, 2024
1 parent fd93a91 commit 207e11b
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 50 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
---
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.8</version>
</extension>
</extensions>
2 changes: 2 additions & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-Pconsume-incrementals
-Pmight-produce-incrementals
5 changes: 4 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env groovy

/* `buildPlugin` step provided by: https://github.com/jenkins-infra/pipeline-library */
buildPlugin()
buildPlugin(useContainerAgent: true, configurations: [
[platform: 'linux', jdk: 21],
[platform: 'windows', jdk: 17]
])
56 changes: 29 additions & 27 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.23</version>
<version>4.88</version>
<relativePath />
</parent>

<artifactId>sectioned-view</artifactId>
<packaging>hpi</packaging>
<name>Sectioned View Plugin</name>
<version>1.28-SNAPSHOT</version>
<version>${revision}${changelist}</version>
<url>http://wiki.jenkins-ci.org/display/JENKINS/Sectioned+View+Plugin</url>
<developers>
<developer>
Expand All @@ -28,10 +30,10 @@
</licenses>

<scm>
<connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
<developerConnection>scm:git:[email protected]:jenkinsci/${project.artifactId}-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
<tag>HEAD</tag>
<connection>scm:git:https://github.com/${gitHubRepo}.git</connection>
<developerConnection>scm:git:[email protected]:${gitHubRepo}.git</developerConnection>
<url>https://github.com/${gitHubRepo}</url>
<tag>${scmTag}</tag>
</scm>

<repositories>
Expand All @@ -48,54 +50,54 @@
</pluginRepositories>

<properties>
<jenkins.version>1.580.3</jenkins.version>
<java.version>6</java.version>
<findbugs.failOnError>false</findbugs.failOnError>
<revision>1.28</revision>
<changelist>-SNAPSHOT</changelist>
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.440</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<!-- TODO fix existing violations -->
<spotbugs.threshold>High</spotbugs.threshold>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-${jenkins.baseline}.x</artifactId>
<version>3435.v238d66a_043fb_</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.2.1</version>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
<version>1.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>antisamy-markup-formatter</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<optional>true</optional>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>cloudbees-folder</artifactId>
<version>5.18</version>
</dependency>

</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package hudson.plugins.sectioned_view;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.DescriptorExtensionList;
import hudson.Extension;
import hudson.model.Descriptor;
Expand Down Expand Up @@ -65,6 +66,7 @@ public Iterable<ListViewColumn> getColumns() {
return columns;
}

@SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "TODO needs triage")
public static List<ListViewColumn> getDefaultColumns() {
ArrayList<ListViewColumn> r = new ArrayList<ListViewColumn>();
DescriptorExtensionList<ListViewColumn, Descriptor<ListViewColumn>> all = ListViewColumn.all();
Expand Down
31 changes: 14 additions & 17 deletions src/test/java/hudson/plugins/sectioned_view/SectionedViewTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,33 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import com.gargoylesoftware.htmlunit.html.HtmlButton;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.markup.RawHtmlMarkupFormatter;
import hudson.model.Descriptor;
import hudson.model.FreeStyleProject;
import hudson.model.ItemGroup;
import hudson.util.DescribableList;
import java.util.Arrays;
import org.htmlunit.html.HtmlButton;
import org.htmlunit.html.HtmlForm;
import org.htmlunit.html.HtmlPage;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;

import java.util.Arrays;
import java.util.Collections;

public class SectionedViewTest {

public @Rule JenkinsRule j = new JenkinsRule();

@Test @Issue("JENKINS-37174")
public void doNotEnumerateItemsRepeatedly() throws Exception {
j.createFreeStyleProject("show");
j.createFreeStyleProject("hide");
FreeStyleProject show = j.createFreeStyleProject();
FreeStyleProject hide = j.createFreeStyleProject();

SectionedView sw = new SectionedView("sw");
j.jenkins.addView(sw);
Expand All @@ -46,18 +43,18 @@ public void doNotEnumerateItemsRepeatedly() throws Exception {
sections.add(lvs);
sections.add(trvs);
for (SectionedViewSection section : sections) {
section.setIncludeRegex(".*show.*");
section.setIncludeRegex(".*" + show.getName() + ".*");
}

JenkinsRule.WebClient wc = j.createWebClient();
String content = wc.getPage(j.jenkins).getWebResponse().getContentAsString();
assertThat(content, containsString("show"));
assertThat(content, containsString("hide"));
assertThat(content, containsString(show.getName()));
assertThat(content, containsString(hide.getName()));

content = wc.getPage(sw).getWebResponse().getContentAsString();

assertThat(content, containsString("show"));
assertThat(content, not(containsString("hide")));
assertThat(content, containsString(show.getName()));
assertThat(content, not(containsString(hide.getName())));
assertThat(content, containsString("jgs"));
assertThat(content, containsString("lvs"));
assertThat(content, containsString("trvs"));
Expand All @@ -69,7 +66,7 @@ public void doNotEnumerateItemsRepeatedly() throws Exception {

@Test @Issue("JENKINS-44987")
public void htmlUI() throws Exception {
String MARKUP = "<div><b><a href=\"adsf\">LVS</a></b></div>";
String MARKUP = "<div><b><a href=\"adsf\" rel=\"nofollow noopener noreferrer\">LVS</a></b></div>";

j.jenkins.setMarkupFormatter(new RawHtmlMarkupFormatter(false));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package hudson.plugins.sectioned_view;

import static org.junit.Assert.*;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;

import hudson.Functions;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
Expand All @@ -26,26 +28,31 @@ public class TestResultViewSectionTest {

@Test
public void showIt() throws Exception {
assumeFalse("TODO seems to crash the test JVM in CI buidls", Functions.isWindows() && System.getenv("CI") != null);
FreeStyleProject p = j.createFreeStyleProject("test_project");
p.getPublishersList().add(new JUnitResultArchiver("*.xml", false, null, 1));
p.getPublishersList().add(new JUnitResultArchiver("*.xml"));
p.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
build.getWorkspace().child("result.xml").copyFrom(TestResultViewSectionTest.class.getResourceAsStream("junit-report-1472.xml"));
return true;
}
});
j.assertBuildStatus(Result.UNSTABLE, p.scheduleBuild2(0).get());
j.assertBuildStatus(Result.UNSTABLE, p.scheduleBuild2(0).get());
j.waitForCompletion(j.buildAndAssertStatus(Result.UNSTABLE, p));
j.waitForCompletion(j.buildAndAssertStatus(Result.UNSTABLE, p));

SectionedView sectionedView = new SectionedView("sw");
j.jenkins.addView(sectionedView);
TestResultViewSection tests = new TestResultViewSection("tests view", SectionedViewSection.Width.FULL, SectionedViewSection.Positioning.CENTER);
tests.includeRegex = ".*";
tests.includePattern = Pattern.compile(".*");
sectionedView.setSections(Collections.singletonList(tests));
sectionedView.save();

String out = j.createWebClient().getPage(sectionedView).getWebResponse().getContentAsString();
String out;
try (JenkinsRule.WebClient wc = j.createWebClient()) {
out = wc.getPage(sectionedView).getWebResponse().getContentAsString();
}

assertTrue(out, out.contains("tests view"));
assertTrue(out, out.contains("test_project"));
Expand Down

0 comments on commit 207e11b

Please sign in to comment.