diff --git a/.editorconfig b/.editorconfig index 34b4e21..2170ac1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,13 +7,13 @@ indent_size = 4 indent_style = tab insert_final_newline = true trim_trailing_whitespace = true +max_line_length = 100 [*.md] trim_trailing_whitespace = false +max_line_length = off [*.{yml,yaml}] indent_style = space indent_size = 2 - -[docker-compose.yml] -indent_size = 4 +max_line_length = off diff --git a/.github/actions/download_dependencies/action.yml b/.github/actions/download_dependencies/action.yml new file mode 100644 index 0000000..fbde876 --- /dev/null +++ b/.github/actions/download_dependencies/action.yml @@ -0,0 +1,28 @@ +name: "Download Dependencies" +description: "Downloads the dependencies for the mod" + +inputs: + minecraft_version: + type: string + description: 'Minecraft version to use for testing. Defaults to "1.21.3".' + default: "1.21.3" + + loader: + type: string + description: 'Mod loader to use for testing. Defaults to "fabric".' + default: "fabric" + +runs: + using: "composite" + steps: + - name: "[Geckolib 3] (${{ runner.os }}) Fetch Version" + uses: ./.github/actions/set_to_env + with: + value: $( ./gradlew -q :getGeckolib3Version ) + env_var: GECKOLIB3_VERSION + + - name: "[Geckolib 3] Downloading..." + uses: suisei-cn/actions-download-file@818d6b7dc8fe73f2f924b6241f2b1134ca1377d9 + with: + url: "https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/software/bernie/geckolib/geckolib-${{ inputs.loader }}-${{ inputs.minecraft_version }}/${{ env.GECKOLIB3_VERSION }}/geckolib-${{ inputs.loader }}-${{ inputs.minecraft_version }}-${{ env.GECKOLIB3_VERSION }}.jar" + target: "run/mods" diff --git a/.github/actions/prep/action.yml b/.github/actions/prep/action.yml new file mode 100644 index 0000000..0d9bddf --- /dev/null +++ b/.github/actions/prep/action.yml @@ -0,0 +1,46 @@ +name: "Pre Testing" +description: "Prepare the environment for testing" + +inputs: + java: + type: number + description: 'Java version to use for testing. Defaults to 22.' + default: 22 + + java_dist: + type: string + description: 'Java distribution to use for testing. Defaults to "adopt".' + default: 'adopt' + + os: + type: string + description: 'Operating system to use for testing. Defaults to "ubuntu-latest".' + default: 'ubuntu-latest' + +runs: + using: "composite" + steps: + - name: "[Pre Testing] Debug Info" + shell: bash + run: | + echo "Java Version: ${{ inputs.java }}" + echo "Java Distribution: ${{ inputs.java_dist }}" + echo "Operating System: ${{ inputs.os }}" + + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: Setup JDK ${{ inputs.java }} + uses: actions/setup-java@v4 + with: + distribution: 'adopt' + java-version: ${{ inputs.java }} + + - name: Make Gradle Wrapper Executable + if: ${{ inputs.os != 'Windows' }} + shell: bash + run: chmod +x ./gradlew + + - name: Build Mod with Gradle + shell: bash + run: ./gradlew build --stacktrace diff --git a/.github/actions/set_to_env/action.yml b/.github/actions/set_to_env/action.yml new file mode 100644 index 0000000..c34e7dc --- /dev/null +++ b/.github/actions/set_to_env/action.yml @@ -0,0 +1,24 @@ +name: "Set Variable to Environment" +description: "Sets a value to an environment variable with respect to the operating system" + +inputs: + value: + type: string + description: 'Value to set to the environment variable.' + required: true + + env_var: + type: string + description: 'Name of the environment variable to set.' + required: true + +runs: + using: "composite" + steps: + - if: runner.os != 'Windows' + shell: bash + run: echo "${{ inputs.env_var }}=${{ inputs.value }}" >> $GITHUB_ENV + + - if: runner.os == 'Windows' + shell: powershell + run: echo "${{ inputs.env_var }}=${{ inputs.value }}" | Out-File -FilePath $env:GITHUB_ENV -Append diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 326b1b9..e867fc3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ # certain platforms or Java versions, and provides a first line of defence # against bad commits. -name: build +name: Build Check on: [pull_request, push] jobs: @@ -12,28 +12,27 @@ jobs: matrix: # Use these Java versions java: [ - 22, # Current Java LTS & minimum supported by Minecraft + 22 # Current Java LTS & minimum supported by Minecraft ] - # and run on both Linux and Windows - os: [ubuntu-20.04, windows-2022] + # Run on both Linux and Windows + os: + - ubuntu-latest + - windows-latest + runs-on: ${{ matrix.os }} steps: - - name: checkout repository - uses: actions/checkout@v2 - - name: validate gradle wrapper - uses: gradle/wrapper-validation-action@v1 - - name: setup jdk ${{ matrix.java }} - uses: actions/setup-java@v1 + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Prepare Testing + uses: ./.github/actions/prep with: - java-version: ${{ matrix.java }} - - name: make gradle wrapper executable - if: ${{ runner.os != 'Windows' }} - run: chmod +x ./gradlew - - name: build - run: ./gradlew build - - name: capture build artifacts - if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS - uses: actions/upload-artifact@v2 + java: ${{ matrix.java }} + os: ${{ matrix.os }} + + - name: Capture Build Artifacts + if: ${{ runner.os == 'Linux' && matrix.java == '22' }} # Only upload artifacts built from latest java on one OS + uses: actions/upload-artifact@v4 with: name: Artifacts path: build/libs/ diff --git a/.github/workflows/error_action.yml b/.github/workflows/error_action.yml deleted file mode 100644 index a078802..0000000 --- a/.github/workflows/error_action.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Gradle Error Checker - -on: [ push, pull_request ] -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Check for errors. - uses: github/super-linter@v4 - env: - VALIDATE_ALL_CODEBASE: false - GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/fabric.yml b/.github/workflows/fabric.yml new file mode 100644 index 0000000..db8769f --- /dev/null +++ b/.github/workflows/fabric.yml @@ -0,0 +1,64 @@ +name: Fabric Testing +on: [pull_request, push] + +jobs: + run: + strategy: + matrix: + version: + - {minecraft_version: "1.21.3", java: 22, loader: fabric, api: "0.110.0"} + os: + - ubuntu-latest + - windows-latest + + runs-on: ${{ matrix.os }} + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Prepare Testing + uses: ./.github/actions/prep + with: + java: ${{ matrix.version.java }} + java_dist: temurin + os: ubuntu-latest + + - name: Get jar name + uses: ./.github/actions/set_to_env + with: + value: $( ./gradlew -q :getJarName ) + env_var: JAR_NAME + + - name: Stage mod for test client + run: | + mkdir -p run/mods + cp build/libs/${{ env.JAR_NAME }}.jar run/mods + + - name: Download dependencies + uses: ./.github/actions/download_dependencies + with: + minecraft_version: ${{ matrix.version.minecraft_version }} + loader: ${{ matrix.version.loader }} + + + - name: "[Fabric Testing] Debug Info" + run: | + echo "Minecraft Version: ${{ matrix.version.minecraft_version }}" + echo "Mod Loader: ${{ matrix.version.loader }}" + echo "Regex: .*${{ matrix.version.loader }}.*" + echo "Java Version: ${{ matrix.version.java }}" + echo "Runtime Test Version: ${{ matrix.version.loader }}" + echo "Fabric API Version: ${{ matrix.version.api }}" + + - name: Run MC test client + uses: headlesshq/mc-runtime-test@3.0.0 + with: + mc: ${{ matrix.version.minecraft_version }} + modloader: ${{ matrix.version.loader }} + regex: .*${{ matrix.version.loader }}.* + java: ${{ matrix.version.java }} + mc-runtime-test: ${{ matrix.version.loader }} + xvfb: false + fabric-api: ${{ matrix.version.api }} + headlessmc-command: -lwjgl --jvm -Djava.awt.headless=true + diff --git a/README.md b/README.md index b0cfc0a..a30d9b7 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,34 @@ -![](https://github.com/Virus5600/Defensive-Measures-Mod/blob/main/Defensive%20Measures%20Add-On%20Banner.png) +