diff --git a/.github/scripts/test-no-crash-reports.sh b/.github/scripts/test-no-crash-reports.sh new file mode 100644 index 0000000..c67e342 --- /dev/null +++ b/.github/scripts/test-no-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/pull-request.yml b/.github/workflows/build-and-test.yml similarity index 68% rename from .github/workflows/pull-request.yml rename to .github/workflows/build-and-test.yml index d62a2f5..6c9b3cb 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/build-and-test.yml @@ -6,9 +6,11 @@ name: Build and test on: pull_request: branches: [ master, main ] + push: + branches: [ master, main ] jobs: - build: + build-and-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -30,3 +32,14 @@ jobs: - name: Build the mod run: ./gradlew build + + - name: Run server for 1 minute + run: | + mkdir run + echo "eula=true" > run/eula.txt + timeout 10 ./gradlew runServer || true + + - name: Test no crashes happend + run: | + chmod +x .github/scripts/test-no-crash-reports.sh + .github/scripts/test-no-crash-reports.sh diff --git a/.github/workflows/release-packages-tags.yml b/.github/workflows/release-packages-tags.yml index 23e3b87..c256222 100644 --- a/.github/workflows/release-packages-tags.yml +++ b/.github/workflows/release-packages-tags.yml @@ -1,5 +1,4 @@ -# 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 +# This workflow only meant for the source mod you shouldn't bring it into your own project name: Release starter and migration packages @@ -33,7 +32,7 @@ jobs: -x ".github/scripts/update-version.sh" \ -x ".github/workflows/buildscript-maintenance.yml" \ -x ".github/workflows/release-packages-latest.yml" \ - -x ".github/workflows/release-packages-tags.yml" \ + -x ".github/workflows/toolchain-compatibility.yml" \ \ -x "*docs/*" \ -x "README.md" \ @@ -54,6 +53,7 @@ jobs: -x ".github/workflows/buildscript-maintenance.yml" \ -x ".github/workflows/release-packages-latest.yml" \ -x ".github/workflows/release-packages-tags.yml" \ + -x ".github/workflows/toolchain-compatibility.yml" \ \ -x "*docs/*" \ -x "*src/*" \ 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: diff --git a/.github/workflows/toolchain-compatibility.yml b/.github/workflows/toolchain-compatibility.yml new file mode 100644 index 0000000..a082bf3 --- /dev/null +++ b/.github/workflows/toolchain-compatibility.yml @@ -0,0 +1,43 @@ +# 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: + check-compatibility-with-java-11: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up JDK 11 + 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 setupCIWorkspace + + - name: Build the mod + run: ./gradlew build + + - name: Run server for 1 minute + run: | + mkdir run + echo "eula=true" > run/eula.txt + timeout 10 ./gradlew runServer || true + + - name: Test no crashes happend + run: | + chmod +x .github/scripts/test-no-crash-reports.sh + .github/scripts/test-no-crash-reports.sh 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!__ diff --git a/build.gradle b/build.gradle index e1930d4..a86c8b3 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) diff --git a/src/main/java/com/myname/mymodid/CommonProxy.java b/src/main/java/com/myname/mymodid/CommonProxy.java index 5c5ef7d..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()); - + 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 +}