Skip to content
Open

5.0 #37

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 181 additions & 0 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
name: Moodle Plugin CI

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-24.04

services:
mariadb:
image: mariadb:10.11.7
env:
MYSQL_ROOT_PASSWORD: ''
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
MYSQL_CHARACTER_SET_SERVER: "utf8mb4"
MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci"
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping --silent" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
fail-fast: false
matrix:
php: ['8.4']
moodle-branch: ['MOODLE_500_STABLE']
database: [mariadb]

steps:
- name: Checkout Plugin
uses: actions/checkout@v4
with:
path: inactive_user_cleanup

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, intl, soap, curl, gd, xml, json, zip, pdo, pdo_mysql,
ini-values: max_input_vars=5000
coverage: none

- name: Setup Node.js (for Grunt)
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install Moodle Node dependencies
run: npm install
working-directory: inactive_user_cleanup

- name: Install Plugin Composer Dependencies
run: composer install --no-dev --prefer-dist --no-progress
working-directory: inactive_user_cleanup

- name: Clean Extra Files from Plugin
run: |
rm -rf $(cat inactive_user_cleanup/exclude.lst | tr '\n' ' ')

- name: Install moodle-plugin-ci tooling
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
env:
COMPOSER_NO_INTERACTION: 1

- name: Install moodle-plugin-ci
run: moodle-plugin-ci install --plugin ./inactive_user_cleanup --db-host=127.0.0.1
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}

- name: PHP Lint
if: ${{ !cancelled() }}
run: moodle-plugin-ci phplint inactive_user_cleanup

- name: Moodle Code Checker
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpcs --max-warnings 0 inactive_user_cleanup

- name: Moodle PHPDoc Checker
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpdoc --max-warnings 0 inactive_user_cleanup

- name: PHP Mess Detector
if: ${{ !cancelled() }}
continue-on-error: true
run: moodle-plugin-ci phpmd inactive_user_cleanup

- name: PHP Code Beautifier and Fixer
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpcbf inactive_user_cleanup

- name: Validate Plugin
if: ${{ !cancelled() }}
run: moodle-plugin-ci validate inactive_user_cleanup

- name: Check Upgrade Savepoints
if: ${{ !cancelled() }}
run: moodle-plugin-ci savepoints inactive_user_cleanup

- name: PHPUnit Tests
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpunit --fail-on-warning inactive_user_cleanup

- name: Run Behat Tests
id: behat
if: ${{ !cancelled() }}
run: moodle-plugin-ci behat --profile chrome --scss-deprecations inactive_user_cleanup

- name: Upload Behat Faildump (if failed)
if: ${{ failure() && steps.behat.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: Behat Faildump (${{ matrix.php }}, ${{ matrix.database }})
path: ${{ github.workspace }}/moodledata/behat_dump
retention-days: 7
if-no-files-found: ignore

- name: Final Cleanup - Remove Vendor
if: ${{ always() }}
run: rm -rf inactive_user_cleanup/vendor

- name: Mark cancelled jobs as failed
if: ${{ cancelled() }}
run: exit 1

create_tag_and_release:
runs-on: ubuntu-24.04
needs: test
if: github.event_name == 'push' && contains(github.event.head_commit.message, 'Merge pull request')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
path: inactive_user_cleanup

- uses: actions/setup-node@v3
with:
node-version: 18

- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

- name: Clear npm cache
run: npm cache clean --force

- name: Install Moodle Node dependencies
run: npm install
working-directory: inactive_user_cleanup

- name: Install Composer Dependencies
run: composer install --no-dev --prefer-dist --no-progress
working-directory: inactive_user_cleanup

- name: Prepare Release Folder
run: mkdir -p release

- name: Build Zip using exclude.lst
run: |
zip -r release/inactive_user_cleanup.zip inactive_user_cleanup -x@inactive_user_cleanup/exclude.lst

- name: Get version from package.json
id: version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
working-directory: inactive_user_cleanup

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.version.outputs.version }}
files: release/inactive_user_cleanup.zip
body: |
This is the official release for version v${{ steps.version.outputs.version }}.
Thank you for using our inactive_user_cleanup plugin!
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
vendor/
composer.lock
node_modules/
package-lock.json
Loading