diff --git a/.github/workflows/moodle-ci.yaml b/.github/workflows/moodle-ci.yaml new file mode 100644 index 0000000..7348874 --- /dev/null +++ b/.github/workflows/moodle-ci.yaml @@ -0,0 +1,132 @@ +# Modified from https://github.com/moodlehq/moodle-plugin-ci/blob/198ee6c2b36eddba6c3ccac560f50396792c1b47/gha.dist.yml + +name: Moodle Plugin CI + +on: + push: + branches: + - main + pull_request: + +jobs: + test: + runs-on: ubuntu-22.04 + + services: + mariadb: + image: mariadb:10 + env: + MYSQL_USER: "root" + MYSQL_ALLOW_EMPTY_PASSWORD: "true" + MYSQL_CHARACTER_SET_SERVER: "utf8mb4" + MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci" + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3 + + strategy: + fail-fast: false + matrix: + php: ["8.3", "8.4"] + moodle-branch: + [ + "MOODLE_405_STABLE", + "MOODLE_500_STABLE", + "MOODLE_501_STABLE", + "MOODLE_502_STABLE", + ] + database: [mariadb] + exclude: + - moodle-branch: MOODLE_405_STABLE + php: "8.4" + + steps: + - name: Check out repository code + # actions/checkout@v4.3.1 + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 + with: + path: plugin + persist-credentials: false + + - name: Setup PHP ${{ matrix.php }} + # shivammathur/setup-php@v2 + uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 + with: + php-version: ${{ matrix.php }} + extensions: mysqli,pdo_mysql,pdo_sqlite + ini-values: max_input_vars=5000 + coverage: none + + - name: Initialise moodle-plugin-ci + run: | + composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4 + echo $(cd ci/bin; pwd) >> $GITHUB_PATH + echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH + sudo locale-gen en_AU.UTF-8 + echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV + + - name: Install moodle-plugin-ci + run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 + env: + DB: ${{ matrix.database }} + MOODLE_BRANCH: ${{ matrix.moodle-branch }} + IGNORE_PATHS: "vendor" + + - name: PHP Lint + if: ${{ !cancelled() }} + run: moodle-plugin-ci phplint + + - name: PHP Mess Detector + continue-on-error: true + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpmd + + - name: Moodle Code Checker + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpcs --max-warnings 0 + + - name: Moodle PHPDoc Checker + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpdoc --max-warnings 0 + continue-on-error: true + env: + MDL_LOCAL_DEVKIT_DISABLE: 1 + + - name: Validating + if: ${{ !cancelled() }} + run: moodle-plugin-ci validate + + - name: Check upgrade savepoints + if: ${{ !cancelled() }} + run: moodle-plugin-ci savepoints + + - name: Mustache Lint + if: ${{ !cancelled() }} + run: moodle-plugin-ci mustache + + - name: Grunt + if: ${{ !cancelled() }} + run: moodle-plugin-ci grunt --max-lint-warnings 0 + + - name: PHPUnit tests + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpunit --fail-on-warning + + - name: Behat features + id: behat + if: ${{ !cancelled() }} + run: moodle-plugin-ci behat --profile chrome --scss-deprecations + + - name: Upload Behat Faildump + if: ${{ failure() && steps.behat.outcome == 'failure' }} + # actions/upload-artifact@v4.6.2 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: Behat Faildump (${{ matrix.php }}, ${{ matrix.moodle-branch }}, ${{ matrix.database }}) + path: ${{ github.workspace }}/moodledata/behat_dump + retention-days: 7 + if-no-files-found: ignore + + - name: Mark cancelled jobs as failed. + if: ${{ cancelled() }} + run: exit 1