Skip to content

Commit

Permalink
GitHub Actions Refactorization (#24)
Browse files Browse the repository at this point in the history
* Update 20241230 - Actions Update

Attempt to update GitHub CI.

[CHANGELOG]
🟢 Added Fabric CI action under fabric.yml.
🟡 Updated the editor configuration file.
🟡 Updated the Build Check action for readability and to update the "capture build artifacts" step.
🟡 Updated README.
🔴 Removed Gradle Error Checker action by removing the error_action.yml file.

* Update fabric.yml

* Update README.md

* Update README.md

* Update README.md

* Update fabric.yml

* Update 20241230 - Actions Rework

Reworked the actions after the last fabric action used was outdated by 4 years.

* Update fabric.yml

* Update 20241230 - Actions Rework

* Update 20241230 - Actions Rework

* Update 20241230 - Actions Rework

* Update 20241230 - Actions Rework

* Update prep.yml

* Update 20241230 - Actions Rework

* Refactor 20241230 - Composite Refactor

Refactored the composite action for the workflow.

* Update action.yml

* Update action.yml

* Update action.yml

* Hotfix 20241230 - Quick Action Hotfix

* Update fabric.yml

* Update fabric.yml

* Update fabric.yml

* Update fabric.yml

* Update fabric.yml

* Fix Attempt 20241230 - Action Fix Attempt

* Update action.yml

* Fix Attempt 20241230 - Action Fix Attempt (1)

* Fix Attempt 20241230 - Action Fix Attempt (2)

* Fix Attempt 20241230 - Action Fix Attempt (3)

* Fix Attempt 20241230 - Action Fix Attempt (4)

* Fix Attempt 20241230 - Action Fix Attempt (5)

* Fix Attempt 20241230 - Action Fix Attempt (6)

* Fix Attempt 20241230 - Action Fix Attempt (7)

* Fix Attempt 20241230 - Action Fix Attempt (8)

* Potential Fix 20241230 - Potential FIx to GHA

Potential fix for the perpetual failing GitHub Actions implementation since yesterday.

PS: HALP! 助けて! Tulong! 帮助! Pomoc! 俺は losing my utak!

* Potential Fix 20241230 - Potential FIx to GHA (2)

* Hotfix 20241230 - Typo Fix

* Potential Fix 20241230 - Potential Fix to GHA (3)

* Potential Fix 20241230 - Potential Fix to GHA (4)

* Potential Fix 20241230 - Potential Fix to GHA (5)

* Potential Fix 20241230 - Potential Fix to GHA (6)
  • Loading branch information
Virus5600 authored Dec 30, 2024
1 parent 7d09ba9 commit 2eeb61a
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 42 deletions.
6 changes: 3 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 28 additions & 0 deletions .github/actions/download_dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -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"
46 changes: 46 additions & 0 deletions .github/actions/prep/action.yml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions .github/actions/set_to_env/action.yml
Original file line number Diff line number Diff line change
@@ -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
37 changes: 18 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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/
16 changes: 0 additions & 16 deletions .github/workflows/error_action.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/fabric.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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

32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
![](https://github.com/Virus5600/Defensive-Measures-Mod/blob/main/Defensive%20Measures%20Add-On%20Banner.png)
<div align="center" style="text-align: center">
<img src="https://img.shields.io/github/actions/workflow/status/Virus5600/Defensive-Measures-Mod/build.yml?logo=gradle&amp;label=Build%20Check" alt="GitHub Actions Workflow Status">&nbsp;&nbsp;&nbsp;&nbsp;
<img src="https://img.shields.io/github/actions/workflow/status/Virus5600/Defensive-Measures-Mod/fabric.yml?logo=gradle&amp;label=Fabric%20Test%20Runner" alt="GitHub Actions Workflow Status">&nbsp;&nbsp;&nbsp;&nbsp;
</div>
<br>

<div align="center" style="text-align: center">
<img src="https://img.shields.io/modrinth/v/defensive-measures?logo=modrinth&amp;label=Latest%20Modrinth%20Release" alt="Modrinth Version">&nbsp;&nbsp;&nbsp;&nbsp;
<img src="https://img.shields.io/curseforge/v/700629?logo=curseforge&amp;label=Latest%20CurseForge%20Release" alt="CurseForge Version">&nbsp;&nbsp;&nbsp;&nbsp;
<img src="https://img.shields.io/github/v/tag/Virus5600/Defensive-Measures-Mod?include_prereleases&amp;sort=semver&amp;logo=github&amp;label=Latest%20GitHub%20Tag" alt="GitHub Tag">&nbsp;&nbsp;&nbsp;&nbsp;
<img src="https://img.shields.io/github/v/release/Virus5600/Defensive-Measures-Mod?logo=semanticrelease&amp;label=Latest%20Release" alt="GitHub release (latest by date)">&nbsp;&nbsp;&nbsp;&nbsp;
</div>
<br>

<div align="center" style="text-align: center">
<img src="https://img.shields.io/modrinth/dt/defensive-measures?logo=modrinth&amp;label=Modrinth%20Downloads" alt="Modrinth Downloads">&nbsp;&nbsp;&nbsp;&nbsp;
<img src="https://img.shields.io/curseforge/dt/700629?logo=curseforge&amp;label=CureForge%20Downloads" alt="CurseForge Downloads">&nbsp;&nbsp;&nbsp;&nbsp;
<img src="https://img.shields.io/github/downloads/Virus5600/Defensive-Measures-Mod/total?logo=github&amp;label=GitHub%20Downloads" alt="GitHub Downloads (all assets, all releases)">&nbsp;&nbsp;&nbsp;&nbsp;
</div>
<br>

<div align="center" style="text-align: center">
<img src="https://raw.githubusercontent.com/Virus5600/Defensive-Measures-Mod/refs/heads/main/Defensive%20Measures%20Add-On%20Banner.png" alt="Defensive Measures Banner" width="100%">
</div>


# Defensive-Measures

Defensive Add-on is an add-on that allows players to place defensive turrets and traps to protect themselves, their creations, positions, and so on. The add-on adds <b><i>Towers</i></b>, <b><i>Traps</i></b>, <b><i>Entities</i></b>, <b><i>Structures</i></b>, <b><i>Villager Variants</i></b>, and <b><i>Items</i></b> to the game, which opens a lot of new capabilities, ideas, and creative imaginations for the players to explore.

# SOCIAL LINKS
# SUPPORT ME

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/D1D6BFRR3)<br>
<a href="https://www.paypal.com/donate/?hosted_button_id=T5LTYWVFU29R8"><img src="https://github.com/Virus5600/Defensive-Measures-Add-on-Guide/blob/main/public/images/UI/paypal_donate.png" height="30px"></a>
<a href="https://www.paypal.com/donate/?hosted_button_id=T5LTYWVFU29R8"><img src="https://raw.githubusercontent.com/Virus5600/Defensive-Measures-Add-on-Guide/refs/heads/main/public/images/UI/paypal_donate.png" height="30px"></a>
18 changes: 18 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ dependencies {
// GeckoLib
modImplementation "software.bernie.geckolib:geckolib-fabric-${minecraft_version}:${geckolib_version}"

// Testing
testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}"
}

processResources {
Expand Down Expand Up @@ -94,3 +96,19 @@ publishing {
// retrieving dependencies.
}
}

test {
useJUnitPlatform()
}

// All custom tasks goes below this line

/** Prints the built jar name. */
tasks.register("getJarName") {
println("${project.archives_base_name}-${project.version}")
}

/** Prints the Geckolib3 version */
tasks.register("getGeckolib3Version") {
println("${project.geckolib_version}")
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx2G
org.gradle.jvmargs=-Xmx4G
org.gradle.parallel=true

# Fabric Properties
Expand Down

0 comments on commit 2eeb61a

Please sign in to comment.