diff --git a/.github/actions/setup-environment/action.yml b/.github/actions/setup-environment/action.yml new file mode 100644 index 000000000..af98fa41f --- /dev/null +++ b/.github/actions/setup-environment/action.yml @@ -0,0 +1,26 @@ +name: "Setup environment" +description: "Common setup before using gradle" +runs: + using: "composite" + steps: + - name: "Checkout repository" + uses: actions/checkout@v3.5.3 + with: + fetch-depth: 0 + + - name: "Set up JDK" + uses: actions/setup-java@v3.12.0 + with: + distribution: "temurin" + java-version: 17 + + - name: "Initialize caches" + uses: actions/cache@v3.3.1 + with: + path: | + ~/.gradle/caches + ~/.gradle/loom-cache + ~/.gradle/wrapper + key: ${{ runner.os }}-build-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-build- \ No newline at end of file diff --git a/.github/scripts/run-client.sh b/.github/scripts/run-client.sh new file mode 100755 index 000000000..518de5401 --- /dev/null +++ b/.github/scripts/run-client.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +./gradlew $1:runClient > gradle_client_output.txt 2>&1 & + +SUCCESS_PATTERN='minecraft:textures/atlas/mob_effects\.png-atlas' +ERROR_PATTERNS=( + 'For more details see the full crash report file' + ' end of report ' +) +TIMEOUT=1800 +ELAPSED=0 + +while [ $ELAPSED -lt $TIMEOUT ]; do + if grep -Eq "$SUCCESS_PATTERN" gradle_client_output.txt; then + pkill -P $$ + exit 0 + fi + + for ERROR_PATTERN in "${ERROR_PATTERNS[@]}"; do + if grep -Eq "$ERROR_PATTERN" gradle_client_output.txt; then + pkill -P $$ + exit 1 + fi + done + + sleep 1 + ELAPSED=$((ELAPSED + 1)) +done + +if [ $ELAPSED -ge $TIMEOUT ]; then + exit 1 +fi diff --git a/.github/scripts/run-server.sh b/.github/scripts/run-server.sh new file mode 100755 index 000000000..ae7b8a4cf --- /dev/null +++ b/.github/scripts/run-server.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +./gradlew $1:runServer --args="nogui" > gradle_server_output.txt 2>&1 & + +SUCCESS_PATTERN='For help, type "help"' +ERROR_PATTERNS=( + 'For more details see the full crash report file' + ' end of report ' +) +TIMEOUT=1800 +ELAPSED=0 + +while [ $ELAPSED -lt $TIMEOUT ]; do + if grep -Eq "$SUCCESS_PATTERN" gradle_server_output.txt; then + pkill -P $$ + exit 0 + fi + + for ERROR_PATTERN in "${ERROR_PATTERNS[@]}"; do + if grep -Eq "$ERROR_PATTERN" gradle_server_output.txt; then + pkill -P $$ + exit 1 + fi + done + + sleep 1 + ELAPSED=$((ELAPSED + 1)) +done + +if [ $ELAPSED -ge $TIMEOUT ]; then + exit 1 +fi \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b508b7bd8..f0719d0a6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,23 +11,62 @@ jobs: steps: - name: "Checkout repository" uses: actions/checkout@v3.5.3 - - - name: "Set up JDK" - uses: actions/setup-java@v3.12.0 with: - distribution: "temurin" - java-version: 17 - - - name: "Initialize caches" - uses: actions/cache@v3.3.1 - with: - path: | - ~/.gradle/caches - ~/.gradle/loom-cache - ~/.gradle/wrapper - key: ${{ runner.os }}-build-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-build- + fetch-depth: 0 + + - name: "Setup environment" + uses: ./.github/actions/setup-environment - name: "Build with gradle" - run: ./gradlew build \ No newline at end of file + run: ./gradlew build + + run-client: + needs: build + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + mod_loader: [ "fabric", "forge" ] + name: Run ${{ matrix.mod_loader }} client + timeout-minutes: 30 + + steps: + - name: "Checkout repository" + uses: actions/checkout@v3.5.3 + with: + fetch-depth: 0 + + - name: "Setup environment" + uses: ./.github/actions/setup-environment + + - name: Run ${{ matrix.mod_loader }} client + uses: modmuss50/xvfb-action@v1 + with: + run: ./.github/scripts/run-client.sh ${{ matrix.mod_loader }} + shell: bash + + run-server: + needs: build + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + mod_loader: [ "fabric", "forge" ] + name: Run ${{ matrix.mod_loader }} server + timeout-minutes: 30 + + steps: + - name: "Checkout repository" + uses: actions/checkout@v3.5.3 + with: + fetch-depth: 0 + + - name: "Setup environment" + uses: ./.github/actions/setup-environment + + - name: "Accept eula" + run: mkdir -p ${{ matrix.mod_loader }}/run && echo "eula=true" > ${{ matrix.mod_loader }}/run/eula.txt + + - name: Run ${{ matrix.mod_loader }} server + run: ./.github/scripts/run-server.sh ${{ matrix.mod_loader }} + shell: bash \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c654eb0eb..dc75a3141 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,8 +13,12 @@ env: 1.19.3 FABRIC_DEPENDENCIES: | fabric-api | depends | * - QUILT_DEPENDENCIES: | - qsl | depends | * + FABRIC_LOADERS: | + fabric + quilt + FORGE_LOADERS: | + forge + neoforge RETRY_ATTEMPTS: 3 RELAY_DELAY: 10000 VERSION_RESOLVER: latest @@ -28,23 +32,11 @@ jobs: steps: - name: "Checkout repository" uses: actions/checkout@v3.5.3 - - - name: "Set up JDK" - uses: actions/setup-java@v3.12.0 with: - distribution: "temurin" - java-version: 17 - - - name: "Initialize caches" - uses: actions/cache@v3.3.1 - with: - path: | - ~/.gradle/caches - ~/.gradle/loom-cache - ~/.gradle/wrapper - key: ${{ runner.os }}-build-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-build- + fetch-depth: 0 + + - name: "Setup environment" + uses: ./.github/actions/setup-environment - name: "Build with gradle" run: ./gradlew build @@ -56,7 +48,6 @@ jobs: path: | fabric/build/libs/friendsandfoes-fabric-${{ github.ref_name }}.jar forge/build/libs/friendsandfoes-forge-${{ github.ref_name }}.jar - quilt/build/libs/friendsandfoes-quilt-${{ github.ref_name }}.jar LICENSE.txt publish-license-to-release: @@ -115,7 +106,7 @@ jobs: files-primary: fabric/build/libs/friendsandfoes-fabric-${{ github.ref_name }}.jar version-type: ${{ env.VERSION_TYPE }} - loaders: fabric + loaders: ${{ env.FABRIC_LOADERS }} game-versions: ${{ env.GAME_VERSIONS }} name: Friends&Foes ${{ github.ref_name }} (Fabric) dependencies: ${{ env.FABRIC_DEPENDENCIES }} @@ -147,7 +138,7 @@ jobs: files-primary: fabric/build/libs/friendsandfoes-fabric-${{ github.ref_name }}.jar version-type: ${{ env.VERSION_TYPE }} - loaders: fabric + loaders: ${{ env.FABRIC_LOADERS }} game-versions: ${{ env.GAME_VERSIONS }} name: Friends&Foes ${{ github.ref_name }} (Fabric) version: fabric-${{ github.ref_name }} @@ -195,7 +186,7 @@ jobs: files-primary: forge/build/libs/friendsandfoes-forge-${{ github.ref_name }}.jar version-type: ${{ env.VERSION_TYPE }} - loaders: forge + loaders: ${{ env.FORGE_LOADERS }} game-versions: ${{ env.GAME_VERSIONS }} name: Friends&Foes ${{ github.ref_name }} (Forge) java: ${{ env.JAVA_VERSIONS }} @@ -226,92 +217,11 @@ jobs: files-primary: forge/build/libs/friendsandfoes-forge-${{ github.ref_name }}.jar version-type: ${{ env.VERSION_TYPE }} - loaders: forge + loaders: ${{ env.FORGE_LOADERS }} game-versions: ${{ env.GAME_VERSIONS }} name: Friends&Foes ${{ github.ref_name }} (Forge) version: forge-${{ github.ref_name }} java: ${{ env.JAVA_VERSIONS }} retry-attempts: ${{ env.RETRY_ATTEMPTS }} retry-delay: ${{ env.RETRY_DELAY }} - version-resolver: ${{ env.VERSION_RESOLVER }} - - - publish-quilt-to-github: - needs: build - runs-on: ubuntu-latest - name: "Publish Quilt to GitHub" - timeout-minutes: 30 - - steps: - - name: "Download artifacts" - uses: actions/download-artifact@v3 - with: - name: "friends-and-foes" - - - name: "Publish Quilt to GitHub" - uses: AButler/upload-release-assets@v2.0.2 - with: - files: quilt/build/libs/friendsandfoes-quilt-${{ github.ref_name }}.jar - repo-token: ${{ secrets.GITHUB_TOKEN }} - - publish-quilt-to-curseforge: - needs: build - runs-on: ubuntu-latest - name: "Publish Quilt to CurseForge" - timeout-minutes: 30 - - steps: - - name: "Download artifacts" - uses: actions/download-artifact@v3 - with: - name: "friends-and-foes" - - - name: "Publish Quilt to CurseForge" - uses: Kir-Antipov/mc-publish@v3.2 - with: - curseforge-id: 628248 - curseforge-token: ${{ secrets.CURSEFORGE_RELEASE_TOKEN }} - - files-primary: quilt/build/libs/friendsandfoes-quilt-${{ github.ref_name }}.jar - version-type: ${{ env.VERSION_TYPE }} - loaders: quilt - game-versions: ${{ env.GAME_VERSIONS }} - name: Friends&Foes ${{ github.ref_name }} (Quilt) - dependencies: ${{ env.QUILT_DEPENDENCIES }} - java: ${{ env.JAVA_VERSIONS }} - - retry-attempts: ${{ env.RETRY_ATTEMPTS }} - retry-delay: ${{ env.RETRY_DELAY }} - version-resolver: ${{ env.VERSION_RESOLVER }} - - publish-quilt-to-modrinth: - needs: build - runs-on: ubuntu-latest - name: "Publish Quilt to Modrinth" - timeout-minutes: 30 - - steps: - - name: "Download artifacts" - uses: actions/download-artifact@v3 - with: - name: "friends-and-foes" - - - name: "Publish Quilt to Modrinth" - uses: Kir-Antipov/mc-publish@v3.2 - with: - modrinth-id: NxP9xmhw - modrinth-featured: true - modrinth-unfeature-mode: version-intersection - modrinth-token: ${{ secrets.MODRINTH_RELEASE_TOKEN }} - - files-primary: quilt/build/libs/friendsandfoes-quilt-${{ github.ref_name }}.jar - version-type: ${{ env.VERSION_TYPE }} - loaders: quilt - game-versions: ${{ env.GAME_VERSIONS }} - name: Friends&Foes ${{ github.ref_name }} (Quilt) - version: quilt-${{ github.ref_name }} - dependencies: ${{ env.QUILT_DEPENDENCIES }} - java: ${{ env.JAVA_VERSIONS }} - retry-attempts: ${{ env.RETRY_ATTEMPTS }} - retry-delay: ${{ env.RETRY_DELAY }} version-resolver: ${{ env.VERSION_RESOLVER }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index be2a7c27e..11a28bad0 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,6 @@ classes/ .vscode .settings *.launch -.architectury-transformer \ No newline at end of file +.architectury-transformer +gradle_client_output.txt +gradle_server_output.txt \ No newline at end of file diff --git a/build.gradle b/build.gradle index 6aafc9805..38f1bb6dc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "1.0.+" apply false + id "dev.architectury.loom" version "1.3.+" apply false } architectury { diff --git a/fabric/build.gradle b/fabric/build.gradle index 69a855aed..c8aa78ce5 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,5 +1,5 @@ plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" + id "com.github.johnrengelman.shadow" version "8.1.1" } allprojects { @@ -38,6 +38,10 @@ dependencies { // Trinkets modImplementation("dev.emi:trinkets:${rootProject.trinkets_version}") + // Fix for CCA + modApi("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cca_version}") + modApi("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cca_version}") + // For faster development https://www.cursemaven.com/ // https://www.curseforge.com/minecraft/mc-mods/lazydfu/files modRuntimeOnly "curse.maven:lazydfu-433518:3821870" @@ -72,18 +76,18 @@ shadowJar { exclude "architectury.common.json" configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" + archiveClassifier.set("dev-shadow") } remapJar { injectAccessWidener = true - input.set shadowJar.archiveFile + inputFile.set shadowJar.archiveFile dependsOn shadowJar - classifier null + archiveClassifier.set(null) } jar { - classifier "dev" + archiveClassifier.set("dev") } sourcesJar { diff --git a/forge/build.gradle b/forge/build.gradle index 82ce737c0..623e8027e 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -1,5 +1,5 @@ plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" + id "com.github.johnrengelman.shadow" version "8.1.1" } allprojects { @@ -66,17 +66,17 @@ shadowJar { exclude "architectury.common.json" configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" + archiveClassifier.set("dev-shadow") } remapJar { - input.set shadowJar.archiveFile + inputFile.set shadowJar.archiveFile dependsOn shadowJar - classifier null + archiveClassifier.set(null) } jar { - classifier "dev" + archiveClassifier.set("dev") } sourcesJar { diff --git a/gradle.properties b/gradle.properties index 4b18311e6..16c5fdd25 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,12 +20,13 @@ minecraft_version=1.19.3 yarn_mappings=1.19.3+build.5:v2 # Architectury -enabled_platforms=fabric,forge,quilt +enabled_platforms=fabric,forge # Common cloth_config_version=9.0.94 mixin_extras_version=0.2.0-beta.8 trinkets_version=3.5.1 +cca_version=5.2.0 # Fabric https://fabricmc.net/versions.html fabric_loader_version=0.14.19 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 41dfb8790..ac6226f70 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/quilt/build.gradle b/quilt/build.gradle index d9c7c1451..6ebd4ae23 100644 --- a/quilt/build.gradle +++ b/quilt/build.gradle @@ -1,5 +1,5 @@ plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" + id "com.github.johnrengelman.shadow" version "8.1.1" } allprojects { @@ -34,6 +34,10 @@ dependencies { // Trinkets modImplementation("dev.emi:trinkets:${rootProject.trinkets_version}") + // Fix for CCA + modApi("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cca_version}") + modApi("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cca_version}") + common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionQuilt")) { transitive false } } @@ -64,18 +68,18 @@ shadowJar { exclude "architectury.common.json" configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" + archiveClassifier.set("dev-shadow") } remapJar { injectAccessWidener = true - input.set shadowJar.archiveFile + inputFile.set shadowJar.archiveFile dependsOn shadowJar - classifier null + archiveClassifier.set(null) } jar { - classifier "dev" + archiveClassifier.set("dev") } sourcesJar { diff --git a/settings.gradle b/settings.gradle index 8c96dc79f..197a2ae8d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,6 +10,5 @@ pluginManagement { include("common") include("fabric") include("forge") -include("quilt") rootProject.name = "friends-and-foes"