From a2f20556fd701767bf6c5bf31ed0575104b6bcb1 Mon Sep 17 00:00:00 2001 From: Matthew Hilton Date: Thu, 11 Dec 2025 14:59:55 +1000 Subject: [PATCH] [#151] Clone moodle before apply core patches --- .github/plugin/setup/action.yml | 25 +++++++++++++++++++++---- README.md | 16 ++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/.github/plugin/setup/action.yml b/.github/plugin/setup/action.yml index f3e43def..b26ffb57 100644 --- a/.github/plugin/setup/action.yml +++ b/.github/plugin/setup/action.yml @@ -91,21 +91,38 @@ runs: echo "::endgroup::" shell: bash + - name: Clone Moodle + # Clone to a temporary directory + run: | + echo "::group::Moodle clone output" + + git clone https://github.com/moodle/moodle.git --branch $MOODLE_BRANCH $GITHUB_WORKSPACE/moodletemp + + echo "::endgroup::" + shell: bash + env: + DB: ${{ matrix.database }} + MOODLE_BRANCH: ${{ matrix.moodle-branch }} + - name: Install Core Patches if: ${{ always() }} - # We should attempt to install a patch, and pass if there isnt one for the branch. + # Install core patches to moodle in temporary directory run: | git config --global user.email "test@test.com" git config --global user.name "Test" - ((test -f plugin/patch/${{ matrix.moodle-branch }}.diff && cd moodle && git am --whitespace=nowarn < ../plugin/patch/${{ matrix.moodle-branch }}.diff) || echo No patch found;) + ((test -f plugin/patch/${{ matrix.moodle-branch }}.diff && cd $GITHUB_WORKSPACE/moodletemp && git am --whitespace=nowarn < ../plugin/patch/${{ matrix.moodle-branch }}.diff) || echo No patch found;) shell: bash - - name: Install Moodle + - name: Install Moodle and Plugin + # Install moodle, but use our temporary directory to include any potential core patches that have been applied. run: | # Install moodle commands echo "::group::Moodle install output" - moodle-plugin-ci install -vvv --plugin ./plugin --db-host=127.0.0.1 + # This is a workaround for https://github.com/moodlehq/moodle-plugin-ci/issues/306 - we disable the git repository validation to allow folder cloning. + sed -i '/public function gitUrl($url)/{n; s/{/& return $url;/}' $GITHUB_WORKSPACE/m-ci/src/Validate.php + + moodle-plugin-ci install -vvv --plugin ./plugin --db-host=127.0.0.1 --repo $GITHUB_WORKSPACE/moodletemp echo "::endgroup::" shell: bash diff --git a/README.md b/README.md index 84456f86..0a16448c 100644 --- a/README.md +++ b/README.md @@ -173,3 +173,19 @@ To fix this, you'll need to rebundle the relevant files, on the highest sup __NOTE:__ This may involve having a clean copy of Moodle and installing the plugin code to run the necessary commands to rebuild the _stale_ files. Grunt docs: https://docs.moodle.org/dev/Grunt#Running_grunt + +### Testing changes +Changes can be tested by using another plugin repository that uses these workflows. + +Simply change the repository/branch it pulls from: + +```yml +uses: catalyst/catalyst-moodle-workflows/.github/workflows/ci.yml@my-custom-branch +``` + +and specify the same branch as a `with` parameter: + +```yml +with: + internal_workflow_branch: 'my-custom-branch' +``` \ No newline at end of file