Skip to content

Commit

Permalink
Merge branch 'release/1.64.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jelemux committed Apr 11, 2023
2 parents 8a45afc + ac776fa commit a9c930f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.64.0](https://github.com/cloudogu/ces-build-lib/releases/tag/1.64.0) - 2023-04-11
## Added
- Add parameter to configure version for markdown link checker #100.

## [1.63.0](https://github.com/cloudogu/ces-build-lib/releases/tag/1.63.0) - 2023-02-16
## Fixed
- A bug with SonarCloud where an error was thrown because a private field was accessed (#99)
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1147,10 +1147,18 @@ Example:
markdown.check()
```


`markdown.check` executes the function defined in `Markdown`
running a container with the latest https://github.com/tcort/markdown-link-check image
and verifies that the links in the defined project directory are alive

Additionally, the markdown link checker can be used with a specific version (default: stable).

```groovy
Markdown markdown = new Markdown(this, "3.11.0")
markdown.check()
```

### DockerLint

```groovy
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.cloudogu.ces</groupId>
<artifactId>ces-build-lib</artifactId>
<name>ces-build-lib</name>
<version>1.63.0</version>
<version>1.64.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
6 changes: 4 additions & 2 deletions src/com/cloudogu/ces/cesbuildlib/Markdown.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ class Markdown implements Serializable{
Sh sh
private script
Docker docker
private String tag

Markdown(script) {
Markdown(script, String tag = "stable") {
this.script = script
this.sh = new Sh(script)
this.docker = new Docker(script)
this.tag = tag
}

def check(){
this.docker.image("ghcr.io/tcort/markdown-link-check:stable")
this.docker.image("ghcr.io/tcort/markdown-link-check:${this.tag}")
.mountJenkinsUser()
.inside("--entrypoint=\"\" -v ${this.script.env.WORKSPACE}/docs:/docs") {
this.script.sh 'find /docs -name \\*.md -print0 | xargs -0 -n1 markdown-link-check -v'
Expand Down
8 changes: 6 additions & 2 deletions test/com/cloudogu/ces/cesbuildlib/DockerMock.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ import static org.mockito.Mockito.when

class DockerMock {

static Docker create() {
static Docker create(String imageTag = "") {
Docker dockerMock = mock(Docker.class)
Docker.Image imageMock = mock(Docker.Image.class)
when(dockerMock.image(anyString())).thenReturn(imageMock)
if (imageTag == "") {
when(dockerMock.image(anyString())).thenReturn(imageMock)
} else {
when(dockerMock.image(imageTag)).thenReturn(imageMock)
}
when(imageMock.mountJenkinsUser()).thenReturn(imageMock)
when(imageMock.mountJenkinsUser(anyBoolean())).thenReturn(imageMock)
when(imageMock.mountDockerSocket()).thenReturn(imageMock)
Expand Down
20 changes: 18 additions & 2 deletions test/com/cloudogu/ces/cesbuildlib/MarkdownTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import static org.mockito.Mockito.verify
class MarkdownTest extends GroovyTestCase {
@Test
void testIfDockerContainerCommandIsCalledWithCorrectArgs() {
Docker dockerMock = DockerMock.create()
Docker dockerMock = DockerMock.create("ghcr.io/tcort/markdown-link-check:stable")
ScriptMock scriptMock = new ScriptMock(dockerMock)
Markdown markdown = new Markdown(scriptMock)

Expand All @@ -19,6 +19,22 @@ class MarkdownTest extends GroovyTestCase {
assert scriptMock.allActualArgs.size() == 1
assert scriptMock.allActualArgs[0] == "find /docs -name \\*.md -print0 | xargs -0 -n1 markdown-link-check -v"

verify(dockerMock.image(""), times(1)).mountJenkinsUser()
verify(dockerMock.image("ghcr.io/tcort/markdown-link-check:stable"), times(1)).mountJenkinsUser()
}

@Test
void testIfDockerContainerCommandIsCalledWithCorrectArgsWithMarkDownTag() {
Docker dockerMock = DockerMock.create("ghcr.io/tcort/markdown-link-check:3.11.0")
ScriptMock scriptMock = new ScriptMock(dockerMock)
Markdown markdown = new Markdown(scriptMock, "3.11.0")

markdown.docker = dockerMock

markdown.check()

assert scriptMock.allActualArgs.size() == 1
assert scriptMock.allActualArgs[0] == "find /docs -name \\*.md -print0 | xargs -0 -n1 markdown-link-check -v"

verify(dockerMock.image("ghcr.io/tcort/markdown-link-check:3.11.0"), times(1)).mountJenkinsUser()
}
}

0 comments on commit a9c930f

Please sign in to comment.