rebase
This commit is contained in:
@@ -37,7 +37,7 @@ jobs:
|
|||||||
- name: Build project to paperclip jar
|
- name: Build project to paperclip jar
|
||||||
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
|
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
|
||||||
with:
|
with:
|
||||||
arguments: createReobfPaperclipJar
|
arguments: createReobfBundlerJar createReobfPaperclipJar
|
||||||
- name: Capture build artifacts
|
- name: Capture build artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
64
.github/workflows/build_1_20_4_v2.yml
vendored
Normal file
64
.github/workflows/build_1_20_4_v2.yml
vendored
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
name: Luminol CI v2 - Ver/1.20.4
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "ver/1.20.4" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "ver/1.20.4" ]
|
||||||
|
# workflow_dispatch:
|
||||||
|
permissions: write-all
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: default
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Git Repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: '17'
|
||||||
|
- name: Setup Git Config
|
||||||
|
run: |
|
||||||
|
git config --global user.email "ci@luminolmc.com"
|
||||||
|
git config --global user.name "Luminol CI"
|
||||||
|
- name: Apply Patches
|
||||||
|
run: ./gradlew applyPatches
|
||||||
|
- name: Build
|
||||||
|
run: ./gradlew createReobfBundlerJar createReobfPaperclipJar
|
||||||
|
- uses: "actions/upload-artifact@v3"
|
||||||
|
with:
|
||||||
|
name: "Luminol CI Artifacts"
|
||||||
|
path: "build/libs/*.jar"
|
||||||
|
- name: Rename jar file
|
||||||
|
run: |
|
||||||
|
mv build/libs/luminol-bundler-1.20.4-R0.1-SNAPSHOT-reobf.jar build/libs/luminol-1.20.4-bundler.jar
|
||||||
|
mv build/libs/luminol-paperclip-1.20.4-R0.1-SNAPSHOT-reobf.jar build/libs/luminol-1.20.4-paperclip.jar
|
||||||
|
- name: setenv
|
||||||
|
run: |
|
||||||
|
sh scripts/SetENV.sh
|
||||||
|
echo "${{ env.tag }}"
|
||||||
|
- name: Create Release
|
||||||
|
if: "!contains(github.event.commits[0].message, '[release-skip]')"
|
||||||
|
uses: ncipollo/release-action@v1.12.0
|
||||||
|
with:
|
||||||
|
tag: ${{ env.tag }}
|
||||||
|
name: Luminol ${{ env.mcversion }} - ${{ env.commitid }}
|
||||||
|
body: |
|
||||||
|
📦Version: `${{ env.mcversion }}` | Commit ${{ env.commitid }} [](https://github.com/LeavesMC/LuminolMC/Luminol/download/${{ env.tag }}/luminol-1.20.4-paperclip.jar)
|
||||||
|
This release is automatically compiled by GitHub Actions
|
||||||
|
artifacts: |
|
||||||
|
build/libs/luminol-1.20.4-bundler.jar
|
||||||
|
build/libs/luminol-1.20.4-paperclip.jar
|
||||||
|
generateReleaseNotes: true
|
||||||
|
prerelease: ${{ env.pre }}
|
||||||
|
makeLatest: ${{ env.make_latest }}
|
||||||
|
token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
- name: Push to Api
|
||||||
|
if: "!contains(github.event.commits[0].message, '[release-skip]')"
|
||||||
|
env:
|
||||||
|
secret_v2: ${{ secrets.API_KEY }}
|
||||||
|
tag: ${{ env.tag }}
|
||||||
|
run: sh scripts/PushToAPI.sh
|
||||||
@@ -74,3 +74,4 @@ QQ群: [368632360](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=MfosKhcDd8Fdxn1MREu
|
|||||||
<img alt="Star历史表" src="https://api.star-history.com/svg?repos=LuminolMC/Luminol%2CLuminolMC/LightingLuminol&type=Date" />
|
<img alt="Star历史表" src="https://api.star-history.com/svg?repos=LuminolMC/Luminol%2CLuminolMC/LightingLuminol&type=Date" />
|
||||||
</picture>
|
</picture>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|||||||
@@ -7,3 +7,7 @@ org.gradle.caching = true
|
|||||||
org.gradle.parallel = true
|
org.gradle.parallel = true
|
||||||
org.gradle.vfs.watch = false
|
org.gradle.vfs.watch = false
|
||||||
org.gradle.jvmargs = -Xmx3G
|
org.gradle.jvmargs = -Xmx3G
|
||||||
|
|
||||||
|
mcVersion=1.20.4
|
||||||
|
GroupMCV=1.20
|
||||||
|
preVersion=false
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: MrHua269 <novau233@163.com>
|
||||||
|
Date: Fri, 12 Apr 2024 13:48:09 +0000
|
||||||
|
Subject: [PATCH] Rewrite linear region flush task dispatching
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
|
||||||
|
index e40989889f3821bb7484fc0bae5d94b033013904..dc5a5f42c9ca7a50295c18424722568a3ad33fa5 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFile.java
|
||||||
|
@@ -126,7 +126,7 @@ public class LinearRegionFile implements AbstractRegionFile, AutoCloseable {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void flush() throws IOException {
|
||||||
|
- if (isMarkedToSave()) flushWrapper(); // sync
|
||||||
|
+ if (getAndResetSaveMarker()) flushWrapper(); // sync
|
||||||
|
}
|
||||||
|
|
||||||
|
private void markToSave() {
|
||||||
|
@@ -134,10 +134,18 @@ public class LinearRegionFile implements AbstractRegionFile, AutoCloseable {
|
||||||
|
markedToSave.set(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
- public boolean isMarkedToSave() {
|
||||||
|
+ public boolean getAndResetSaveMarker() {
|
||||||
|
return markedToSave.getAndSet(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ public boolean isMarkedToSave(){
|
||||||
|
+ return this.markedToSave.get();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void resetSaveMarker(){
|
||||||
|
+ this.markedToSave.set(false);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
public void flushWrapper() {
|
||||||
|
try {
|
||||||
|
save();
|
||||||
|
diff --git a/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFileFlusher.java b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFileFlusher.java
|
||||||
|
index f06d7767c79e465f999b2032086cc224de95152a..65435eb666b2e1cabffc145e016faa5e3b373464 100644
|
||||||
|
--- a/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFileFlusher.java
|
||||||
|
+++ b/src/main/java/dev/kaiijumc/kaiiju/region/LinearRegionFileFlusher.java
|
||||||
|
@@ -1,17 +1,14 @@
|
||||||
|
package dev.kaiijumc.kaiiju.region;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
|
-import java.util.Queue;
|
||||||
|
+
|
||||||
|
+import java.util.Set;
|
||||||
|
import java.util.concurrent.*;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
public class LinearRegionFileFlusher {
|
||||||
|
- private final Queue<LinearRegionFile> savingQueue = new LinkedBlockingQueue<>();
|
||||||
|
- private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(
|
||||||
|
- new ThreadFactoryBuilder()
|
||||||
|
- .setNameFormat("linear-flush-scheduler")
|
||||||
|
- .build()
|
||||||
|
- );
|
||||||
|
+ private final Set<LinearRegionFile> pendingSaving = ConcurrentHashMap.newKeySet();
|
||||||
|
+
|
||||||
|
private final ExecutorService executor = Executors.newFixedThreadPool(
|
||||||
|
me.earthme.luminol.config.modules.misc.RegionFormatConfig.linearFlushThreads,
|
||||||
|
new ThreadFactoryBuilder()
|
||||||
|
@@ -19,26 +16,42 @@ public class LinearRegionFileFlusher {
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
|
+ private final Executor delayedFlusher = CompletableFuture.delayedExecutor(
|
||||||
|
+ me.earthme.luminol.config.modules.misc.RegionFormatConfig.linearFlushFrequency,
|
||||||
|
+ TimeUnit.SECONDS,
|
||||||
|
+ executor
|
||||||
|
+ );
|
||||||
|
+
|
||||||
|
public LinearRegionFileFlusher() {
|
||||||
|
Bukkit.getLogger().info("Using " + me.earthme.luminol.config.modules.misc.RegionFormatConfig.linearFlushThreads + " threads for linear region flushing.");
|
||||||
|
- scheduler.scheduleAtFixedRate(this::pollAndFlush, 0L, me.earthme.luminol.config.modules.misc.RegionFormatConfig.linearFlushFrequency, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void scheduleSave(LinearRegionFile regionFile) {
|
||||||
|
- if (savingQueue.contains(regionFile)) return;
|
||||||
|
- savingQueue.add(regionFile);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- private void pollAndFlush() {
|
||||||
|
- while (!savingQueue.isEmpty()) {
|
||||||
|
- LinearRegionFile regionFile = savingQueue.poll();
|
||||||
|
- if (!regionFile.closed && regionFile.isMarkedToSave())
|
||||||
|
- executor.execute(regionFile::flushWrapper);
|
||||||
|
+ if (this.pendingSaving.contains(regionFile) || !regionFile.isMarkedToSave()){
|
||||||
|
+ return;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ this.pendingSaving.add(regionFile);
|
||||||
|
+ this.delayedFlusher.execute(()->{
|
||||||
|
+ try {
|
||||||
|
+ if (!regionFile.closed && regionFile.isMarkedToSave()){
|
||||||
|
+ regionFile.flushWrapper();
|
||||||
|
+ }
|
||||||
|
+ }finally {
|
||||||
|
+ regionFile.resetSaveMarker();
|
||||||
|
+ this.pendingSaving.remove(regionFile);
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shutdown() {
|
||||||
|
- executor.shutdown();
|
||||||
|
- scheduler.shutdown();
|
||||||
|
+ this.executor.shutdown();
|
||||||
|
+ for (;;) {
|
||||||
|
+ try {
|
||||||
|
+ if (this.executor.awaitTermination(5_00,TimeUnit.MILLISECONDS)) break;
|
||||||
|
+ } catch (InterruptedException e) {
|
||||||
|
+ e.printStackTrace();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
sha256() {
|
||||||
|
sha256sum $1 | awk '{print $1}'
|
||||||
|
}
|
||||||
|
|
||||||
|
prop() {
|
||||||
|
grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//'
|
||||||
|
}
|
||||||
|
|
||||||
|
project_id="luminol"
|
||||||
|
mcversion_group=$(prop GroupMCV)
|
||||||
|
mcversion=$(prop mcVersion)
|
||||||
|
pre=$(prop preVersion)
|
||||||
|
|
||||||
|
if [ $pre = "true" ]; then
|
||||||
|
channel="experimental"
|
||||||
|
else
|
||||||
|
channel="default"
|
||||||
|
fi
|
||||||
|
changes=$(git log -1 --pretty="[{\"commit\": \"%H\", \"message\": \"%s\", \"summary\": \"%s\"}]")
|
||||||
|
jar_sha256=`sha256 build/libs/luminol-1.20.4-paperclip.jar`
|
||||||
|
jar_name="luminol-1.20.4-paperclip.jar"
|
||||||
|
ctime=$(date -u +"%s")"000"
|
||||||
|
|
||||||
|
# v2
|
||||||
|
echo "Authentication: $secret_v2"
|
||||||
|
#echo "{\"version_group\":\"$mcversion_group\",\"channel\":\"$channel\",\"changes\":\"$changes\",\"jar_name\":\"$jar_name\",\"sha256\":\"$jar_sha256\",\"release_tag\":\"$tag\",\"time\":\"$ctime\"}" > data.json
|
||||||
|
json=$(printf "{\\\"channel\\\":\\\"%s\\\", \\\"jar_name\\\":\\\"%s\\\", \\\"sha256\\\":\\\"%s\\\", \\\"tag\\\":\\\"%s\\\", \\\"time\\\":\\\"%s\\\", \\\"changes\\\":\\\"%s\\\"}" \
|
||||||
|
"$channel" "$jar_name" "$jar_sha256" "$tag" "$ctime" "$changes")
|
||||||
|
echo "[DEBUG] $json"
|
||||||
|
echo "[DEBUG] $changes"
|
||||||
|
echo "[DEBUG] curl --location --request POST \"https://api.luminolmc.com/v2/projects/$project_id/$mcversion/build/commit\" \
|
||||||
|
-H \"Content-Type: application/x-www-form-urlencoded\" \
|
||||||
|
-H \"Authorization: $secret_v2\" \
|
||||||
|
--data-urlencode \"channel=$channel\" \
|
||||||
|
--data-urlencode \"jar_name=$jar_name\" \
|
||||||
|
--data-urlencode \"sha256=$jar_sha256\" \
|
||||||
|
--data-urlencode \"release_tag=$tag\" \
|
||||||
|
--data-urlencode \"time=$ctime\" \
|
||||||
|
--data-urlencode \"changes=$changes\""
|
||||||
|
curl -L --request POST "https://api.luminolmc.com/v2/projects/$project_id/$mcversion/build/commit" \
|
||||||
|
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||||
|
-H "Authorization: $secret_v2" \
|
||||||
|
--data-urlencode "channel=$channel" \
|
||||||
|
--data-urlencode "jar_name=$jar_name" \
|
||||||
|
--data-urlencode "sha256=$jar_sha256" \
|
||||||
|
--data-urlencode "release_tag=$tag" \
|
||||||
|
--data-urlencode "time=$ctime" \
|
||||||
|
--data-urlencode "changes=$changes"
|
||||||
|
|||||||
18
scripts/SetENV.sh
Normal file
18
scripts/SetENV.sh
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
prop() {
|
||||||
|
grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//'
|
||||||
|
}
|
||||||
|
|
||||||
|
commitid=$(git log --pretty='%h' -1)
|
||||||
|
mcversion=$(prop mcVersion)
|
||||||
|
preVersion=$(prop preVersion)
|
||||||
|
release_tag="$mcversion-$commitid"
|
||||||
|
jarName="build/libs/luminol-1.20.4-paperclip.jar"
|
||||||
|
make_latest=$([ $preVersion = "true" ] && echo "false" || echo "true")
|
||||||
|
|
||||||
|
echo "commitid=$commitid" >> $GITHUB_ENV
|
||||||
|
echo "mcversion=$mcversion" >> $GITHUB_ENV
|
||||||
|
echo "$mcversion"
|
||||||
|
echo "tag=$release_tag" >> $GITHUB_ENV
|
||||||
|
echo "jar=$jarName" >> $GITHUB_ENV
|
||||||
|
echo "pre=$preVersion" >> $GITHUB_ENV
|
||||||
|
echo "make_latest=$make_latest" >> $GITHUB_ENV
|
||||||
Reference in New Issue
Block a user