Skip to content

Commit

Permalink
#43 up
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Oct 20, 2024
1 parent 33e0cef commit e3b6ef9
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 1 deletion.
47 changes: 47 additions & 0 deletions src/main/java/org/eolang/hone/PullMojo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Objectionary.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.eolang.hone;

import com.jcabi.log.Logger;
import java.io.IOException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;

/**
* Pull Docker image.
*
* @since 0.1.0
*/
@Mojo(name = "pull", defaultPhase = LifecyclePhase.PROCESS_CLASSES)
public final class PullMojo extends AbstractMojo {

@Override
public void exec() throws IOException {
new Docker(this.sudo).exec(
"pull",
this.image
);
Logger.info(this, "Docker image '%s' was pulled", this.image);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SOFTWARE.
<name>hone</name>
<properties>
<eo.version>0.39.1</eo.version>
<jeo.version>0.6.6</jeo.version>
<jeo.version>0.6.8</jeo.version>
</properties>
<build>
<pluginManagement>
Expand Down
64 changes: 64 additions & 0 deletions src/test/java/org/eolang/hone/PullMojoTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Objectionary.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.eolang.hone;

import com.yegor256.farea.Farea;
import java.nio.file.Path;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

/**
* Test case for {@link PullMojo}.
*
* @since 0.1.0
*/
final class PullMojoTest {

@Test
void pullsDockerImage(@TempDir final Path dir) throws Exception {
new Farea(dir).together(
f -> {
f.build()
.plugins()
.appendItself()
.execution("default")
.phase("process-classes")
.goals("pull")
.configuration()
.set("image", "yegor256/hone");
f.exec("test");
MatcherAssert.assertThat(
"the Docker image pulling step must succeed",
f.log(),
Matchers.allOf(
Matchers.containsString("BUILD SUCCESS"),
Matchers.not(Matchers.containsString("BUILD FAILURE"))
)
);
}
);
}
}

0 comments on commit e3b6ef9

Please sign in to comment.