| 
 | 1 | +---  | 
 | 2 | +name: Moodle Plugin CI  | 
 | 3 | + | 
 | 4 | +on: [push, pull_request]  | 
 | 5 | + | 
 | 6 | +jobs:  | 
 | 7 | +  test:  | 
 | 8 | +    runs-on: ubuntu-22.04  | 
 | 9 | + | 
 | 10 | +    services:  | 
 | 11 | +      postgres:  | 
 | 12 | +        image: postgres:14  | 
 | 13 | +        env:  | 
 | 14 | +          POSTGRES_USER: 'postgres'  | 
 | 15 | +          POSTGRES_HOST_AUTH_METHOD: 'trust'  | 
 | 16 | +        ports:  | 
 | 17 | +          - 5432:5432  | 
 | 18 | +        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3  | 
 | 19 | + | 
 | 20 | +      mariadb:  | 
 | 21 | +        image: mariadb:10  | 
 | 22 | +        env:  | 
 | 23 | +          MYSQL_USER: 'root'  | 
 | 24 | +          MYSQL_ALLOW_EMPTY_PASSWORD: "true"  | 
 | 25 | +          MYSQL_CHARACTER_SET_SERVER: "utf8mb4"  | 
 | 26 | +          MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci"  | 
 | 27 | +        ports:  | 
 | 28 | +          - 3306:3306  | 
 | 29 | +        options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3  | 
 | 30 | + | 
 | 31 | +    strategy:  | 
 | 32 | +      fail-fast: false  | 
 | 33 | +      matrix:  | 
 | 34 | +        php: ['7.4', '8.0', '8.1']  | 
 | 35 | +        moodle-branch: ['MOODLE_401_STABLE']  | 
 | 36 | +        database: [pgsql, mariadb]  | 
 | 37 | + | 
 | 38 | +    steps:  | 
 | 39 | +      - name: Check out repository code  | 
 | 40 | +        uses: actions/checkout@v4  | 
 | 41 | +        with:  | 
 | 42 | +          path: plugin  | 
 | 43 | + | 
 | 44 | +      - name: Setup PHP ${{ matrix.php }}  | 
 | 45 | +        uses: shivammathur/setup-php@v2  | 
 | 46 | +        with:  | 
 | 47 | +          php-version: ${{ matrix.php }}  | 
 | 48 | +          extensions: ${{ matrix.extensions }}  | 
 | 49 | +          ini-values: max_input_vars=5000  | 
 | 50 | +          # If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug".  | 
 | 51 | +          # If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems).  | 
 | 52 | +          coverage: none  | 
 | 53 | + | 
 | 54 | +      - name: Initialise moodle-plugin-ci  | 
 | 55 | +        run: |  | 
 | 56 | +          composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4  | 
 | 57 | +          echo $(cd ci/bin; pwd) >> $GITHUB_PATH  | 
 | 58 | +          echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH  | 
 | 59 | +          sudo locale-gen en_AU.UTF-8  | 
 | 60 | +          echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV  | 
 | 61 | +
  | 
 | 62 | +      - name: Install moodle-plugin-ci  | 
 | 63 | +        run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1  | 
 | 64 | +        env:  | 
 | 65 | +          DB: ${{ matrix.database }}  | 
 | 66 | +          MOODLE_BRANCH: ${{ matrix.moodle-branch }}  | 
 | 67 | +          # Uncomment this to run Behat tests using the Moodle App.  | 
 | 68 | +          # MOODLE_APP: 'true'  | 
 | 69 | + | 
 | 70 | +      - name: PHP Lint  | 
 | 71 | +        if: ${{ !cancelled() }}  | 
 | 72 | +        run: moodle-plugin-ci phplint .  | 
 | 73 | + | 
 | 74 | +      - name: PHP Mess Detector  | 
 | 75 | +        continue-on-error: true # This step will show errors but will not fail  | 
 | 76 | +        if: ${{ !cancelled() }}  | 
 | 77 | +        run: moodle-plugin-ci phpmd .  | 
 | 78 | + | 
 | 79 | +      - name: Moodle Code Checker  | 
 | 80 | +        if: ${{ !cancelled() }}  | 
 | 81 | +        run: moodle-plugin-ci phpcs --max-warnings 0 .  | 
 | 82 | + | 
 | 83 | +      - name: Moodle PHPDoc Checker  | 
 | 84 | +        if: ${{ !cancelled() }}  | 
 | 85 | +        run: moodle-plugin-ci phpdoc --max-warnings 0 .  | 
 | 86 | + | 
 | 87 | +      - name: Validating  | 
 | 88 | +        if: ${{ !cancelled() }}  | 
 | 89 | +        run: moodle-plugin-ci validate .  | 
 | 90 | + | 
 | 91 | +      - name: Check upgrade savepoints  | 
 | 92 | +        if: ${{ !cancelled() }}  | 
 | 93 | +        run: moodle-plugin-ci savepoints .  | 
 | 94 | +   | 
 | 95 | +      - name: Mustache Lint  | 
 | 96 | +        if: ${{ !cancelled() }}  | 
 | 97 | +        run: moodle-plugin-ci mustache .  | 
 | 98 | + | 
 | 99 | +      - name: Grunt  | 
 | 100 | +        if: ${{ !cancelled() }}  | 
 | 101 | +        run: moodle-plugin-ci grunt --max-lint-warnings 0 .  | 
 | 102 | + | 
 | 103 | +      - name: PHPUnit tests  | 
 | 104 | +        if: ${{ !cancelled() }}  | 
 | 105 | +        run: moodle-plugin-ci phpunit --fail-on-warning .  | 
 | 106 | + | 
 | 107 | +      - name: Behat features  | 
 | 108 | +        id: behat  | 
 | 109 | +        if: ${{ !cancelled() }}  | 
 | 110 | +        run: moodle-plugin-ci behat --profile chrome .  | 
 | 111 | + | 
 | 112 | +      - name: Upload Behat Faildump  | 
 | 113 | +        if: ${{ failure() && steps.behat.outcome == 'failure' }}  | 
 | 114 | +        uses: actions/upload-artifact@v4  | 
 | 115 | +        with:  | 
 | 116 | +          name: Behat Faildump (${{ join(matrix.*, ', ') }})  | 
 | 117 | +          path: ${{ github.workspace }}/moodledata/behat_dump  | 
 | 118 | +          retention-days: 7  | 
 | 119 | +          if-no-files-found: ignore  | 
 | 120 | + | 
 | 121 | +      - name: Mark cancelled jobs as failed.  | 
 | 122 | +        if: ${{ cancelled() }}  | 
 | 123 | +        run: exit 1  | 
0 commit comments