diff --git a/.forgejo/workflows/publish-artifact.yml b/.forgejo/workflows/publish-artifact.yml deleted file mode 100644 index 96bade7..0000000 --- a/.forgejo/workflows/publish-artifact.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: "Build and Deploy artifact" -on: - push: - branches: [master, main] - -jobs: - build: - runs-on: docker - container: - image: "git.lab0x13.site/scrow/bazel-java:0.12" - steps: - - uses: actions/checkout@v7 - - uses: actions/cache@v6 - with: - path: /var/cache/bazel - key: bazel-${{ env.FORGEJO_REPOSITORY }} - - id: deploy - env: - CACHE_USERNAME: ${{ secrets.CACHE_USERNAME }} - CACHE_PASSWORD: ${{ secrets.CACHE_PASSWORD }} - MAVEN_USER: ${{ secrets.MAVENREPO_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.MAVENREPO_PASSWORD }} - run: | - for target in //bukkit:bukkit.publish //core:core.publish - do - bazel \ - --output_user_root=/var/cache/bazel \ - run "$target" \ - --remote_cache="https://${CACHE_USERNAME}:${CACHE_PASSWORD}@cache.lab0x13.site:443" \ - --remote_upload_local_results \ - done \ No newline at end of file diff --git a/.forgejo/workflows/publish.yml b/.forgejo/workflows/publish.yml new file mode 100644 index 0000000..cceb684 --- /dev/null +++ b/.forgejo/workflows/publish.yml @@ -0,0 +1,57 @@ +on: + push: + +jobs: + test: + runs-on: docker + container: + image: "git.lab0x13.site/scrow/bazel-java:0.12" + steps: + - uses: actions/checkout@v7 + - uses: actions/cache@v6 + with: + path: /var/cache/bazel + key: bazel-${{ env.FORGEJO_REPOSITORY }} + - id: run-tests + env: + CACHE_USERNAME: ${{ secrets.CACHE_USERNAME }} + CACHE_PASSWORD: ${{ secrets.CACHE_PASSWORD }} + run: | + bazel \ + --output_user_root=/var/cache/bazel \ + test \ + --remote_cache="https://${CACHE_USERNAME}:${CACHE_PASSWORD}@cache.lab0x13.site:443" \ + --noremote_upload_local_results \ + --noremote_cache_async \ + --test_output=all \ + //... + + deploy: + needs: test + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' + runs-on: docker + container: + image: "git.lab0x13.site/scrow/bazel-java:0.12" + + steps: + - uses: actions/checkout@v7 + - uses: actions/cache@v6 + with: + path: /var/cache/bazel + key: bazel-${{ env.FORGEJO_REPOSITORY }} + - id: deploy + env: + CACHE_USERNAME: ${{ secrets.CACHE_USERNAME }} + CACHE_PASSWORD: ${{ secrets.CACHE_PASSWORD }} + MAVEN_USER: ${{ secrets.MAVENREPO_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVENREPO_PASSWORD }} + run: | + for target in //bukkit:bukkit.publish //core:core.publish + do + bazel \ + --output_user_root=/var/cache/bazel \ + run "$target" \ + --remote_cache="https://${CACHE_USERNAME}:${CACHE_PASSWORD}@cache.lab0x13.site:443" \ + --remote_upload_local_results \ + --noremote_cache_async + done diff --git a/common/tests/site/lab0x13/scrow/commands/CommandHandlerTest.java b/common/tests/site/lab0x13/scrow/commands/CommandHandlerTest.java index e41e2a2..30d0f19 100644 --- a/common/tests/site/lab0x13/scrow/commands/CommandHandlerTest.java +++ b/common/tests/site/lab0x13/scrow/commands/CommandHandlerTest.java @@ -13,6 +13,7 @@ import site.lab0x13.scrow.commands.model.literal.RootLiteral; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.stream.Stream; @@ -56,7 +57,7 @@ class CommandHandlerTest { @BeforeAll static void init() { - System.setOut(new PrintStream(outContent)); + System.setOut(new PrintStream(outContent, true, StandardCharsets.UTF_8)); } @AfterAll @@ -72,37 +73,37 @@ class CommandHandlerTest { @Test void testDefaultExecutor() { commandHandler.invoke(rootLiteral, new CommandContextImpl(), Stream.of()); - assertEquals("default executor\n", outContent.toString()); + assertEquals("default executor\n", outContent.toString(StandardCharsets.UTF_8)); } @Test void testSubLiteralNoArgs() { commandHandler.invoke(rootLiteral, new CommandContextImpl(), Stream.of("get", "foo")); - assertEquals("get executor: player=foo\n", outContent.toString()); + assertEquals("get executor: player=foo\n", outContent.toString(StandardCharsets.UTF_8)); } @Test void testSubLiteralWithArgs() { commandHandler.invoke(rootLiteral, new CommandContextImpl(), Stream.of("set", "foo", "10")); - assertEquals("set executor: player=foo amount=10\n", outContent.toString()); + assertEquals("set executor: player=foo amount=10\n", outContent.toString(StandardCharsets.UTF_8)); outContent.reset(); } @Test void testFailOnBadLiteral() { commandHandler.invoke(rootLiteral, new CommandContextImpl(), Stream.of("BAD_LITERAL")); - assertEquals("Unknown literal \"BAD_LITERAL\".\n", outContent.toString()); + assertEquals("Unknown literal \"BAD_LITERAL\".\n", outContent.toString(StandardCharsets.UTF_8)); } @Test void testFailOnBadArgument() { commandHandler.invoke(rootLiteral, new CommandContextImpl(), Stream.of("set", "foo", "bar")); - assertEquals("Not a number.\n", outContent.toString()); + assertEquals("Not a number.\n", outContent.toString(StandardCharsets.UTF_8)); } @Test void testFailOnMissingArgument() { commandHandler.invoke(rootLiteral, new CommandContextImpl(), Stream.of("set")); - assertEquals("Argument expected.\n", outContent.toString()); + assertEquals("Argument expected.\n", outContent.toString(StandardCharsets.UTF_8)); } } diff --git a/common/tests/site/lab0x13/scrow/commands/TestPlatform.java b/common/tests/site/lab0x13/scrow/commands/TestPlatform.java index 0fc7ebf..a9088a8 100644 --- a/common/tests/site/lab0x13/scrow/commands/TestPlatform.java +++ b/common/tests/site/lab0x13/scrow/commands/TestPlatform.java @@ -3,6 +3,7 @@ package site.lab0x13.scrow.commands; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; +import java.util.ArrayList; import java.util.List; public class TestPlatform implements PlatformAdapter { @@ -12,7 +13,7 @@ public class TestPlatform implements PlatformAdapter { private final List permissions; public TestPlatform(List permissions) { - this.permissions = permissions; + this.permissions = new ArrayList<>(permissions); } @Override @@ -23,5 +24,6 @@ public class TestPlatform implements PlatformAdapter { @Override public void sendMessage(CommandContextImpl ctx, Component message) { System.out.println(plainText.serialize(message)); + System.out.flush(); } }