|
| 1 | +name: Moodle plugin CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths-ignore: |
| 6 | + - 'docs/**' |
| 7 | + - '*.md' |
| 8 | + - 'README*' |
| 9 | + - 'LICENSE' |
| 10 | + - '.gitignore' |
| 11 | +<<<<<<< HEAD |
| 12 | +======= |
| 13 | + - 'site/**' |
| 14 | +>>>>>>> 5489a43e (Prevent testsuite runs on documentation changes only.) |
| 15 | + pull_request: |
| 16 | + paths-ignore: |
| 17 | + - 'docs/**' |
| 18 | + - '*.md' |
| 19 | + - 'README*' |
| 20 | + - 'LICENSE' |
| 21 | + - '.gitignore' |
| 22 | +<<<<<<< HEAD |
| 23 | +======= |
| 24 | + - 'site/**' |
| 25 | +>>>>>>> 5489a43e (Prevent testsuite runs on documentation changes only.) |
| 26 | + |
| 27 | +jobs: |
| 28 | + test: |
| 29 | + runs-on: 'ubuntu-latest' |
| 30 | + |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + include: |
| 35 | + - php: '8.3' |
| 36 | + moodle-branch: 'MOODLE_500_STABLE' |
| 37 | + database: 'mariadb' |
| 38 | + - php: '8.3' |
| 39 | + moodle-branch: 'MOODLE_405_STABLE' |
| 40 | + database: 'mariadb' |
| 41 | + - php: '8.2' |
| 42 | + moodle-branch: 'MOODLE_404_STABLE' |
| 43 | + database: 'pgsql' |
| 44 | + - php: '8.1' |
| 45 | + moodle-branch: 'MOODLE_403_STABLE' |
| 46 | + database: 'mariadb' |
| 47 | + services: |
| 48 | + postgres: |
| 49 | + image: postgres:14 |
| 50 | + env: |
| 51 | + POSTGRES_USER: 'postgres' |
| 52 | + POSTGRES_HOST_AUTH_METHOD: 'trust' |
| 53 | + ports: |
| 54 | + - 5432:5432 |
| 55 | + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 |
| 56 | + |
| 57 | + mariadb: |
| 58 | + image: mariadb:10.11 |
| 59 | + env: |
| 60 | + MYSQL_USER: 'root' |
| 61 | + MYSQL_ALLOW_EMPTY_PASSWORD: "true" |
| 62 | + ports: |
| 63 | + - 3306:3306 |
| 64 | + options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3 |
| 65 | + |
| 66 | + steps: |
| 67 | + - name: Checkout |
| 68 | + uses: actions/checkout@v2 |
| 69 | + with: |
| 70 | + path: plugin |
| 71 | + |
| 72 | + - name: Setup PHP ${{ matrix.php }} |
| 73 | + uses: shivammathur/setup-php@v2 |
| 74 | + with: |
| 75 | + php-version: ${{ matrix.php }} |
| 76 | + extensions: mbstring, pgsql, mysqli |
| 77 | + ini-values: max_input_vars=5000 |
| 78 | + coverage: none |
| 79 | + |
| 80 | + - name: Initialise moodle-plugin-ci |
| 81 | + run: | |
| 82 | + composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4.5.7 |
| 83 | + # Add dirs to $PATH |
| 84 | + echo $(cd ci/bin; pwd) >> $GITHUB_PATH |
| 85 | + echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH |
| 86 | + # PHPUnit depends on en_AU.UTF-8 locale |
| 87 | + sudo locale-gen en_AU.UTF-8 |
| 88 | + echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV |
| 89 | + |
| 90 | + - name: Start JobeInABox |
| 91 | + run: sudo docker run -d -p 4000:80 --name jobe trampgeek/jobeinabox:latest |
| 92 | + |
| 93 | + - name: Let JobeInABox settle |
| 94 | + run: sleep 5s |
| 95 | + |
| 96 | + - name: Test JobeInABox |
| 97 | + run: | |
| 98 | + curl http://localhost:4000/jobe/index.php/restapi/languages |
| 99 | + curl http://localhost:4000/jobe/index.php/restapi/runs -H 'Content-Type: application/json; charset=utf-8' --data-binary '{"run_spec":{"language_id":"python3","sourcecode":"print(\"Hello sandbox!\")","sourcefilename":"__tester__.python3","input":"","file_list":[]}}' |
| 100 | + |
| 101 | + - name: Create Test sandbox configuration |
| 102 | + run: | |
| 103 | + echo "<?php" > plugin/tests/fixtures/test-sandbox-config.php |
| 104 | + echo "set_config('jobesandbox_enabled', 1, 'qtype_coderunner');" >> plugin/tests/fixtures/test-sandbox-config.php |
| 105 | + echo "set_config('jobe_host', 'localhost:4000', 'qtype_coderunner');" >> plugin/tests/fixtures/test-sandbox-config.php |
| 106 | + # Display it, at least for now, so it is east to check. |
| 107 | + cat plugin/tests/fixtures/test-sandbox-config.php |
| 108 | + |
| 109 | + - name: Install Moodle |
| 110 | + run: | |
| 111 | + moodle-plugin-ci add-plugin trampgeek/moodle-qbehaviour_adaptive_adapted_for_coderunner |
| 112 | + moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 |
| 113 | + moodle-plugin-ci add-config 'define("QTYPE_CODERUNNER_JOBE_HOST", "localhost:4000");' |
| 114 | + env: |
| 115 | + DB: ${{ matrix.database }} |
| 116 | + MOODLE_BRANCH: ${{ matrix.moodle-branch }} |
| 117 | + |
| 118 | + - name: PHP Lint |
| 119 | + continue-on-error: true # This step will show errors but will not fail |
| 120 | + if: ${{ always() }} |
| 121 | + run: moodle-plugin-ci phplint |
| 122 | + |
| 123 | + - name: PHP Copy/Paste Detector |
| 124 | + continue-on-error: true # This step will show errors but will not fail |
| 125 | + if: ${{ always() }} |
| 126 | + run: moodle-plugin-ci phpcpd |
| 127 | + |
| 128 | + - name: PHP Mess Detector |
| 129 | + continue-on-error: true # This step will show errors but will not fail |
| 130 | + if: ${{ always() }} |
| 131 | + run: moodle-plugin-ci phpmd |
| 132 | + |
| 133 | + - name: Moodle Code Checker |
| 134 | + continue-on-error: true # This step will show errors but will not fail |
| 135 | + if: ${{ always() }} |
| 136 | + run: moodle-plugin-ci codechecker --max-warnings 0 |
| 137 | + |
| 138 | + - name: Moodle PHPDoc Checker |
| 139 | + continue-on-error: true # This step will show errors but will not fail |
| 140 | + if: ${{ always() }} |
| 141 | + run: moodle-plugin-ci phpdoc |
| 142 | + |
| 143 | + - name: Validating |
| 144 | + if: ${{ always() }} |
| 145 | + run: moodle-plugin-ci validate |
| 146 | + |
| 147 | + - name: Check upgrade savepoints |
| 148 | + if: ${{ always() }} |
| 149 | + run: moodle-plugin-ci savepoints |
| 150 | + |
| 151 | + - name: Mustache Lint |
| 152 | + if: ${{ always() }} |
| 153 | + run: moodle-plugin-ci mustache |
| 154 | + |
| 155 | + - name: Grunt |
| 156 | + if: ${{ matrix.moodle-branch == 'MOODLE_400_STABLE' }} |
| 157 | + run: moodle-plugin-ci grunt |
| 158 | + |
| 159 | + - name: PHPUnit tests |
| 160 | + if: ${{ always() }} |
| 161 | + run: moodle-plugin-ci phpunit |
| 162 | + |
| 163 | + - name: Behat features |
| 164 | + if: ${{ always() }} |
| 165 | + run: moodle-plugin-ci behat --profile chrome |
0 commit comments