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
64 changes: 34 additions & 30 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ jobs:
isInRepo: ${{ steps.save-var.outputs.IS_IN_REPO }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Check for latest
id: save-var
run: |
if [[ -e "${{ env.VERSIONS_LOCATION }}${{ github.event.inputs.VERSION }}" ]]; then echo "IS_IN_REPO=true" >> $GITHUB_OUTPUT; else echo "IS_IN_REPO=false" >> $GITHUB_OUTPUT; fi

- name: Is latest in repo?
run: echo "${{ steps.save-var.outputs.IS_IN_REPO }}"

Expand All @@ -40,38 +42,49 @@ jobs:
if: ${{ github.event.inputs.VERSION != null && github.event.inputs.IS_RELEASE != null && needs.is-in-repo.outputs.isInRepo == 'false' }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: master
uses: actions/checkout@v6

- name: Create server folder
run: mkdir server

- name: Get previous version
run: echo "PREVIOUS_VERSION=$(curl -sSL "https://piston-meta.mojang.com/mc/game/version_manifest.json" | jq -cr '[.versions[] | select(.type == "release")] [1] .id')" >> $GITHUB_ENV

- name: Start server for world creation
run: docker run --rm --name mc -e EULA=TRUE -e UID="$(id -u)" -e VERSION=${{ github.event.inputs.VERSION }} -e ENABLE_AUTOSTOP=TRUE -e AUTOSTOP_TIMEOUT_INIT=5 -e MEMORY=8G -v ./server:/data itzg/minecraft-server:latest --forceUpgrade

- name: Copy old regions into server
run: /bin/cp -rf ${{ env.VERSIONS_LOCATION }}${{ env.PREVIOUS_VERSION }}/region server/world/dimensions/minecraft/overworld

- name: Get last version
run: echo "LAST_VERSION=$(curl -sSL "https://piston-meta.mojang.com/mc/game/version_manifest.json" | jq -cr '[.versions[] | select(.type == "release")] [1] .id')" >> $GITHUB_ENV
- name: Copy old entities into server
run: /bin/cp -rf ${{ env.VERSIONS_LOCATION }}${{ env.PREVIOUS_VERSION }}/entities server/world/dimensions/minecraft/overworld

- name: Delete latest version folder
run: rm -rf ${{ env.VERSIONS_LOCATION }}latest
- name: Start server for upgrade
run: docker run --rm --name mc -e EULA=TRUE -e UID="$(id -u)" -e VERSION=${{ github.event.inputs.VERSION }} -e ENABLE_AUTOSTOP=TRUE -e AUTOSTOP_TIMEOUT_INIT=5 -e MEMORY=8G -v ./server:/data itzg/minecraft-server:latest --forceUpgrade

- name: Copy last version into latest folder
run: cp -R ${{ env.VERSIONS_LOCATION }}${{ env.LAST_VERSION }} ${{ env.VERSIONS_LOCATION }}latest
- name: Create latest version folder
run: mkdir ${{ env.VERSIONS_LOCATION }}${{ github.event.inputs.VERSION }}

- name: Start server
run: docker run --name mc -e EULA=TRUE -e UID="$(id -u)" -e VERSION=${{ github.event.inputs.VERSION }} -e ENABLE_AUTOSTOP=TRUE -e AUTOSTOP_TIMEOUT_INIT=5 -e MEMORY=8G -v "$GITHUB_WORKSPACE"/${{ env.VERSIONS_LOCATION }}latest itzg/minecraft-server:latest --forceUpgrade
- name: Copy upgraded regions into version folder
run: /bin/cp -rf server/world/dimensions/minecraft/overworld/region ${{ env.VERSIONS_LOCATION }}${{ github.event.inputs.VERSION }}

- name: Copy upgraded world into version folder
run: cp -R ${{ env.VERSIONS_LOCATION }}latest ${{ env.VERSIONS_LOCATION }}${{ github.event.inputs.VERSION }}
- name: Copy upgraded entities into version folder
run: /bin/cp -rf server/world/dimensions/minecraft/overworld/entities ${{ env.VERSIONS_LOCATION }}${{ github.event.inputs.VERSION }}

- name: Delete server folder
run: rm -rf server

- if: ${{ github.event.inputs.IS_RELEASE == 'true' }}
name: Committing to master
uses: EndBug/add-and-commit@v9
uses: EndBug/add-and-commit@v10
with:
add: './${{ env.VERSIONS_LOCATION }}${{ github.event.inputs.VERSION }}/*'
message: 'add latest Minecraft world'
push: true

- if: ${{ github.event.inputs.IS_RELEASE == 'false' }}
name: Committing to snapshots
uses: EndBug/add-and-commit@v9
uses: EndBug/add-and-commit@v10
with:
add: './${{ env.VERSIONS_LOCATION }}${{ github.event.inputs.VERSION }}/*'
new_branch: snapshots
message: 'add latest Minecraft world'
push: true
Expand All @@ -90,17 +103,8 @@ jobs:
if: always()

steps:
- if: ${{ github.event.inputs.IS_RELEASE == 'true' || github.event.inputs.IS_RELEASE == null }}
name: Checkout master
uses: actions/checkout@v4
with:
ref: master

- if: ${{ github.event.inputs.IS_RELEASE == 'false' }}
name: Checkout snapshots
uses: actions/checkout@v4
with:
ref: snapshots
- name: Checkout repo
uses: actions/checkout@v6

- name: Show resource folder
run: tree ${{ env.VERSIONS_LOCATION }}
Expand Down Expand Up @@ -138,7 +142,7 @@ jobs:
if: ${{ always() && github.event.inputs.IS_RELEASE != null && github.event.inputs.IS_RELEASE == 'false' }}
steps:
- name: Checkout snapshots
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
ref: snapshots

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed examples/resources/versions/26.1/entities/r.0.0.mca
Binary file not shown.
Binary file removed examples/resources/versions/26.1/region/r.-1.-1.mca
Binary file not shown.
Binary file removed examples/resources/versions/26.1/region/r.-1.0.mca
Binary file not shown.
Binary file removed examples/resources/versions/26.1/region/r.-2.-1.mca
Binary file not shown.
Binary file not shown.
Binary file removed examples/resources/versions/26.1/region/r.0.-1.mca
Binary file not shown.
Binary file removed examples/resources/versions/26.1/region/r.0.0.mca
Binary file not shown.
13 changes: 2 additions & 11 deletions tests/integration/HawkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ function copyTestFiles($src = null, $dst = null)
closedir($dir);
}


/**
* @return array
* @throws Exception
Expand All @@ -93,11 +92,7 @@ public function provideSingleBlockFile(): array
foreach ($versions as $version) {
if (!$version->isDot()) {
$dirName = $version->getFilename();
$major = null;
if (str_contains($dirName, ".")) {
$major = explode(".", $dirName)[1];
}
if ($major > 16 || $dirName === "latest") {
if (version_compare($dirName, "1.17", ">=") || $dirName === "latest") {
$blockFiles[$dirName] = [
[
new File(__DIR__ . "/../files/versions/" . $dirName . "/region/r.0.0.mca")
Expand Down Expand Up @@ -131,11 +126,7 @@ public function provideNegativeSingleBlockFile(): array
foreach ($versions as $version) {
if (!$version->isDot()) {
$dirName = $version->getFilename();
$major = null;
if (str_contains($dirName, ".")) {
$major = explode(".", $dirName)[1];
}
if ($major > 16 || $dirName === "latest") {
if (version_compare($dirName, "1.17", ">=") || $dirName === "latest") {
$blockFiles[$dirName] = [
[
new File(__DIR__ . "/../files/versions/" . $dirName . "/region/r.-1.-1.mca")
Expand Down
24 changes: 4 additions & 20 deletions tests/unit/HawkTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,10 @@ public function provideSingleBlockFile(): array
foreach ($versions as $version) {
if (!$version->isDot()) {
$dirName = $version->getFilename();
$major = null;
if (str_contains($dirName, ".")) {
$major = explode(".", $dirName)[1];
}
$regionFile = new File(__DIR__ . "/../../examples/resources/versions/" . $dirName . "/region/r.0.0.mca");
$this->files[] = $regionFile;
$entityFile = null;
if ($major > 16 || $dirName === "latest") {
if (version_compare($dirName, "1.17", ">=") || $dirName === "latest") {
$entityFile = new File(__DIR__ . "/../../examples/resources/versions/" . $dirName . "/entities/r.0.0.mca");
$this->files[] = $entityFile;
}
Expand All @@ -172,14 +168,10 @@ public function provideNegativeSingleBlockFile(): array
foreach ($versions as $version) {
if (!$version->isDot()) {
$dirName = $version->getFilename();
$major = null;
if (str_contains($dirName, ".")) {
$major = explode(".", $dirName)[1];
}
$regionFile = new File(__DIR__ . "/../../examples/resources/versions/" . $dirName . "/region/r.-1.-1.mca");
$this->files[] = $regionFile;
$entityFile = null;
if ($major > 16 || $dirName === "latest") {
if (version_compare($dirName, "1.17", ">=") || $dirName === "latest") {
$entityFile = new File(__DIR__ . "/../../examples/resources/versions/" . $dirName . "/entities/r.-1.-1.mca");
$this->files[] = $entityFile;
}
Expand All @@ -199,10 +191,6 @@ public function provideMultipleBlockFiles(): array
foreach ($versions as $version) {
if (!$version->isDot()) {
$dirName = $version->getFilename();
$major = null;
if (str_contains($dirName, ".")) {
$major = explode(".", $dirName)[1];
}
$blockFiles[$dirName] = [];
$regionFile = new File(__DIR__ . "/../../examples/resources/versions/" . $dirName . "/region/r.0.0.mca");
$regionFileTwo = new File(__DIR__ . "/../../examples/resources/versions/" . $dirName . "/region/r.-1.-1.mca");
Expand All @@ -211,7 +199,7 @@ public function provideMultipleBlockFiles(): array
$this->files[] = $regionFileTwo;
$entityFile = null;
$entityFileTwo = null;
if ($major > 16 || $dirName === "latest") {
if (version_compare($dirName, "1.17", ">=") || $dirName === "latest") {
$entityFile = new File(__DIR__ . "/../../examples/resources/versions/" . $dirName . "/entities/r.0.0.mca");
$entityFileTwo = new File(__DIR__ . "/../../examples/resources/versions/" . $dirName . "/entities/r.-1.-1.mca");
$blockFiles[$dirName][] = [$entityFile, $entityFileTwo];
Expand All @@ -232,10 +220,6 @@ public function provideMultipleEqualBlockFiles(): array
foreach ($versions as $version) {
if (!$version->isDot()) {
$dirName = $version->getFilename();
$major = null;
if (str_contains($dirName, ".")) {
$major = explode(".", $dirName)[1];
}
$blockFiles[$dirName] = [];
$regionFile = new File(__DIR__ . "/../../examples/resources/versions/" . $dirName . "/region/r.0.0.mca");
$regionFileTwo = new File(__DIR__ . "/../../examples/resources/versions/" . $dirName . "/region/r.0.0.mca");
Expand All @@ -244,7 +228,7 @@ public function provideMultipleEqualBlockFiles(): array
$this->files[] = $regionFileTwo;
$entityFile = null;
$entityFileTwo = null;
if ($major > 16 || $dirName === "latest") {
if (version_compare($dirName, "1.17", ">=") || $dirName === "latest") {
$entityFile = new File(__DIR__ . "/../../examples/resources/versions/" . $dirName . "/entities/r.0.0.mca");
$entityFileTwo = new File(__DIR__ . "/../../examples/resources/versions/" . $dirName . "/entities/r.0.0.mca");
$blockFiles[$dirName][] = [$entityFile, $entityFileTwo];
Expand Down
Loading