From 567c0e49fd4cdc41197850dafc6b0386c27a3710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Gonz=C3=A1lez?= Date: Sat, 12 Aug 2023 19:56:05 +0200 Subject: [PATCH] refactor(ci): drop dependency on PackSquash-action-test repository This dependency is unnecessary, because that repository was focused on testing the action, and to test the action we already have some automated workflows at this repository. For testing in other environments, the new reusable workflow step commands can be directly copied and pasted to an Unix-like shell, which is almost as easy as running `git clone`, but with the added advantage that at least someone (me) will look at and update this commands periodically. While at it, let's update the referenced pack versions to test more up-to-date packs, which are likely to be more representative of end PackSquash usage. --- .../set_up_repo_with_submodules/action.yml | 36 +++++++++++++++++++ .github/workflows/test_pack_in_submodule.yml | 20 ++++------- .github/workflows/test_pack_submodule.yml | 13 +++---- 3 files changed, 46 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/actions/set_up_repo_with_submodules/action.yml diff --git a/.github/workflows/actions/set_up_repo_with_submodules/action.yml b/.github/workflows/actions/set_up_repo_with_submodules/action.yml new file mode 100644 index 00000000..805ea5c7 --- /dev/null +++ b/.github/workflows/actions/set_up_repo_with_submodules/action.yml @@ -0,0 +1,36 @@ +name: Set up empty Git repository with public pack submodules +description: Reusable steps to set up a repository with packs in submodules for testing +runs: + using: composite + steps: + # The packs checked out by these steps are distributed to the public + # and, to the best of our knowledge, used in conformance with the + # usage rights given in their licenses, which are, in no particular + # order: + # - CC BY 4.0, + # - CC BY-NC-SA 4.0, + # - Custom licenses. + # Thanks to their authors for making such great packs! + - name: Set up empty Git repository with public pack submodules + shell: sh + run: | + git -c init.defaultBranch=master init + + while read -r submodule_info; do + url="${submodule_info%% *}" + name="${submodule_info#* }" + name="${name% *}" + commitish="${submodule_info##* }" + + git submodule add "$url" "$name" + git -C "$name" -c advice.detachedHead=false checkout "$commitish" + git add "$name" + done <<'SUBMODULES' + https://github.com/PoeticRainbow/golden-days.git golden-days 1.9.0 + https://github.com/Crackers0106/Programmer-Art-Plus.git Programmer-Art-Plus 8ddc173e274094588f04d1c989a58378fb56b303 + https://github.com/SummerFields/SummerFields.git SummerFields 645be0fc27495117a7decc96fee810ff1ed584ab + SUBMODULES + + GIT_AUTHOR_NAME='github-actions[bot]' GIT_AUTHOR_EMAIL='41898282+github-actions[bot]@users.noreply.github.com' \ + GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME" GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL" \ + git commit -m 'Root commit' diff --git a/.github/workflows/test_pack_in_submodule.yml b/.github/workflows/test_pack_in_submodule.yml index 23620a30..c863147e 100644 --- a/.github/workflows/test_pack_in_submodule.yml +++ b/.github/workflows/test_pack_in_submodule.yml @@ -13,27 +13,19 @@ jobs: if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork steps: - - name: Clone pack repository - uses: actions/checkout@v3 - with: - repository: ComunidadAylas/PackSquash-action-test - fetch-depth: 0 - submodules: recursive - token: ${{ secrets.GITHUB_TOKEN }} - name: Clone action repository uses: actions/checkout@v3 with: - path: action-checkout - - name: Modify pack files + path: action + - name: Set up empty Git repository with public pack submodules + uses: ./action/.github/workflows/actions/set_up_repo_with_submodules + - name: Modify pack files (test that working directory changes are handled well) run: | - echo '{ "pack": { "pack_format": 8, "description": "Dummy pack.mcmeta" } }' > golden-days/golden-days-base/pack.mcmeta touch golden-days/golden-days-base/assets/minecraft/sounds.json mv golden-days/golden-days-base/credits.txt golden-days/golden-days-base/credits_new.txt - # Remove some files that generate GStreamer negotiation errors on v0.3.1. - # This also serves to check that the action handles files being deleted from the working copy correctly - rm golden-days/golden-days-base/assets/minecraft/sounds/liquid/*.ogg + rm golden-days/golden-days-base/assets/minecraft/optifine/color.properties - name: Run PackSquash - uses: ./action-checkout + uses: ./action with: packsquash_version: latest options: | diff --git a/.github/workflows/test_pack_submodule.yml b/.github/workflows/test_pack_submodule.yml index ba8ef0d4..cbb31bd5 100644 --- a/.github/workflows/test_pack_submodule.yml +++ b/.github/workflows/test_pack_submodule.yml @@ -13,19 +13,14 @@ jobs: if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork steps: - - name: Clone pack repository - uses: actions/checkout@v3 - with: - repository: ComunidadAylas/PackSquash-action-test - fetch-depth: 0 - submodules: recursive - token: ${{ secrets.GITHUB_TOKEN }} - name: Clone action repository uses: actions/checkout@v3 with: - path: action-checkout + path: action + - name: Set up empty Git repository with public pack submodules + uses: ./action/.github/workflows/actions/set_up_repo_with_submodules - name: Run PackSquash - uses: ./action-checkout + uses: ./action with: packsquash_version: latest options: |