diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml new file mode 100644 index 0000000..18b0b1b --- /dev/null +++ b/.github/workflows/moodle-ci.yml @@ -0,0 +1,119 @@ +name: Moodle Plugin CI + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-18.04 + + services: + postgres: + image: postgres:9.6 + env: + POSTGRES_USER: 'postgres' + POSTGRES_HOST_AUTH_METHOD: 'trust' + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 + mariadb: + # https://tracker.moodle.org/browse/MDL-72131 + image: mariadb:10.5 + env: + MYSQL_USER: 'root' + MYSQL_ALLOW_EMPTY_PASSWORD: "true" + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3 + + strategy: + fail-fast: false + matrix: + include: + - php: '7.4' + moodle-branch: 'MOODLE_311_STABLE' + database: 'pgsql' + extensions: "mbstring, pgsql" + - php: '7.3' + moodle-branch: 'MOODLE_310_STABLE' + database: 'mariadb' + extensions: "mbstring, mysqli" + - php: '7.2' + moodle-branch: 'MOODLE_39_STABLE' + database: 'pgsql' + extensions: "mbstring, pgsql" + + steps: + - name: Check out repository code + uses: actions/checkout@v2 + with: + path: plugin + + - name: Setup PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: ${{ matrix.extensions }} + 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 ^3 + 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 }} + + - name: PHP Lint + if: ${{ always() }} + run: moodle-plugin-ci phplint + + - name: PHP Copy/Paste Detector + continue-on-error: true # This step will show errors but will not fail + if: ${{ always() }} + run: moodle-plugin-ci phpcpd + + - name: PHP Mess Detector + continue-on-error: true # This step will show errors but will not fail + if: ${{ always() }} + run: moodle-plugin-ci phpmd + + - name: Moodle Code Checker + if: ${{ false }} + run: moodle-plugin-ci codechecker --max-warnings 0 + + - name: Moodle PHPDoc Checker + continue-on-error: true # This step will show errors but will not fail + if: ${{ always() }} + run: moodle-plugin-ci phpdoc + + - name: Validating + if: ${{ always() }} + run: moodle-plugin-ci validate + + - name: Check upgrade savepoints + if: ${{ always() }} + run: moodle-plugin-ci savepoints + + - name: Mustache Lint + if: ${{ always() }} + run: moodle-plugin-ci mustache + + - name: Grunt + if: ${{ false }} + run: moodle-plugin-ci grunt --max-lint-warnings 0 + + - name: PHPUnit tests + if: ${{ always() }} + run: moodle-plugin-ci phpunit + + - name: Behat features + if: ${{ always() }} + run: moodle-plugin-ci behat --profile chrome diff --git a/.github/workflows/moodle-release.yml b/.github/workflows/moodle-release.yml new file mode 100644 index 0000000..4fb6c70 --- /dev/null +++ b/.github/workflows/moodle-release.yml @@ -0,0 +1,66 @@ +# +# Whenever a new tag starting with "v" is pushed, add the tagged version +# to the Moodle Plugins directory at https://moodle.org/plugins +# +# revision: 2021070201 +# +name: Releasing in the Plugins directory + +on: + push: + tags: + - 2* + + workflow_dispatch: + inputs: + tag: + description: 'Tag to be released' + required: true + +defaults: + run: + shell: bash + +jobs: + release-at-moodle-org: + runs-on: ubuntu-latest + env: + PLUGIN: auth_ip + CURL: curl -s + ENDPOINT: https://moodle.org/webservice/rest/server.php + TOKEN: ${{ secrets.MOODLE_ORG_TOKEN }} + FUNCTION: local_plugins_add_version + + steps: + - name: Call the service function + id: add-version + run: | + if [[ ! -z "${{ github.event.inputs.tag }}" ]]; then + TAGNAME="${{ github.event.inputs.tag }}" + elif [[ $GITHUB_REF = refs/tags/* ]]; then + TAGNAME="${GITHUB_REF##*/}" + fi + if [[ -z "${TAGNAME}" ]]; then + echo "No tag name has been provided!" + exit 1 + fi + ZIPURL="https://api.github.com/repos/${{ github.repository }}/zipball/${TAGNAME}" + RESPONSE=$(${CURL} ${ENDPOINT} --data-urlencode "wstoken=${TOKEN}" \ + --data-urlencode "wsfunction=${FUNCTION}" \ + --data-urlencode "moodlewsrestformat=json" \ + --data-urlencode "frankenstyle=${PLUGIN}" \ + --data-urlencode "zipurl=${ZIPURL}" \ + --data-urlencode "vcssystem=git" \ + --data-urlencode "vcsrepositoryurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \ + --data-urlencode "vcstag=${TAGNAME}" \ + --data-urlencode "changelogurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commits/${TAGNAME}" \ + --data-urlencode "altdownloadurl=${ZIPURL}") + echo "::set-output name=response::${RESPONSE}" + + - name: Evaluate the response + id: evaluate-response + env: + RESPONSE: ${{ steps.add-version.outputs.response }} + run: | + jq <<< ${RESPONSE} + jq --exit-status ".id" <<< ${RESPONSE} > /dev/null diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d48fb29..0000000 --- a/.travis.yml +++ /dev/null @@ -1,67 +0,0 @@ -language: php - -sudo: required - -addons: - firefox: "47.0.1" - postgresql: "9.3" - apt: - packages: - - oracle-java8-installer - - oracle-java8-set-default - -cache: - directories: - - $HOME/.composer/cache - - $HOME/.npm - -php: - - 7.0 - - 7.1 - -env: - matrix: - - DB=pgsql MOODLE_BRANCH=MOODLE_32_STABLE - - DB=pgsql MOODLE_BRANCH=MOODLE_33_STABLE - - DB=pgsql MOODLE_BRANCH=MOODLE_34_STABLE - - DB=pgsql MOODLE_BRANCH=master - - DB=mysqli MOODLE_BRANCH=MOODLE_32_STABLE - - DB=mysqli MOODLE_BRANCH=MOODLE_33_STABLE - - DB=mysqli MOODLE_BRANCH=MOODLE_34_STABLE - - DB=mysqli MOODLE_BRANCH=master - -matrix: - include: - - php: 5.6 - env: DB=pgsql MOODLE_BRANCH=MOODLE_32_STABLE - - php: 5.6 - env: DB=pgsql MOODLE_BRANCH=MOODLE_33_STABLE - - php: 5.6 - env: DB=mysqli MOODLE_BRANCH=MOODLE_32_STABLE - - php: 5.6 - env: DB=mysqli MOODLE_BRANCH=MOODLE_33_STABLE - allow_failures: - - env: MOODLE_BRANCH=master - -before_install: - - phpenv config-rm xdebug.ini - - nvm install 8.9 - - nvm use 8.9 - - cd ../.. - - composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^2 - - export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH" - -install: - - moodle-plugin-ci install - -script: - - moodle-plugin-ci phplint - - moodle-plugin-ci phpcpd - - moodle-plugin-ci phpmd -# - moodle-plugin-ci codechecker - - moodle-plugin-ci validate - - moodle-plugin-ci savepoints - - moodle-plugin-ci mustache -# - moodle-plugin-ci grunt - - moodle-plugin-ci phpunit - - moodle-plugin-ci behat diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..c36b329 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,14 @@ +Release notes +============= + +1. (#12) Minimum Moodle version supported is 3.3. +1. (#12) Use Github Actions to pass tests and update release on Moodle Plugins directory. + +Contributors +============ + +Maintained by: + +* Jordi Pujol-Ahulló (at SREd, Universitat Rovira i Virgili). + +[See all Github contributors](https://github.com/SREd-URV/moodle-auth_ip/graphs/contributors) diff --git a/tests/ip_test.php b/tests/ip_test.php index 58b4344..ff485fc 100644 --- a/tests/ip_test.php +++ b/tests/ip_test.php @@ -22,7 +22,7 @@ require_once($CFG->dirroot.'/auth/ip/auth.php'); class auth_ip_testcase extends advanced_testcase { protected $authplugin; - protected function setUp() { + protected function setUp() : void { $this->authplugin = new auth_plugin_ip(); } diff --git a/version.php b/version.php index f2d3680..6710b17 100644 --- a/version.php +++ b/version.php @@ -27,9 +27,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2018053000; // The current plugin version (Date: YYYYMMDDXX) -$plugin->requires = 2012120300; // Requires this Moodle version (2.4) +$plugin->version = 2021081100; // The current plugin version (Date: YYYYMMDDXX) +$plugin->requires = 2017051500; // Requires this Moodle version (3.3) for changes in settings.php. $plugin->component = 'auth_ip'; // Full name of the plugin (used for diagnostics) $plugin->maturity = MATURITY_STABLE; -$plugin->release = '1.3 (Build: 2017020800)'; - +$plugin->release = '2021081100';