|
| 1 | +name: Moodle Plugin CI |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + static: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + |
| 9 | + strategy: |
| 10 | + matrix: |
| 11 | + php: ['7.4'] |
| 12 | + moodle-branch: ['MOODLE_311_STABLE'] |
| 13 | + database: ['pgsql'] |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Start PostgreSQL |
| 17 | + run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:9.6 |
| 18 | + |
| 19 | + - name: Check out repository code |
| 20 | + uses: actions/checkout@v2 |
| 21 | + with: |
| 22 | + path: plugin |
| 23 | + |
| 24 | + - name: Setup PHP ${{ matrix.php }} |
| 25 | + uses: shivammathur/setup-php@v2 |
| 26 | + with: |
| 27 | + php-version: ${{ matrix.php }} |
| 28 | + coverage: none |
| 29 | + |
| 30 | + - name: Get composer cache directory |
| 31 | + id: composer-cache |
| 32 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 33 | + |
| 34 | + - name: Composer cache |
| 35 | + uses: actions/cache@v2 |
| 36 | + with: |
| 37 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 38 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 39 | + restore-keys: | |
| 40 | + ${{ runner.os }}-composer- |
| 41 | +
|
| 42 | + - name: npm cache |
| 43 | + uses: actions/cache@v2 |
| 44 | + with: |
| 45 | + path: ~/.npm |
| 46 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 47 | + restore-keys: | |
| 48 | + ${{ runner.os }}-node- |
| 49 | +
|
| 50 | + - name: Initialise moodle-plugin-ci |
| 51 | + run: | |
| 52 | + composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3 |
| 53 | + echo $(cd ci/bin; pwd) >> $GITHUB_PATH |
| 54 | + echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH |
| 55 | + sudo locale-gen en_AU.UTF-8 |
| 56 | + echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV |
| 57 | +
|
| 58 | + - name: Install moodle-plugin-ci |
| 59 | + run: | |
| 60 | + moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 --no-init |
| 61 | + env: |
| 62 | + DB: ${{ matrix.database }} |
| 63 | + MOODLE_BRANCH: ${{ matrix.moodle-branch }} |
| 64 | + |
| 65 | + - name: PHP Lint |
| 66 | + if: ${{ always() }} |
| 67 | + run: moodle-plugin-ci phplint |
| 68 | + |
| 69 | + - name: PHP Copy/Paste Detector |
| 70 | + if: ${{ always() }} |
| 71 | + run: moodle-plugin-ci phpcpd |
| 72 | + |
| 73 | + - name: PHP Mess Detector |
| 74 | + if: ${{ always() }} |
| 75 | + run: moodle-plugin-ci phpmd |
| 76 | + |
| 77 | + - name: Moodle Code Checker |
| 78 | + if: ${{ always() }} |
| 79 | + run: moodle-plugin-ci codechecker |
| 80 | + |
| 81 | + - name: Moodle PHPDoc Checker |
| 82 | + if: ${{ always() }} |
| 83 | + run: moodle-plugin-ci phpdoc |
| 84 | + continue-on-error: true |
| 85 | + |
| 86 | + - name: Validating |
| 87 | + if: ${{ always() }} |
| 88 | + run: moodle-plugin-ci validate |
| 89 | + |
| 90 | + - name: Check upgrade savepoints |
| 91 | + if: ${{ always() }} |
| 92 | + run: moodle-plugin-ci savepoints |
| 93 | + |
| 94 | + - name: Mustache Lint |
| 95 | + if: ${{ always() }} |
| 96 | + run: moodle-plugin-ci mustache |
| 97 | + |
| 98 | + - name: Grunt |
| 99 | + if: ${{ always() }} |
| 100 | + run: moodle-plugin-ci grunt |
| 101 | + |
| 102 | + test: |
| 103 | + runs-on: ubuntu-latest |
| 104 | + needs: static |
| 105 | + |
| 106 | + strategy: |
| 107 | + fail-fast: false |
| 108 | + matrix: |
| 109 | + php: ['7.3', '7.4'] |
| 110 | + moodle-branch: ['MOODLE_39_STABLE', 'MOODLE_310_STABLE', 'MOODLE_311_STABLE'] |
| 111 | + database: ['mariadb', 'pgsql'] |
| 112 | + |
| 113 | + steps: |
| 114 | + - name: Start MariaDB |
| 115 | + if: matrix.database == 'mariadb' |
| 116 | + run: docker run -p 3306:3306 -e MYSQL_USER=root -e MYSQL_ALLOW_EMPTY_PASSWORD=true -d mariadb:10 |
| 117 | + |
| 118 | + - name: Start PostgreSQL |
| 119 | + if: matrix.database == 'pgsql' |
| 120 | + run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:9.6 |
| 121 | + |
| 122 | + - name: Check out repository code |
| 123 | + uses: actions/checkout@v2 |
| 124 | + with: |
| 125 | + path: plugin |
| 126 | + |
| 127 | + - name: Setup PHP ${{ matrix.php }} |
| 128 | + uses: shivammathur/setup-php@v2 |
| 129 | + with: |
| 130 | + php-version: ${{ matrix.php }} |
| 131 | + coverage: none |
| 132 | + |
| 133 | + - name: Get composer cache directory |
| 134 | + id: composer-cache |
| 135 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 136 | + - name: Composer cache |
| 137 | + uses: actions/cache@v2 |
| 138 | + with: |
| 139 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 140 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 141 | + restore-keys: | |
| 142 | + ${{ runner.os }}-composer- |
| 143 | + - name: npm cache |
| 144 | + uses: actions/cache@v2 |
| 145 | + with: |
| 146 | + path: ~/.npm |
| 147 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 148 | + restore-keys: | |
| 149 | + ${{ runner.os }}-node- |
| 150 | +
|
| 151 | + - name: Initialise moodle-plugin-ci |
| 152 | + run: | |
| 153 | + composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3 |
| 154 | + echo $(cd ci/bin; pwd) >> $GITHUB_PATH |
| 155 | + echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH |
| 156 | + sudo locale-gen en_AU.UTF-8 |
| 157 | + echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV |
| 158 | +
|
| 159 | + - name: Install moodle-plugin-ci |
| 160 | + run: | |
| 161 | + moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 |
| 162 | + env: |
| 163 | + DB: ${{ matrix.database }} |
| 164 | + MOODLE_BRANCH: ${{ matrix.moodle-branch }} |
| 165 | + |
| 166 | + - name: PHPUnit tests |
| 167 | + if: ${{ always() }} |
| 168 | + run: moodle-plugin-ci phpunit |
| 169 | + |
| 170 | + - name: Behat features |
| 171 | + if: ${{ always() }} |
| 172 | + run: moodle-plugin-ci behat --profile chrome |
0 commit comments