From 4f55d73db50928749763ec8509cb8e7d750b67f0 Mon Sep 17 00:00:00 2001 From: Markus Date: Sun, 27 Oct 2024 17:53:07 +0100 Subject: [PATCH 01/16] error handling in case restore fail --- .github/workflows/infection.yml | 56 +++++++++++++++++++++++++++++++++ infection.json5 | 17 ++++++++++ 2 files changed, 73 insertions(+) create mode 100644 .github/workflows/infection.yml create mode 100644 infection.json5 diff --git a/.github/workflows/infection.yml b/.github/workflows/infection.yml new file mode 100644 index 0000000..ff89d5f --- /dev/null +++ b/.github/workflows/infection.yml @@ -0,0 +1,56 @@ +name: Infection Tests + +on: [push, pull_request] + +jobs: + ci: + name: ci + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + moodle-branch: ['main'] + php: ['8.3'] + database: ['mysqli'] + + steps: + - name: checkout plugin + uses: actions/checkout@v4 + with: + path: this-plugin + + - name: setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + ini-values: max_input_vars=5000 + tools: infection, phpunit + coverage: pcov + + - name: composer + run: | + composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci + echo $(cd ci/bin; pwd) >> $GITHUB_PATH + echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH + sudo locale-gen en_AU.UTF-8 + sudo systemctl start mysql.service + + - name: install Moodle + run: moodle-plugin-ci install --db-user=root --db-pass=root --db-host=127.0.0.1 --plugin this-plugin + env: + DB: ${{ matrix.database }} + MOODLE_BRANCH: ${{ matrix.moodle-branch }} + + - name: autoload + working-directory: moodle + run: | + echo ' vendor/autoloadmoodle.php + echo 'define("PHPUNIT_UTIL", true);' >> vendor/autoloadmoodle.php + echo 'require(__DIR__ . "/../lib/phpunit/bootstrap.php");' >> vendor/autoloadmoodle.php + echo 'require("autoload.php");' >> vendor/autoloadmoodle.php + + - name: infection + if: ${{ !cancelled() }} + run: infection -s --only-covered --configuration=availability/condition/language/infection.json5 + working-directory: moodle \ No newline at end of file diff --git a/infection.json5 b/infection.json5 new file mode 100644 index 0000000..d84d66e --- /dev/null +++ b/infection.json5 @@ -0,0 +1,17 @@ +{ + "$schema": "https://raw.githubusercontent.com/infection/infection/0.29.0/resources/schema.json", + "source": { + "directories": [ + "." + ] + }, + "phpUnit": { + "configDir": ".", + "customPath": "./vendor/bin/phpunit" + }, + "initialTestsPhpOptions": "-dxdebug.mode=off -dpcov.enabled=1 -dpcov.directory=.", + "bootstrap": "./vendor/autoloadmoodle.php", + "mutators": { + "@default": true + } +} \ No newline at end of file From 09f8976bc96e5200b0510757e65d41e88223addf Mon Sep 17 00:00:00 2001 From: Markus Date: Sun, 27 Oct 2024 17:58:34 +0100 Subject: [PATCH 02/16] update --- .github/workflows/infection.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/infection.yml b/.github/workflows/infection.yml index ff89d5f..07429d6 100644 --- a/.github/workflows/infection.yml +++ b/.github/workflows/infection.yml @@ -52,5 +52,5 @@ jobs: - name: infection if: ${{ !cancelled() }} - run: infection -s --only-covered --configuration=availability/condition/language/infection.json5 + run: infection -s --only-covered --configuration=local/logging/infection.json5 working-directory: moodle \ No newline at end of file From 4f6ecb5ed843d0dd01981b5a79009f09f5097ea9 Mon Sep 17 00:00:00 2001 From: Markus Date: Sun, 27 Oct 2024 18:17:49 +0100 Subject: [PATCH 03/16] update --- infection.json5 | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/infection.json5 b/infection.json5 index d84d66e..85cb82d 100644 --- a/infection.json5 +++ b/infection.json5 @@ -1,17 +1,18 @@ { - "$schema": "https://raw.githubusercontent.com/infection/infection/0.29.0/resources/schema.json", - "source": { - "directories": [ - "." - ] - }, - "phpUnit": { - "configDir": ".", - "customPath": "./vendor/bin/phpunit" - }, - "initialTestsPhpOptions": "-dxdebug.mode=off -dpcov.enabled=1 -dpcov.directory=.", - "bootstrap": "./vendor/autoloadmoodle.php", - "mutators": { - "@default": true - } + "$schema": "https://raw.githubusercontent.com/infection/infection/0.29.0/resources/schema.json", + "source": { + "directories": [ + "." + ] + }, + "phpUnit": { + "configDir": ".", + "customPath": "./vendor/phpunit/phpunit/phpunit" + }, + "initialTestsPhpOptions": "-dxdebug.mode=off -dpcov.enabled=1 -dpcov.directory=.", + "bootstrap": "vendor/autoloadmoodle.php", +// "bootstrap": "../../lib/phpunit/bootstrap.php", + "mutators": { + "@default": true + } } \ No newline at end of file From 506daa80884510e543c28e279b5bb0eda9bc7368 Mon Sep 17 00:00:00 2001 From: Markus Date: Wed, 4 Dec 2024 14:37:48 +0100 Subject: [PATCH 04/16] fix automatic maturity level setting on release --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 656156a..1cd4a8e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,11 +24,11 @@ jobs: # - release is marked as pre-release on github, then MATURITY_BETA # - release name contains 'rc', then MATURITY_RC if [[ "${{ github.ref_name }}" == *"rc"* ]]; then - sed -i "s/^\$plugin->maturity\s=\sMATURITY_STABLE;/\$plugin->maturity = MATURITY_RC;/" version.php + sed -i "s/^\$plugin->maturity\s=\sMATURITY_[A-Z]*;/\$plugin->maturity = MATURITY_RC;/" version.php elif [[ "${{ github.event_name }}" == "release" && "${{ github.event.release.prerelease }}" == "true" ]]; then - sed -i "s/^\$plugin->maturity\s=\sMATURITY_STABLE;/\$plugin->maturity = MATURITY_BETA;/" version.php - else - sed -i "s/^\$plugin->maturity\s=\sMATURITY_STABLE;/\$plugin->maturity = MATURITY_STABLE;/" version.php + sed -i "s/^\$plugin->maturity\s=\sMATURITY_[A-Z]*;/\$plugin->maturity = MATURITY_BETA;/" version.php + else + sed -i "s/^\$plugin->maturity\s=\sMATURITY_[A-Z]*;/\$plugin->maturity = MATURITY_STABLE;/" version.php fi - name: remove files not needed for release From bc958ff8c4519c01c14026557b0ad058560542ea Mon Sep 17 00:00:00 2001 From: Markus Date: Wed, 4 Dec 2024 14:45:02 +0100 Subject: [PATCH 05/16] add md5 files for release archives --- .github/workflows/release.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1cd4a8e..7a27728 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,18 +40,35 @@ jobs: tar --exclude='.git' -czf /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.tgz * zip -x .git -r /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip * - - name: Upload release archives + - name: Calculate MD5 hash + run: | + md5sum /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.tgz > /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.tgz.md5 + md5sum /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip > /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip.md5 + + - name: Upload release archive (ZIP) uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip tag: ${{ github.ref_name }} - - name: Upload release archives + - name: Upload release archive (TGZ) uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.tgz tag: ${{ github.ref_name }} + - name: Upload MD5 hash files (ZIP) + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip.md5 + tag: ${{ github.ref_name }} + - name: Upload MD5 hash files (TGZ) + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.tgz.md5 + tag: ${{ github.ref_name }} - name: Prepare release body (description) id: prep_body From 7a362d5daae9e43005afe207fb8f3849b9a5f80f Mon Sep 17 00:00:00 2001 From: Markus Date: Wed, 4 Dec 2024 14:52:51 +0100 Subject: [PATCH 06/16] remove infection pipeline step --- .github/workflows/infection.yml | 56 --------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 .github/workflows/infection.yml diff --git a/.github/workflows/infection.yml b/.github/workflows/infection.yml deleted file mode 100644 index 07429d6..0000000 --- a/.github/workflows/infection.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Infection Tests - -on: [push, pull_request] - -jobs: - ci: - name: ci - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - moodle-branch: ['main'] - php: ['8.3'] - database: ['mysqli'] - - steps: - - name: checkout plugin - uses: actions/checkout@v4 - with: - path: this-plugin - - - name: setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - ini-values: max_input_vars=5000 - tools: infection, phpunit - coverage: pcov - - - name: composer - run: | - composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci - echo $(cd ci/bin; pwd) >> $GITHUB_PATH - echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH - sudo locale-gen en_AU.UTF-8 - sudo systemctl start mysql.service - - - name: install Moodle - run: moodle-plugin-ci install --db-user=root --db-pass=root --db-host=127.0.0.1 --plugin this-plugin - env: - DB: ${{ matrix.database }} - MOODLE_BRANCH: ${{ matrix.moodle-branch }} - - - name: autoload - working-directory: moodle - run: | - echo ' vendor/autoloadmoodle.php - echo 'define("PHPUNIT_UTIL", true);' >> vendor/autoloadmoodle.php - echo 'require(__DIR__ . "/../lib/phpunit/bootstrap.php");' >> vendor/autoloadmoodle.php - echo 'require("autoload.php");' >> vendor/autoloadmoodle.php - - - name: infection - if: ${{ !cancelled() }} - run: infection -s --only-covered --configuration=local/logging/infection.json5 - working-directory: moodle \ No newline at end of file From cd882c449ce796455aa4390069737e62cb76870a Mon Sep 17 00:00:00 2001 From: Markus Date: Sat, 14 Dec 2024 02:45:11 +0100 Subject: [PATCH 07/16] bump postgres to 16 --- .github/workflows/moodle-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index 46aaace..a254e02 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -16,7 +16,7 @@ jobs: services: postgres: - image: postgres:13 + image: postgres:16 env: POSTGRES_USER: 'postgres' POSTGRES_HOST_AUTH_METHOD: 'trust' From 4a2229dcfc2622d340c8378c9ca228c7c33a9b2e Mon Sep 17 00:00:00 2001 From: Markus Date: Sat, 14 Dec 2024 02:46:54 +0100 Subject: [PATCH 08/16] remove .tgz archive, exclude some additional files from release zips --- .github/workflows/release.yml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7a27728..41ea2af 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,11 +33,10 @@ jobs: - name: remove files not needed for release run: | - rm -rf .github tests vendor .gitignore composer.json composer.lock phpunit.xml dev_utils + rm -rf .github tests vendor .gitignore composer.json composer.lock phpunit.xml dev_utils phpunit.xml infection.json5 - name: Create release archives run: | - tar --exclude='.git' -czf /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.tgz * zip -x .git -r /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip * - name: Calculate MD5 hash @@ -51,24 +50,12 @@ jobs: repo_token: ${{ secrets.GITHUB_TOKEN }} file: /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip tag: ${{ github.ref_name }} - - name: Upload release archive (TGZ) - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.tgz - tag: ${{ github.ref_name }} - name: Upload MD5 hash files (ZIP) uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip.md5 tag: ${{ github.ref_name }} - - name: Upload MD5 hash files (TGZ) - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.tgz.md5 - tag: ${{ github.ref_name }} - name: Prepare release body (description) id: prep_body From 1f2ec3b0ba255e7546d8def276a11969d912ee5e Mon Sep 17 00:00:00 2001 From: Markus Date: Sat, 14 Dec 2024 23:00:05 +0100 Subject: [PATCH 09/16] fix zip archive folder structure (contents have to be in subdirectory, moodle expects that) --- .github/workflows/release.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 41ea2af..12fd6d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,9 +35,13 @@ jobs: run: | rm -rf .github tests vendor .gitignore composer.json composer.lock phpunit.xml dev_utils phpunit.xml infection.json5 - - name: Create release archives + - name: Create release archive run: | - zip -x .git -r /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip * + FOLDER_NAME=$(echo ${{ env.PLUGIN_NAME }} | cut -d'_' -f2) + mkdir -p /tmp/$FOLDER_NAME + cp -r * /tmp/$FOLDER_NAME + cd /tmp + zip -r moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip $FOLDER_NAME - name: Calculate MD5 hash run: | From ea3efe951f9ed523a4e473cde19514959d3c4fe5 Mon Sep 17 00:00:00 2001 From: Markus Date: Mon, 16 Dec 2024 03:30:00 +0100 Subject: [PATCH 10/16] remove discord release notification, add upload to package registry --- .github/workflows/release.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 12fd6d2..c0de7c6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,16 +61,9 @@ jobs: file: /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip.md5 tag: ${{ github.ref_name }} - - name: Prepare release body (description) - id: prep_body + - name: Upload to package registry run: | - echo "${{ github.event.release.body }}" > changes.md - - - name: Discord notification - uses: appleboy/discord-action@master - with: - webhook_id: ${{ secrets.DISCORD_RELEASE_CHANNEL_WEBHOOK_ID }} - webhook_token: ${{ secrets.DISCORD_RELEASE_CHANNEL_WEBHOOK_TOKEN }} - username: GitHub Releases - message: "New release of **${{ github.repository }}**\nVersion: ${{ github.ref_name }} (${{github.event.release.name}})\n<${{ github.event.release.html_url }}>" - file: changes.md \ No newline at end of file + cd /tmp + MD5_CONTENT=$(awk '{print $1 " '${{ github.ref_name }}.zip'"}' /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip.md5) + curl --fail-with-body -u upload:${{ secrets.PACKAGE_REGISTRY_UPLOAD_PASSWORD }} -T /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip https://packages.projekt-adler.eu/upload/moodle/${{ env.PLUGIN_NAME }}/${{ github.ref_name }}.zip + curl --fail-with-body -u upload:${{ secrets.PACKAGE_REGISTRY_UPLOAD_PASSWORD }} -X PUT --data "$MD5_CONTENT" https://packages.projekt-adler.eu/upload/moodle/${{ env.PLUGIN_NAME }}/${{ github.ref_name }}.zip.md5 From 19211116c545c52dd5e25cc142d72c2abaf86c18 Mon Sep 17 00:00:00 2001 From: Markus Date: Mon, 16 Dec 2024 03:32:30 +0100 Subject: [PATCH 11/16] fix wrong release zip path in md5 file --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c0de7c6..840b628 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,7 +45,7 @@ jobs: - name: Calculate MD5 hash run: | - md5sum /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.tgz > /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.tgz.md5 + cd /tmp md5sum /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip > /tmp/moodle-${{ env.PLUGIN_NAME }}-${{ github.ref_name }}.zip.md5 - name: Upload release archive (ZIP) From 12990816531d69972fe2aa254d896041239027b6 Mon Sep 17 00:00:00 2001 From: Markus Date: Mon, 16 Dec 2024 04:03:29 +0100 Subject: [PATCH 12/16] rename release pipeline --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 840b628..fb012c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Moodle Plugin CI +name: Create release on: release: From 49f65cde866a7a1171542e230a32c31cd2f52a70 Mon Sep 17 00:00:00 2001 From: Markus Date: Mon, 16 Dec 2024 04:52:50 +0100 Subject: [PATCH 13/16] update infection config --- infection.json5 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/infection.json5 b/infection.json5 index 85cb82d..92aad9b 100644 --- a/infection.json5 +++ b/infection.json5 @@ -11,8 +11,7 @@ }, "initialTestsPhpOptions": "-dxdebug.mode=off -dpcov.enabled=1 -dpcov.directory=.", "bootstrap": "vendor/autoloadmoodle.php", -// "bootstrap": "../../lib/phpunit/bootstrap.php", "mutators": { - "@default": true + "@default": true, } } \ No newline at end of file From b7662b6c2c2fafc380a4e2c6221a9640b484ecab Mon Sep 17 00:00:00 2001 From: Markus Date: Mon, 16 Dec 2024 23:44:27 +0100 Subject: [PATCH 14/16] fix test namespaces, add mtrace output module, always use mtrace output module --- classes/hook_listener.php | 14 ++++--- classes/local/output/log_output_mtrace.php | 13 ++++++ tests/local/output/log_output_db_test.php | 3 +- tests/local/output/log_output_mtrace_test.php | 42 +++++++++++++++++++ tests/local/output/log_output_stdout_test.php | 3 +- 5 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 classes/local/output/log_output_mtrace.php create mode 100644 tests/local/output/log_output_mtrace_test.php diff --git a/classes/hook_listener.php b/classes/hook_listener.php index f7ad380..ee81131 100644 --- a/classes/hook_listener.php +++ b/classes/hook_listener.php @@ -2,9 +2,11 @@ namespace local_logging; +use core\di; use core\hook\di_configuration; use local_logging\local\output\log_output; use local_logging\local\output\log_output_db; +use local_logging\local\output\log_output_mtrace; use local_logging\local\output\log_output_stdout; class hook_listener { @@ -12,11 +14,13 @@ public static function inject_dependencies(di_configuration $hook): void { $hook->add_definition( id: log_output::class, definition: function (): log_output { - if (defined('CLI_SCRIPT') || defined('PHPUNIT_TEST')) { - return new log_output_stdout(); - } else { - return new log_output_db(); - } + return di::get(log_output_mtrace::class); +// if (defined('CLI_SCRIPT') || defined('PHPUNIT_TEST')) { +// return new log_output_stdout(); +// return di::get(log_output_mtrace::class); +// } else { +// return di::get(log_output_db::class); +// } } ); } diff --git a/classes/local/output/log_output_mtrace.php b/classes/local/output/log_output_mtrace.php new file mode 100644 index 0000000..64282e8 --- /dev/null +++ b/classes/local/output/log_output_mtrace.php @@ -0,0 +1,13 @@ +dirroot . '/local/logging/tests/lib/adler_testcase.php'); + +class log_output_mtrace_test extends adler_testcase { + public function test_output() { + // Create an instance of log_output_stdout. + $logOutput = new log_output_mtrace(); + + // Define test data. + $message = 'Test message'; + $level = util::LEVEL_TRACE; // Assuming 100 corresponds to TRACE level + $component = 'testcomponent'; + $title = 'testtitle'; + $time = time(); + $user_id = null; + + // Start output buffering. + ob_start(); + + // Call the output method. + $logOutput->output($message, $level, $component, $title, $time, $user_id); + + // Get the output and clean the buffer. + $output = ob_get_clean(); + + // Assert that the output contains the expected components. + $this->assertStringContainsString('[' . date('Y-m-d H:i:s', $time) . ']', $output); + $this->assertStringContainsString('TRACE', $output); + $this->assertStringContainsString($component, $output); + $this->assertStringContainsString($title . ':', $output); + $this->assertStringContainsString($message, $output); + } +} \ No newline at end of file diff --git a/tests/local/output/log_output_stdout_test.php b/tests/local/output/log_output_stdout_test.php index 5a87bed..22fdd00 100644 --- a/tests/local/output/log_output_stdout_test.php +++ b/tests/local/output/log_output_stdout_test.php @@ -1,7 +1,8 @@ Date: Tue, 17 Dec 2024 13:11:42 +0100 Subject: [PATCH 15/16] refactor pipelines and readme for plugin_compatibility.json --- .github/workflows/moodle-ci.yml | 45 +++++++++++++++++++++++++++------ README.md | 11 ++------ plugin_compatibility.json | 18 +++++++++++++ 3 files changed, 57 insertions(+), 17 deletions(-) create mode 100644 plugin_compatibility.json diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index a254e02..210a8d4 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -11,6 +11,39 @@ on: - '**' jobs: + define-matrix: + runs-on: ubuntu-latest + + outputs: + include_list: ${{ steps.include_list.outputs.include_list }} + + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Define matrix + id: include_list + run: | + # Generates a json array with include entries for all possible combinations of PHP, Moodle branch and database + include_str="[" + first_entry=true + for i in $(cat plugin_compatibility.json | jq -c '.[]'); do + moodle=$(echo "$i" | jq -r '.moodle') + for php in $(echo "$i" | jq -r '.PHP[]'); do + for database in pgsql mariadb; do + if [ "$first_entry" = true ]; then + first_entry=false + else + include_str="$include_str," + fi + next_entry="{\"php\": \"$php\", \"moodle-branch\": \"$moodle\", \"database\": \"$database\", \"experimental\": false}" + include_str="$include_str$next_entry" + done + done + done + include_str="$include_str]" + echo "include_list=$include_str" >> "$GITHUB_OUTPUT" + test: runs-on: ubuntu-22.04 @@ -38,15 +71,11 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.1', '8.2', '8.3'] - moodle-branch: ['MOODLE_404_STABLE', 'MOODLE_405_STABLE'] + php: ['8.3'] + moodle-branch: ['main'] database: [pgsql, mariadb] - experimental: [false] - include: - - php: '8.3' - moodle-branch: 'main' - database: mariadb - experimental: true + experimental: [true] + include: ${{ fromJSON(needs.define-matrix.outputs.include_list) }} continue-on-error: ${{ matrix.experimental }} diff --git a/README.md b/README.md index 1947319..c63449b 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,9 @@ Das Local Logging Plugin ermöglicht eine einfache Protokollierung von Ereignissen in Moodle. Es stellt eine Logger-Klasse zur Verfügung, die es Entwicklern ermöglicht, Nachrichten verschiedener Schweregrade zu protokollieren. ## Kompabilität +Folgende Versionen werden unterstützt (mit mariadb und postresql getestet): -| Moodle Branch | PHP Version | -|-------------------------|-------------| -| MOODLE_404_STABLE | 8.1 | -| MOODLE_404_STABLE | 8.2 | -| MOODLE_404_STABLE | 8.3 | -| MOODLE_405_STABLE (LTS) | 8.1 | -| MOODLE_405_STABLE (LTS) | 8.2 | -| MOODLE_405_STABLE (LTS) | 8.3 | - +siehe [plugin_compatibility.json](plugin_compatibility.json) ## Funktionsweise diff --git a/plugin_compatibility.json b/plugin_compatibility.json new file mode 100644 index 0000000..5feec3a --- /dev/null +++ b/plugin_compatibility.json @@ -0,0 +1,18 @@ +[ + { + "moodle": "MOODLE_404_STABLE", + "PHP": [ + "8.1", + "8.2", + "8.3" + ] + }, + { + "moodle": "MOODLE_405_STABLE", + "PHP": [ + "8.1", + "8.2", + "8.3" + ] + } +] \ No newline at end of file From d7e6c0465ef92b2c343488eb7855c8f9f1d69af1 Mon Sep 17 00:00:00 2001 From: Markus Date: Tue, 17 Dec 2024 15:16:41 +0100 Subject: [PATCH 16/16] add missing `needs: define-matrix` statement --- .github/workflows/moodle-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index 210a8d4..2a3b6cb 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -46,6 +46,7 @@ jobs: test: runs-on: ubuntu-22.04 + needs: define-matrix services: postgres: