From 8ef1fb9dd84dc3d89fe31995fdee0b118cf8eb52 Mon Sep 17 00:00:00 2001 From: kento2 Date: Tue, 25 Aug 2026 15:39:02 +0200 Subject: [PATCH 1/4] ci --- .forgejo/workflows/publish-artifact.yml | 1 + .forgejo/workflows/run-tests.yml | 26 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .forgejo/workflows/run-tests.yml diff --git a/.forgejo/workflows/publish-artifact.yml b/.forgejo/workflows/publish-artifact.yml index 96bade7..14e2651 100644 --- a/.forgejo/workflows/publish-artifact.yml +++ b/.forgejo/workflows/publish-artifact.yml @@ -28,4 +28,5 @@ jobs: run "$target" \ --remote_cache="https://${CACHE_USERNAME}:${CACHE_PASSWORD}@cache.lab0x13.site:443" \ --remote_upload_local_results \ + --noremote_cache_async done \ No newline at end of file diff --git a/.forgejo/workflows/run-tests.yml b/.forgejo/workflows/run-tests.yml new file mode 100644 index 0000000..5e3e643 --- /dev/null +++ b/.forgejo/workflows/run-tests.yml @@ -0,0 +1,26 @@ +on: + push: + +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: 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 \ + //common/tests:site/lab0x13/scrow/commands/CommandHandlerTest --test_output=all --test_verbose_timeout_warnings From f260a25365f2c73fa428e1c1048c2f7fd6e08266 Mon Sep 17 00:00:00 2001 From: kento2 Date: Tue, 25 Aug 2026 15:47:16 +0200 Subject: [PATCH 2/4] fix linter errors --- .../scrow/commands/CommandHandlerTest.java | 15 ++++++++------- .../site/lab0x13/scrow/commands/TestPlatform.java | 4 +++- 2 files changed, 11 insertions(+), 8 deletions(-) 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(); } } From a60ada6c0887a320d43170be18edee42342bc973 Mon Sep 17 00:00:00 2001 From: kento2 Date: Tue, 25 Aug 2026 15:47:24 +0200 Subject: [PATCH 3/4] ci --- .../{publish-artifact.yml => publish.yml} | 32 ++++++++++++++++--- .forgejo/workflows/run-tests.yml | 26 --------------- 2 files changed, 28 insertions(+), 30 deletions(-) rename .forgejo/workflows/{publish-artifact.yml => publish.yml} (51%) delete mode 100644 .forgejo/workflows/run-tests.yml diff --git a/.forgejo/workflows/publish-artifact.yml b/.forgejo/workflows/publish.yml similarity index 51% rename from .forgejo/workflows/publish-artifact.yml rename to .forgejo/workflows/publish.yml index 14e2651..f67c6c8 100644 --- a/.forgejo/workflows/publish-artifact.yml +++ b/.forgejo/workflows/publish.yml @@ -1,13 +1,37 @@ -name: "Build and Deploy artifact" on: push: - branches: [master, main] jobs: - build: + 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 @@ -29,4 +53,4 @@ jobs: --remote_cache="https://${CACHE_USERNAME}:${CACHE_PASSWORD}@cache.lab0x13.site:443" \ --remote_upload_local_results \ --noremote_cache_async - done \ No newline at end of file + done diff --git a/.forgejo/workflows/run-tests.yml b/.forgejo/workflows/run-tests.yml deleted file mode 100644 index 5e3e643..0000000 --- a/.forgejo/workflows/run-tests.yml +++ /dev/null @@ -1,26 +0,0 @@ -on: - push: - -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: 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 \ - //common/tests:site/lab0x13/scrow/commands/CommandHandlerTest --test_output=all --test_verbose_timeout_warnings From 0d8dec62eeb8562615130b568d81c55fc4a66d3b Mon Sep 17 00:00:00 2001 From: kento2 Date: Tue, 25 Aug 2026 15:50:17 +0200 Subject: [PATCH 4/4] ci --- .forgejo/workflows/publish.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/publish.yml b/.forgejo/workflows/publish.yml index f67c6c8..cceb684 100644 --- a/.forgejo/workflows/publish.yml +++ b/.forgejo/workflows/publish.yml @@ -19,11 +19,12 @@ jobs: run: | bazel \ --output_user_root=/var/cache/bazel \ - test + test \ --remote_cache="https://${CACHE_USERNAME}:${CACHE_PASSWORD}@cache.lab0x13.site:443" \ --noremote_upload_local_results \ --noremote_cache_async \ - //... --test_output=all + --test_output=all \ + //... deploy: needs: test