build(plugin): establish build and release pipeline
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package games.dmg.spigotstealth;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class DeliveryConfigurationTest {
|
||||
@Test
|
||||
void ciBuildsChecksAndUploadsDevelopmentJar() throws IOException {
|
||||
String workflow = Files.readString(Path.of(".gitea/workflows/ci.yml"));
|
||||
assertTrue(workflow.contains("./gradlew clean check jar"));
|
||||
assertTrue(workflow.contains("commitlint"));
|
||||
assertTrue(workflow.contains("spigot-stealth-${{ github.sha }}"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void mainBranchReleaseBuildsAndUploadsVersionedJar() throws IOException {
|
||||
String workflow = Files.readString(Path.of(".gitea/workflows/release.yml"));
|
||||
assertTrue(workflow.contains("semantic-release"));
|
||||
assertTrue(workflow.contains("-PreleaseVersion=\"$VERSION\""));
|
||||
assertTrue(workflow.contains("spigot-stealth-${VERSION}.jar"));
|
||||
assertTrue(workflow.contains("/releases/${release_id}/assets"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package games.dmg.spigotstealth;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
class PluginMetadataTest {
|
||||
@Test
|
||||
void pluginEntrypointExtendsJavaPlugin() throws ClassNotFoundException {
|
||||
Class<?> pluginClass = Class.forName("games.dmg.spigotstealth.SpigotStealthPlugin");
|
||||
assertTrue(JavaPlugin.class.isAssignableFrom(pluginClass));
|
||||
}
|
||||
|
||||
@Test
|
||||
void exposesSpigotStealthPluginAndCommands() {
|
||||
try (InputStream input = getClass().getClassLoader().getResourceAsStream("plugin.yml")) {
|
||||
assertNotNull(input, "plugin.yml must be packaged");
|
||||
Map<String, Object> metadata = new Yaml().load(input);
|
||||
assertEquals("SpigotStealth", metadata.get("name"));
|
||||
assertEquals("games.dmg.spigotstealth.SpigotStealthPlugin", metadata.get("main"));
|
||||
assertNotNull(metadata.get("commands"));
|
||||
assertNotNull(metadata.get("permissions"));
|
||||
} catch (java.io.IOException exception) {
|
||||
throw new AssertionError(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user