From 86de13e7127152cf4c865f67e19d51b680fc5924 Mon Sep 17 00:00:00 2001 From: Telan <13066272+TheElan@users.noreply.github.com> Date: Sun, 21 Nov 2021 19:44:37 +0200 Subject: [PATCH 01/10] ci: add step to test toolchain compatibility with newer java version > 8 --- .github/workflows/package-release.yml | 2 + .github/workflows/toolchain-compatibility.yml | 40 +++++++++++++++++++ build.gradle | 4 +- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/toolchain-compatibility.yml diff --git a/.github/workflows/package-release.yml b/.github/workflows/package-release.yml index 363028e..64b698e 100644 --- a/.github/workflows/package-release.yml +++ b/.github/workflows/package-release.yml @@ -24,6 +24,7 @@ jobs: -x ".github/scripts/update-version.sh" \ -x ".github/workflows/buildscript-maintenance.yml" \ -x ".github/workflows/package-release.yml" \ + -x ".github/workflows/toolchain-compatibility.yml" \ \ -x "*docs/*" \ -x "README.md" \ @@ -52,6 +53,7 @@ jobs: -x ".github/scripts/update-version.sh" \ -x ".github/workflows/buildscript-maintenance.yml" \ -x ".github/workflows/package-release.yml" \ + -x ".github/workflows/toolchain-compatibility.yml" \ \ -x "*docs/*" \ -x "*src/*" \ diff --git a/.github/workflows/toolchain-compatibility.yml b/.github/workflows/toolchain-compatibility.yml new file mode 100644 index 0000000..e306095 --- /dev/null +++ b/.github/workflows/toolchain-compatibility.yml @@ -0,0 +1,40 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Check if toolchain is applied when using differnt java versions + +on: + pull_request: + branches: [ master, main ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Setup the workspace + run: ./gradlew setupDecompWorkspace + + - name: Build the mod + run: ./gradlew build + + - name: Run server with mod + timeout-minutes: 1 + run: ./gradlew runServer + + - name: Run client with mod + timeout-minutes: 1 + run: ./gradlew runClient diff --git a/build.gradle b/build.gradle index dc4ccc2..592e95c 100644 --- a/build.gradle +++ b/build.gradle @@ -36,14 +36,14 @@ buildscript { } plugins { + id 'idea' + id 'scala' id("org.ajoberstar.grgit") version("3.1.1") id("com.github.johnrengelman.shadow") version("4.0.4") id("com.palantir.git-version") version("0.12.3") } -apply plugin: 'scala' apply plugin: 'forge' -apply plugin: 'idea' def projectJavaVersion = JavaLanguageVersion.of(8) From a5d5ea510a495da3a4b38c2375c8634f6aa4213e Mon Sep 17 00:00:00 2001 From: Telan <13066272+TheElan@users.noreply.github.com> Date: Sun, 21 Nov 2021 20:06:39 +0200 Subject: [PATCH 02/10] ci: workaround server crash not resulting in gradle error; add step to check generated crash report --- .github/scripts/test-crash-reports.sh | 9 +++++++++ .github/workflows/toolchain-compatibility.yml | 12 +++++++----- src/main/java/com/myname/mymodid/CommonProxy.java | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 .github/scripts/test-crash-reports.sh diff --git a/.github/scripts/test-crash-reports.sh b/.github/scripts/test-crash-reports.sh new file mode 100644 index 0000000..c67e342 --- /dev/null +++ b/.github/scripts/test-crash-reports.sh @@ -0,0 +1,9 @@ +directory="run/crash-reports" +if [ -d $directory ]; then + echo "Crash reports detected:" + cat $directory/* + exit 1 +else + echo "No crash reports detected" + exit 0 +fi diff --git a/.github/workflows/toolchain-compatibility.yml b/.github/workflows/toolchain-compatibility.yml index e306095..612de52 100644 --- a/.github/workflows/toolchain-compatibility.yml +++ b/.github/workflows/toolchain-compatibility.yml @@ -31,10 +31,12 @@ jobs: - name: Build the mod run: ./gradlew build - - name: Run server with mod + - name: Try running server timeout-minutes: 1 - run: ./gradlew runServer + run: | + mkdir run + echo "eula=true" > run/eula.txt + ./gradlew runServer - - name: Run client with mod - timeout-minutes: 1 - run: ./gradlew runClient + - name: Test if any crash reports are present + run: .github/scripts/test-crash-reports.sh diff --git a/src/main/java/com/myname/mymodid/CommonProxy.java b/src/main/java/com/myname/mymodid/CommonProxy.java index 5c5ef7d..ae3b6b1 100644 --- a/src/main/java/com/myname/mymodid/CommonProxy.java +++ b/src/main/java/com/myname/mymodid/CommonProxy.java @@ -8,7 +8,7 @@ public class CommonProxy { // etc, and register them with the GameRegistry." public void preInit(FMLPreInitializationEvent event) { Config.syncronizeConfiguration(event.getSuggestedConfigurationFile()); - + if(true) throw new RuntimeException("test"); MyMod.info(Config.greeting); MyMod.info("I am " + Tags.MODNAME + " at version " + Tags.VERSION + " and group name " + Tags.GROUPNAME); } @@ -43,4 +43,4 @@ public class CommonProxy { public void serverStopped(FMLServerStoppedEvent event) { } -} \ No newline at end of file +} From 2c27858ae504f438a2910471ad3630e96f331293 Mon Sep 17 00:00:00 2001 From: Telan <13066272+TheElan@users.noreply.github.com> Date: Sun, 21 Nov 2021 20:11:04 +0200 Subject: [PATCH 03/10] ci: try to only setup CI workspace --- .github/workflows/toolchain-compatibility.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/toolchain-compatibility.yml b/.github/workflows/toolchain-compatibility.yml index 612de52..95d3fa0 100644 --- a/.github/workflows/toolchain-compatibility.yml +++ b/.github/workflows/toolchain-compatibility.yml @@ -26,7 +26,7 @@ jobs: run: chmod +x gradlew - name: Setup the workspace - run: ./gradlew setupDecompWorkspace + run: ./gradlew setupCIWorkspace - name: Build the mod run: ./gradlew build From 13b5dec6d63bbebed96f06f56b69adae39083615 Mon Sep 17 00:00:00 2001 From: Telan <13066272+TheElan@users.noreply.github.com> Date: Sun, 21 Nov 2021 20:11:43 +0200 Subject: [PATCH 04/10] ci: try fixing test-crash-reports.sh permissions --- .github/workflows/toolchain-compatibility.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/toolchain-compatibility.yml b/.github/workflows/toolchain-compatibility.yml index 95d3fa0..45c13c7 100644 --- a/.github/workflows/toolchain-compatibility.yml +++ b/.github/workflows/toolchain-compatibility.yml @@ -39,4 +39,6 @@ jobs: ./gradlew runServer - name: Test if any crash reports are present - run: .github/scripts/test-crash-reports.sh + run: | + chmod +x .github/scripts/test-crash-reports.sh + .github/scripts/test-crash-reports.sh From f6d48a2287e15dd814e0455683cbcb710a112c79 Mon Sep 17 00:00:00 2001 From: Telan <13066272+TheElan@users.noreply.github.com> Date: Sun, 21 Nov 2021 20:58:13 +0200 Subject: [PATCH 05/10] ci: fix naming in toolchain-compatibility.yml; rename pull-request.yml -> build-and-test.yml; add server run check to build-and-test.yml --- .../{pull-request.yml => build-and-test.yml} | 14 +++++++++++++- .github/workflows/toolchain-compatibility.yml | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) rename .github/workflows/{pull-request.yml => build-and-test.yml} (71%) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/build-and-test.yml similarity index 71% rename from .github/workflows/pull-request.yml rename to .github/workflows/build-and-test.yml index 141530d..b125789 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/build-and-test.yml @@ -10,7 +10,7 @@ on: branches: [ master, main ] jobs: - build: + build-and-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -32,3 +32,15 @@ jobs: - name: Build the mod run: ./gradlew build + + - name: Try running server + timeout-minutes: 1 + run: | + mkdir run + echo "eula=true" > run/eula.txt + ./gradlew runServer + + - name: Test if any crash reports are present + run: | + chmod +x .github/scripts/test-crash-reports.sh + .github/scripts/test-crash-reports.sh diff --git a/.github/workflows/toolchain-compatibility.yml b/.github/workflows/toolchain-compatibility.yml index 45c13c7..b40995d 100644 --- a/.github/workflows/toolchain-compatibility.yml +++ b/.github/workflows/toolchain-compatibility.yml @@ -8,14 +8,14 @@ on: branches: [ master, main ] jobs: - build: + check-compatibility-with-java-11: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set up JDK 8 + - name: Set up JDK 11 uses: actions/setup-java@v2 with: java-version: '11' From 48190d9a2aeb55d95a9bfc70fa70f6532f337478 Mon Sep 17 00:00:00 2001 From: Telan <13066272+TheElan@users.noreply.github.com> Date: Sun, 21 Nov 2021 20:59:02 +0200 Subject: [PATCH 06/10] ci: remove server fail debugging code --- src/main/java/com/myname/mymodid/CommonProxy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/myname/mymodid/CommonProxy.java b/src/main/java/com/myname/mymodid/CommonProxy.java index ae3b6b1..bcc5921 100644 --- a/src/main/java/com/myname/mymodid/CommonProxy.java +++ b/src/main/java/com/myname/mymodid/CommonProxy.java @@ -8,7 +8,7 @@ public class CommonProxy { // etc, and register them with the GameRegistry." public void preInit(FMLPreInitializationEvent event) { Config.syncronizeConfiguration(event.getSuggestedConfigurationFile()); - if(true) throw new RuntimeException("test"); + MyMod.info(Config.greeting); MyMod.info("I am " + Tags.MODNAME + " at version " + Tags.VERSION + " and group name " + Tags.GROUPNAME); } From 09410d48d0c526ff26033dcb27bb1008696d1097 Mon Sep 17 00:00:00 2001 From: Telan <13066272+TheElan@users.noreply.github.com> Date: Sun, 21 Nov 2021 21:01:07 +0200 Subject: [PATCH 07/10] ci: refine naming --- .../{test-crash-reports.sh => test-no-crash-reports.sh} | 0 .github/workflows/build-and-test.yml | 8 ++++---- .github/workflows/toolchain-compatibility.yml | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) rename .github/scripts/{test-crash-reports.sh => test-no-crash-reports.sh} (100%) diff --git a/.github/scripts/test-crash-reports.sh b/.github/scripts/test-no-crash-reports.sh similarity index 100% rename from .github/scripts/test-crash-reports.sh rename to .github/scripts/test-no-crash-reports.sh diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index b125789..1186cf3 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -33,14 +33,14 @@ jobs: - name: Build the mod run: ./gradlew build - - name: Try running server + - name: Run server for 1 minute timeout-minutes: 1 run: | mkdir run echo "eula=true" > run/eula.txt ./gradlew runServer - - name: Test if any crash reports are present + - name: Test no crashes happend run: | - chmod +x .github/scripts/test-crash-reports.sh - .github/scripts/test-crash-reports.sh + chmod +x .github/scripts/test-no-crash-reports.sh + .github/scripts/test-no-crash-reports.sh diff --git a/.github/workflows/toolchain-compatibility.yml b/.github/workflows/toolchain-compatibility.yml index b40995d..dddc282 100644 --- a/.github/workflows/toolchain-compatibility.yml +++ b/.github/workflows/toolchain-compatibility.yml @@ -31,14 +31,14 @@ jobs: - name: Build the mod run: ./gradlew build - - name: Try running server + - name: Run server for 1 minute timeout-minutes: 1 run: | mkdir run echo "eula=true" > run/eula.txt ./gradlew runServer - - name: Test if any crash reports are present + - name: Test no crashes happend run: | - chmod +x .github/scripts/test-crash-reports.sh - .github/scripts/test-crash-reports.sh + chmod +x .github/scripts/test-no-crash-reports.sh + .github/scripts/test-no-crash-reports.sh From c46bab50ce17c2b2d323341b69d91b35745ce347 Mon Sep 17 00:00:00 2001 From: Telan <13066272+TheElan@users.noreply.github.com> Date: Sun, 21 Nov 2021 21:09:01 +0200 Subject: [PATCH 08/10] ci: fix timeout step failing We don't want to fail on timeout, it's probably good if job didn't stop before timeout was reached, which means server is still working --- .github/workflows/build-and-test.yml | 3 +-- .github/workflows/toolchain-compatibility.yml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 1186cf3..6c9b3cb 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -34,11 +34,10 @@ jobs: run: ./gradlew build - name: Run server for 1 minute - timeout-minutes: 1 run: | mkdir run echo "eula=true" > run/eula.txt - ./gradlew runServer + timeout 10 ./gradlew runServer || true - name: Test no crashes happend run: | diff --git a/.github/workflows/toolchain-compatibility.yml b/.github/workflows/toolchain-compatibility.yml index dddc282..a082bf3 100644 --- a/.github/workflows/toolchain-compatibility.yml +++ b/.github/workflows/toolchain-compatibility.yml @@ -32,11 +32,10 @@ jobs: run: ./gradlew build - name: Run server for 1 minute - timeout-minutes: 1 run: | mkdir run echo "eula=true" > run/eula.txt - ./gradlew runServer + timeout 10 ./gradlew runServer || true - name: Test no crashes happend run: | From 3d6187a192ca99ce40306269cabfe9c29f0cc632 Mon Sep 17 00:00:00 2001 From: Telan <13066272+TheElan@users.noreply.github.com> Date: Sun, 21 Nov 2021 21:23:52 +0200 Subject: [PATCH 09/10] ci: also run build and test on main branches; adjust naming --- .github/workflows/build-and-test.yml | 2 ++ .github/workflows/release-tags.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 2eafd62..6c9b3cb 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -6,6 +6,8 @@ name: Build and test on: pull_request: branches: [ master, main ] + push: + branches: [ master, main ] jobs: build-and-test: diff --git a/.github/workflows/release-tags.yml b/.github/workflows/release-tags.yml index 3bc35d2..25c354b 100644 --- a/.github/workflows/release-tags.yml +++ b/.github/workflows/release-tags.yml @@ -1,7 +1,7 @@ # This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle -name: Release artifacts +name: Release tagged build on: push: From bcafab73ecb7d0ad17638f99dfd743a673a48fa4 Mon Sep 17 00:00:00 2001 From: Telan <13066272+TheElan@users.noreply.github.com> Date: Sun, 21 Nov 2021 21:26:33 +0200 Subject: [PATCH 10/10] readme: update --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 721e441..062f833 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,10 @@ We also have described guidelines for existing mod [migration](docs/migration.md - Boilerplate forge mod as starting point - Improved warnings for pitfalls - Git Tags integration for versioning - - GitHub CI - [Jitpack](https://jitpack.io) CI - - Releasing your artifacts on new tags pushed. Push git tag named after version (e.g. 1.0.0) which will trigger a release of artifacts with according names. + - GitHub CI: + - Releasing your artifacts on new tags pushed. Push git tag named after version (e.g. 1.0.0) which will trigger a release of artifacts with according names. + - Running smoke test for server startup. On any server crash occurring workflow will fail and print the crash log. ### Files - [`build.gradle`](https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/build.gradle): This is the core script of the build process. You should not need to tamper with it, unless you are trying to accomplish something out of the ordinary. __Do not touch this file! You will make a future update near impossible if you do so!__