Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Actions Refactorization #24

Merged
merged 41 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7e66783
Update 20241230 - Actions Update
Virus5600 Dec 30, 2024
2fec128
Update fabric.yml
Virus5600 Dec 30, 2024
008d943
Update README.md
Virus5600 Dec 30, 2024
30fa0bb
Update README.md
Virus5600 Dec 30, 2024
f08fd5e
Update README.md
Virus5600 Dec 30, 2024
34024bd
Update fabric.yml
Virus5600 Dec 30, 2024
e273465
Update 20241230 - Actions Rework
Virus5600 Dec 30, 2024
f892fcc
Update fabric.yml
Virus5600 Dec 30, 2024
a8b256d
Update 20241230 - Actions Rework
Virus5600 Dec 30, 2024
718b087
Update 20241230 - Actions Rework
Virus5600 Dec 30, 2024
34efa21
Update 20241230 - Actions Rework
Virus5600 Dec 30, 2024
9b884dc
Update 20241230 - Actions Rework
Virus5600 Dec 30, 2024
66d9610
Update prep.yml
Virus5600 Dec 30, 2024
9d05012
Update 20241230 - Actions Rework
Virus5600 Dec 30, 2024
e789ef2
Refactor 20241230 - Composite Refactor
Virus5600 Dec 30, 2024
d57ce9a
Update action.yml
Virus5600 Dec 30, 2024
8d3c6a4
Update action.yml
Virus5600 Dec 30, 2024
e3acc78
Update action.yml
Virus5600 Dec 30, 2024
524e867
Hotfix 20241230 - Quick Action Hotfix
Virus5600 Dec 30, 2024
fdb208e
Update fabric.yml
Virus5600 Dec 30, 2024
09ae5be
Update fabric.yml
Virus5600 Dec 30, 2024
a99e463
Update fabric.yml
Virus5600 Dec 30, 2024
7b6c92a
Update fabric.yml
Virus5600 Dec 30, 2024
e94c1be
Update fabric.yml
Virus5600 Dec 30, 2024
0d6b51e
Fix Attempt 20241230 - Action Fix Attempt
Virus5600 Dec 30, 2024
ed2e235
Update action.yml
Virus5600 Dec 30, 2024
8b6a351
Fix Attempt 20241230 - Action Fix Attempt (1)
Virus5600 Dec 30, 2024
385b2f7
Fix Attempt 20241230 - Action Fix Attempt (2)
Virus5600 Dec 30, 2024
2541817
Fix Attempt 20241230 - Action Fix Attempt (3)
Virus5600 Dec 30, 2024
771d1a5
Fix Attempt 20241230 - Action Fix Attempt (4)
Virus5600 Dec 30, 2024
fca7fc7
Fix Attempt 20241230 - Action Fix Attempt (5)
Virus5600 Dec 30, 2024
f0cd7b3
Fix Attempt 20241230 - Action Fix Attempt (6)
Virus5600 Dec 30, 2024
484ee1a
Fix Attempt 20241230 - Action Fix Attempt (7)
Virus5600 Dec 30, 2024
b0183aa
Fix Attempt 20241230 - Action Fix Attempt (8)
Virus5600 Dec 30, 2024
556cbe8
Potential Fix 20241230 - Potential FIx to GHA
Virus5600 Dec 30, 2024
b03b422
Potential Fix 20241230 - Potential FIx to GHA (2)
Virus5600 Dec 30, 2024
e8f3783
Hotfix 20241230 - Typo Fix
Virus5600 Dec 30, 2024
cfeb0d0
Potential Fix 20241230 - Potential Fix to GHA (3)
Virus5600 Dec 30, 2024
e59ac41
Potential Fix 20241230 - Potential Fix to GHA (4)
Virus5600 Dec 30, 2024
2c5fdc4
Potential Fix 20241230 - Potential Fix to GHA (5)
Virus5600 Dec 30, 2024
2528cb6
Potential Fix 20241230 - Potential Fix to GHA (6)
Virus5600 Dec 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/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

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
Loading