Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 0 additions & 15 deletions .github/workflows/auto-merge-dependabot.yml

This file was deleted.

35 changes: 30 additions & 5 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,33 @@ on:
jobs:
run-ci:
uses: Jikoo/PlanarActions/.github/workflows/ci_maven.yml@master
store-dependabot-pr-data:
if: "github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'"
uses: Jikoo/PlanarActions/.github/workflows/pr_automerge_prep.yml@master
with:
pr-number: ${{ github.event.number }}
approve-and-merge-dependabot:
if: "github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]'"
needs: [ "run-ci" ]
runs-on: "ubuntu-latest"
permissions:
contents: write
pull-requests: write
steps:
# Always approve PRs from Dependabot.
- name: Approve
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

# Fetch Dependabot metadata for finer decisionmaking later.
- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

# Enable auto-merge for the PR.
# Auto-merge is used rather than a direct merge so that any other required checks can pass.
- name: Enable auto-merge for minor/patch updates
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor'
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.Phaser;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* Runnable for checking and deleting chunks and regions.
Expand Down Expand Up @@ -60,18 +63,36 @@ public void run() {
if (world == null) {
throw new IllegalStateException("Cannot reuse deletion runnable!");
}
world.getRegions().forEach(this::handleRegion);

Future<Stream<RegionInfo>> regionsFuture = plugin.getServer().getScheduler().callSyncMethod(plugin, world::getRegions);

Stream<RegionInfo> regions = null;
try {
// Fetch region info on the main thread. Getting data folder may throw a CME otherwise.
regions = regionsFuture.get();
} catch (InterruptedException | ExecutionException e) {
plugin.getLogger().severe("Unable to access world data!");
plugin.getLogger().log(Level.SEVERE, "Error accessing world data on main thread", e);
}

if (regions != null) {
regions.forEach(this::handleRegion);
}

// Release world reference.
world = null;
plugin.getLogger().info("Deletion cycle complete for " + getRunStats());
nextRun.set(System.currentTimeMillis() + plugin.config().getCycleDelayMillis());

// If configured to remember cycle delays across restarts, do post-run callback on the main thread.
if (plugin.config().isRememberCycleDelay()) {
try {
plugin.getServer().getScheduler().runTask(plugin, () -> plugin.finishCycle(this));
} catch (IllegalPluginAccessException e) {
// Plugin disabling, odds are on that we were mid-cycle. Don't update finish time.
}
}

phaser.arriveAndDeregister();
}

Expand Down