From 4a534f81da99b233948af1c5e779e486945c32ee Mon Sep 17 00:00:00 2001 From: mechoriet Date: Sat, 15 Apr 2023 21:04:41 +0200 Subject: [PATCH 1/8] add cache for base folder since it will never change so its not worth to decompile/patch every single time --- .github/workflows/build.yml | 15 +++++++++++++-- panda | 2 +- scripts/build.sh | 1 - 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3591d0a9..69ffaf67 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - cache-refinement jobs: build: @@ -22,8 +23,18 @@ jobs: git config --global user.email "actions@github.com" git config --global user.name "GitHub Actions" git config --global init.defaultBranch master - - - name: Setup build environment + - name: Cache base/paper folder + id: cache-base + uses: actions/cache@v3 + env: + cache-name: cache-paper-base + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/base + key: cache-paper-base-${{ github.ref_name }} + restore-keys: cache-paper-base-${{ github.ref_name }} + - if: ${{ steps.cache-base.outputs.cache-hit != 'true' }} + name: Setup build environment run: ./panda setup - name: Apply patches diff --git a/panda b/panda index 2692b0b9..3747c519 100755 --- a/panda +++ b/panda @@ -56,7 +56,7 @@ case "$1" in ( set -e cd "$basedir" - scripts/build.sh "$basedir" || exit 1 + ./scripts/applyPatches.sh "$basedir" || exit 1 ) || failed=1 ;; "j" | "jar") diff --git a/scripts/build.sh b/scripts/build.sh index 485920ed..60e18cbf 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -15,7 +15,6 @@ if [ "$2" == "--setup" ] || [ "$2" == "--jar" ]; then ./scripts/decompile.sh "$basedir" ./scripts/init.sh "$basedir" fi -./scripts/applyPatches.sh "$basedir" "$2" if [ "$2" == "--jar" ]; then ./gradlew build && ./scripts/paperclip.sh "$basedir" From 3a3e18f4312873e3c8df8d60bbb5d9f14d14e695 Mon Sep 17 00:00:00 2001 From: mechoriet Date: Sat, 15 Apr 2023 21:05:46 +0200 Subject: [PATCH 2/8] remove the branch since it won't run anyway --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 69ffaf67..36c22c93 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,6 @@ on: push: branches: - master - - cache-refinement jobs: build: From 99e9e395e2fa1d50c3e2f1e83b1138b6370d596a Mon Sep 17 00:00:00 2001 From: mechoriet Date: Sat, 15 Apr 2023 21:09:24 +0200 Subject: [PATCH 3/8] fixed indentations --- .github/workflows/build.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 36c22c93..24866d68 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,8 +30,7 @@ jobs: with: # npm cache files are stored in `~/.npm` on Linux/macOS path: ~/base - key: cache-paper-base-${{ github.ref_name }} - restore-keys: cache-paper-base-${{ github.ref_name }} + key: cache-paper-base-${{ github.ref_name }} - if: ${{ steps.cache-base.outputs.cache-hit != 'true' }} name: Setup build environment run: ./panda setup @@ -48,7 +47,6 @@ jobs: - name: Copy Paperclip jar run: | cp -v "./paperclip/build/libs/paperclip-1.8.8-R0.1-SNAPSHOT.jar" "./pandaspigot-$GITHUB_RUN_NUMBER.jar" - - name: Upload artifacts uses: actions/upload-artifact@v3 with: From c8d5b86eba169855d3d9fa1d83247c95a7b4d546 Mon Sep 17 00:00:00 2001 From: mechoriet Date: Sat, 15 Apr 2023 22:18:53 +0200 Subject: [PATCH 4/8] changed so setup only sets up paperspigot so we can cache that and panda patch on applies pandapaper --- .github/workflows/build.yml | 2 +- scripts/applyPatches.sh | 23 +++++++++++++---------- scripts/build.sh | 1 + 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 24866d68..2ad331d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ jobs: with: # npm cache files are stored in `~/.npm` on Linux/macOS path: ~/base - key: cache-paper-base-${{ github.ref_name }} + key: cache-paper-base - if: ${{ steps.cache-base.outputs.cache-hit != 'true' }} name: Setup build environment run: ./panda setup diff --git a/scripts/applyPatches.sh b/scripts/applyPatches.sh index 70a24f3c..a698a799 100755 --- a/scripts/applyPatches.sh +++ b/scripts/applyPatches.sh @@ -105,18 +105,21 @@ if [ "$2" == "--setup" ] || [ "$2" == "--jar" ]; then echo "Importing MC Dev" ./scripts/importmcdev.sh "$basedir" || exit 1 + if [ "$2" == "--setup" ]; then + exit 1 + fi elif [ ! -d "base/Paper/PaperSpigot-Server" ]; then echo "Upstream directory does not exist. Did you forget to run 'panda setup'?" exit 1 +else + # Apply PandaSpigot + ( + applyPatch "base/Paper/PaperSpigot-API" PandaSpigot-API HEAD patches/api && + applyPatch "base/Paper/PaperSpigot-Server" PandaSpigot-Server HEAD patches/server + cd "$basedir" + ) || ( + echo "Failed to apply Paper Patches" + exit 1 + ) || exit 1 fi - -# Apply PandaSpigot -( - applyPatch "base/Paper/PaperSpigot-API" PandaSpigot-API HEAD patches/api && - applyPatch "base/Paper/PaperSpigot-Server" PandaSpigot-Server HEAD patches/server - cd "$basedir" -) || ( - echo "Failed to apply Paper Patches" - exit 1 -) || exit 1 ) || exit 1 diff --git a/scripts/build.sh b/scripts/build.sh index 60e18cbf..485920ed 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -15,6 +15,7 @@ if [ "$2" == "--setup" ] || [ "$2" == "--jar" ]; then ./scripts/decompile.sh "$basedir" ./scripts/init.sh "$basedir" fi +./scripts/applyPatches.sh "$basedir" "$2" if [ "$2" == "--jar" ]; then ./gradlew build && ./scripts/paperclip.sh "$basedir" From 5500b01bc1903dc2461bdf1850a03c0797944da1 Mon Sep 17 00:00:00 2001 From: mechoriet Date: Sun, 16 Apr 2023 20:24:11 +0200 Subject: [PATCH 5/8] also added a seperate cache for pr so if it brakes it only brakes on one side --- .github/workflows/build.yml | 2 +- .github/workflows/check.yml | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2ad331d3..99740f54 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ jobs: with: # npm cache files are stored in `~/.npm` on Linux/macOS path: ~/base - key: cache-paper-base + key: cache-paper-base-master - if: ${{ steps.cache-base.outputs.cache-hit != 'true' }} name: Setup build environment run: ./panda setup diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 6b2137c0..55f95f6e 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -19,8 +19,17 @@ jobs: git config --global user.email "actions@github.com" git config --global user.name "GitHub Actions" git config --global init.defaultBranch master - - - name: Setup build environment + - name: Cache base/paper folder + id: cache-base + uses: actions/cache@v3 + env: + cache-name: cache-paper-base + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/base + key: cache-paper-base-pr + - if: ${{ steps.cache-base.outputs.cache-hit != 'true' }} + name: Setup build environment run: ./panda setup - name: Apply patches From 38722dcae4095dd1551dd66fc778a35d9cde0448 Mon Sep 17 00:00:00 2001 From: mechoriet Date: Sun, 16 Apr 2023 20:29:31 +0200 Subject: [PATCH 6/8] should be fine to use ~ but just keep working directory as base for folder --- .github/workflows/build.yml | 2 +- .github/workflows/check.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 99740f54..5324a049 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: cache-name: cache-paper-base with: # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/base + path: ./base key: cache-paper-base-master - if: ${{ steps.cache-base.outputs.cache-hit != 'true' }} name: Setup build environment diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 55f95f6e..9e80fc4a 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -26,7 +26,7 @@ jobs: cache-name: cache-paper-base with: # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/base + path: ./base key: cache-paper-base-pr - if: ${{ steps.cache-base.outputs.cache-hit != 'true' }} name: Setup build environment From 2025a812faa32f81fe922510e94b5640a434e33b Mon Sep 17 00:00:00 2001 From: mechoriet Date: Sun, 16 Apr 2023 20:47:54 +0200 Subject: [PATCH 7/8] found a way to cache it locally too so was able to test it --- .github/workflows/build.yml | 17 +++++++++++------ .github/workflows/check.yml | 18 ++++++++++++------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5324a049..fe49b89a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,19 +22,24 @@ jobs: git config --global user.email "actions@github.com" git config --global user.name "GitHub Actions" git config --global init.defaultBranch master - - name: Cache base/paper folder - id: cache-base + - name: Check cache for Paper Base + id: cache-base-check uses: actions/cache@v3 env: cache-name: cache-paper-base with: - # npm cache files are stored in `~/.npm` on Linux/macOS path: ./base key: cache-paper-base-master - - if: ${{ steps.cache-base.outputs.cache-hit != 'true' }} - name: Setup build environment + - name: Setup build environment + if: ${{ steps.cache-base-check.outputs.cache-hit != 'true' }} run: ./panda setup - + - name: Save cache for Paper Base + if: ${{ steps.cache-base-check.outputs.cache-hit != 'true' }} + id: cache-base-save + uses: actions/cache/save@v3 + with: + path: ./base + key: ${{ steps.cache-base-check.outputs.cache-primary-key }} - name: Apply patches run: ./panda patch diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 9e80fc4a..465b2394 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -19,18 +19,24 @@ jobs: git config --global user.email "actions@github.com" git config --global user.name "GitHub Actions" git config --global init.defaultBranch master - - name: Cache base/paper folder - id: cache-base + - name: Check cache for Paper Base + id: cache-base-check uses: actions/cache@v3 env: cache-name: cache-paper-base with: - # npm cache files are stored in `~/.npm` on Linux/macOS path: ./base - key: cache-paper-base-pr - - if: ${{ steps.cache-base.outputs.cache-hit != 'true' }} - name: Setup build environment + key: cache-paper-base-master + - name: Setup build environment + if: ${{ steps.cache-base-check.outputs.cache-hit != 'true' }} run: ./panda setup + - name: Save cache for Paper Base + if: ${{ steps.cache-base-check.outputs.cache-hit != 'true' }} + id: cache-base-save + uses: actions/cache/save@v3 + with: + path: ./base + key: ${{ steps.cache-base-check.outputs.cache-primary-key }} - name: Apply patches run: ./panda patch From b6f21e0c0b65fd9df2b6c4fec09f11bb398571fa Mon Sep 17 00:00:00 2001 From: mechoriet Date: Sun, 16 Apr 2023 20:55:08 +0200 Subject: [PATCH 8/8] clean up diff --- .github/workflows/build.yml | 3 +++ .github/workflows/check.yml | 1 + 2 files changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fe49b89a..19da0783 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,6 +22,7 @@ jobs: git config --global user.email "actions@github.com" git config --global user.name "GitHub Actions" git config --global init.defaultBranch master + - name: Check cache for Paper Base id: cache-base-check uses: actions/cache@v3 @@ -33,6 +34,7 @@ jobs: - name: Setup build environment if: ${{ steps.cache-base-check.outputs.cache-hit != 'true' }} run: ./panda setup + - name: Save cache for Paper Base if: ${{ steps.cache-base-check.outputs.cache-hit != 'true' }} id: cache-base-save @@ -52,6 +54,7 @@ jobs: - name: Copy Paperclip jar run: | cp -v "./paperclip/build/libs/paperclip-1.8.8-R0.1-SNAPSHOT.jar" "./pandaspigot-$GITHUB_RUN_NUMBER.jar" + - name: Upload artifacts uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 465b2394..afbce62e 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -19,6 +19,7 @@ jobs: git config --global user.email "actions@github.com" git config --global user.name "GitHub Actions" git config --global init.defaultBranch master + - name: Check cache for Paper Base id: cache-base-check uses: actions/cache@v3