From 527831df6b61469ee4221f200d64a812eacea178 Mon Sep 17 00:00:00 2001 From: Vincent Cornelis Date: Thu, 9 Dec 2021 13:38:46 +0100 Subject: [PATCH 1/4] add github workflow moodle-release --- .github/workflows/ci.yml | 123 +++++++++++++++++++++++++++ .github/workflows/moodle-release.yml | 66 ++++++++++++++ .travis.yml | 50 ----------- 3 files changed, 189 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/moodle-release.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b5e85df --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,123 @@ +name: Moodle Plugin CI + +on: [ push, pull_request ] + +jobs: + test: + runs-on: ubuntu-18.04 + + services: + postgres: + image: postgres:10 + 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: + 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 + - php: '7.4' + moodle-branch: 'MOODLE_310_STABLE' + database: mariadb + - php: '7.3' + moodle-branch: 'MOODLE_39_STABLE' + database: 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: ${{ always() }} + run: moodle-plugin-ci codechecker --max-warnings 0 + + - name: Moodle PHPDoc Checker + 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 + continue-on-error: true # This step will show errors but will not fail + if: ${{ always() }} + run: moodle-plugin-ci grunt --max-lint-warnings 0 + + - name: PHPUnit tests + if: ${{ always() }} + run: moodle-plugin-ci phpunit + + - name: Core privacy tests + if: ${{ always() }} + run: | + cd moodle + php admin/tool/phpunit/cli/init.php + vendor/bin/phpunit --fail-on-risky --disallow-test-output -v --filter tool_dataprivacy_metadata_registry_testcase + vendor/bin/phpunit --fail-on-risky --disallow-test-output -v --filter provider_testcase + + - 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..bfb5ef6 --- /dev/null +++ b/.github/workflows/moodle-release.yml @@ -0,0 +1,66 @@ +# +# Whenever a new tag 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: + - '*' + + 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: availability_ipaddress + 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 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7f7b817..0000000 --- a/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -language: php - -addons: - postgresql: "9.6" - -services: - - mysql - - postgresql - - docker - -cache: - directories: - - $HOME/.composer/cache - - $HOME/.npm - -php: - - 7.2 - - 7.4 - -env: - global: - - MOODLE_BRANCH=MOODLE_310_STABLE - matrix: - - DB=pgsql - - DB=mysqli - -before_install: - - phpenv config-rm xdebug.ini - - nvm install 14 # moodle-plugin-ci still uses 8.9, but Moodle core switched to 14 in MDL-66109. - - nvm use 14 - - cd ../.. - - composer create-project -n --no-dev --prefer-dist blackboard-open-source/moodle-plugin-ci ci dev-master - - export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH" - #- docker run -d -p 127.0.0.1:4444:4444 --net=host -v /dev/shm:/dev/shm selenium/standalone-chrome:3 - -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 phpdoc - - moodle-plugin-ci phpunit - #- moodle-plugin-ci behat --profile chrome --dump \ No newline at end of file From 28f6d4603b703054244e47659b6b1f73ccbb3dfd Mon Sep 17 00:00:00 2001 From: Vincent Cornelis Date: Thu, 9 Dec 2021 13:42:54 +0100 Subject: [PATCH 2/4] added end-of-lines --- .github/workflows/moodle-release.yml | 2 +- classes/condition.php | 2 +- classes/frontend.php | 2 +- lang/en/availability_ipaddress.php | 2 +- version.php | 2 +- yui/src/form/js/form.js | 2 +- yui/src/form/meta/form.json | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/moodle-release.yml b/.github/workflows/moodle-release.yml index bfb5ef6..cfc69d8 100644 --- a/.github/workflows/moodle-release.yml +++ b/.github/workflows/moodle-release.yml @@ -63,4 +63,4 @@ jobs: RESPONSE: ${{ steps.add-version.outputs.response }} run: | jq <<< ${RESPONSE} - jq --exit-status ".id" <<< ${RESPONSE} > /dev/null \ No newline at end of file + jq --exit-status ".id" <<< ${RESPONSE} > /dev/null diff --git a/classes/condition.php b/classes/condition.php index 42a7f3a..9f8dbea 100644 --- a/classes/condition.php +++ b/classes/condition.php @@ -179,4 +179,4 @@ class condition extends \core_availability\condition { 'ipaddresses' => $this->ipaddresses, ]; } -} \ No newline at end of file +} diff --git a/classes/frontend.php b/classes/frontend.php index 923814f..85dffdc 100644 --- a/classes/frontend.php +++ b/classes/frontend.php @@ -47,4 +47,4 @@ class frontend extends \core_availability\frontend { 'error_ipaddress', ]; } -} \ No newline at end of file +} diff --git a/lang/en/availability_ipaddress.php b/lang/en/availability_ipaddress.php index baa7295..1442ce6 100644 --- a/lang/en/availability_ipaddress.php +++ b/lang/en/availability_ipaddress.php @@ -35,4 +35,4 @@ $string['js:ipaddress'] = 'Require network address'; $string['error_ipaddress'] = 'Incorrect ip-address/subnet format'; // Privacy provider. -$string['privacy:metadata'] = 'The restriction by activity ipaddress plugin does not store any personal data.'; \ No newline at end of file +$string['privacy:metadata'] = 'The restriction by activity ipaddress plugin does not store any personal data.'; diff --git a/version.php b/version.php index e03b1d8..84d82b3 100644 --- a/version.php +++ b/version.php @@ -30,4 +30,4 @@ $plugin->component = 'availability_ipaddress'; $plugin->version = 2020111800; $plugin->release = '3.10.0'; $plugin->requires = 2016120500; -$plugin->maturity = MATURITY_STABLE; \ No newline at end of file +$plugin->maturity = MATURITY_STABLE; diff --git a/yui/src/form/js/form.js b/yui/src/form/js/form.js index 77a4421..ebc6782 100644 --- a/yui/src/form/js/form.js +++ b/yui/src/form/js/form.js @@ -180,4 +180,4 @@ M.availability_ipaddress.form.fillErrors = function(errors, node) { if (M.availability_ipaddress.validateIpaddress(value.ipaddresses) === false) { errors.push('availability_ipaddress:error_ipaddress'); } -}; \ No newline at end of file +}; diff --git a/yui/src/form/meta/form.json b/yui/src/form/meta/form.json index b9b1508..844bc51 100644 --- a/yui/src/form/meta/form.json +++ b/yui/src/form/meta/form.json @@ -7,4 +7,4 @@ "moodle-core_availability-form" ] } -} \ No newline at end of file +} From 5d25933dfb7b00891384f30565da77ffbdadddd6 Mon Sep 17 00:00:00 2001 From: Vincent Cornelis Date: Thu, 9 Dec 2021 13:54:49 +0100 Subject: [PATCH 3/4] bumped versionnumber --- version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.php b/version.php index 84d82b3..8cef8ea 100644 --- a/version.php +++ b/version.php @@ -27,7 +27,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'availability_ipaddress'; -$plugin->version = 2020111800; +$plugin->version = 2021120900; $plugin->release = '3.10.0'; $plugin->requires = 2016120500; $plugin->maturity = MATURITY_STABLE; From 54ac7002d87c80babb1ed8b8e6538012c618ee82 Mon Sep 17 00:00:00 2001 From: Vincent Cornelis Date: Wed, 15 Dec 2021 11:26:08 +0100 Subject: [PATCH 4/4] bumped versionnumber --- version.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.php b/version.php index 8cef8ea..13dce77 100644 --- a/version.php +++ b/version.php @@ -27,7 +27,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'availability_ipaddress'; -$plugin->version = 2021120900; -$plugin->release = '3.10.0'; +$plugin->version = 2021121500; +$plugin->release = '3.11.0'; $plugin->requires = 2016120500; $plugin->maturity = MATURITY_STABLE;