From f7f94ba83bf8ad96c11aa20d1426cfd2b09e52a7 Mon Sep 17 00:00:00 2001 From: Darko Miletic Date: Mon, 20 Mar 2023 18:52:43 -0300 Subject: [PATCH 1/3] Clean and lean example of testing moodle plugin with bitbucket pipelines --- bitbucket-plugins.dist.yml | 82 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 bitbucket-plugins.dist.yml diff --git a/bitbucket-plugins.dist.yml b/bitbucket-plugins.dist.yml new file mode 100644 index 00000000..775f6797 --- /dev/null +++ b/bitbucket-plugins.dist.yml @@ -0,0 +1,82 @@ + +definitions: + setupdeps: &setupDeps + export DEBIAN_FRONTEND='noninteractive' ; + export COMPOSER_ALLOW_SUPERUSER=1 ; + export COMPOSER_CACHE_DIR='/root/.composer/cache' ; + export MOODLE_START_BEHAT_SERVERS='NO' ; + export CI_BUILD_DIR='/tmp/plugin' ; + export MOODLE_BEHAT_WWWROOT="http://$BITBUCKET_DOCKER_HOST_INTERNAL:8000" ; + export MOODLE_BEHAT_WDHOST="http://$BITBUCKET_DOCKER_HOST_INTERNAL:4444/wd/hub" ; + export MOODLE_REPO='https://bitbucket.org/moodle/moodle.git' ; + export MOODLE_BRANCH='MOODLE_311_STABLE' ; + export DB='mariadb' ; + mkdir -pv "$CI_BUILD_DIR" && cp -ru "$BITBUCKET_CLONE_DIR/"* "$CI_BUILD_DIR" && + mkdir -p /usr/share/man/man1 /usr/share/man/man3 /usr/share/man/man7 && + apt-get -q update && apt-get -yq install default-jre-headless mariadb-client && + curl -sS https://raw.githubusercontent.com/creationix/nvm/v0.39.3/install.sh | bash && + . ~/.bashrc && nvm install --default --latest-npm lts/gallium && + curl -sS https://getcomposer.org/installer | php -- --install-dir='/usr/local/bin' --filename='composer' && + composer create-project -n --no-dev --no-progress --no-ansi moodlehq/moodle-plugin-ci /opt/mci ^3 && + export PATH="/opt/mci/bin:/opt/mci/vendor/bin:$PATH" + startbehat: &startBehat + export MPATH="$BITBUCKET_CLONE_DIR/moodle" ; + docker run -d -p 4444:4444 --shm-size=1g -v "$MPATH:$MPATH" 'selenium/standalone-firefox:3' && + { php -S 0.0.0.0:8000 -t "$moodle" >/dev/null 2>&1 & } && + sleep 10s + services: + mariadb: + image: mariadb:10 + variables: + MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 'yes' + caches: + npm: $HOME/.npm + +pipelines: + default: + - step: + name: 'Moodle 3.11, PHP 7.4 and MariaDB 10' + image: moodlehq/moodle-php-apache:7.4 + services: + - mariadb + caches: + - npm + - composer + script: + - *setupDeps + - moodle-plugin-ci install --db-host='127.0.0.1' + - 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 + - step: + name: 'Moodle 4.0, PHP 8.0 and MariaDB 10' + image: moodlehq/moodle-php-apache:8.0 + services: + - mariadb + - docker + caches: + - npm + - composer + - docker + script: + - *setupDeps + - moodle-plugin-ci install --db-host='127.0.0.1' --branch='MOODLE_400_STABLE' + - *startBehat + - 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 From c40e7c9504af82a80148d7b9fad706c44f6aa290 Mon Sep 17 00:00:00 2001 From: Darko Miletic Date: Mon, 20 Mar 2023 19:04:01 -0300 Subject: [PATCH 2/3] Rename the file --- bitbucket-plugins.dist.yml => bitbucket-pipelines.dist.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bitbucket-plugins.dist.yml => bitbucket-pipelines.dist.yml (100%) diff --git a/bitbucket-plugins.dist.yml b/bitbucket-pipelines.dist.yml similarity index 100% rename from bitbucket-plugins.dist.yml rename to bitbucket-pipelines.dist.yml From b488248a7d1ae51db5964814fc84122d296ede85 Mon Sep 17 00:00:00 2001 From: Darko Miletic Date: Tue, 21 Mar 2023 09:19:03 -0300 Subject: [PATCH 3/3] Fix incorrect variable --- bitbucket-pipelines.dist.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitbucket-pipelines.dist.yml b/bitbucket-pipelines.dist.yml index 775f6797..c122cce6 100644 --- a/bitbucket-pipelines.dist.yml +++ b/bitbucket-pipelines.dist.yml @@ -3,7 +3,7 @@ definitions: setupdeps: &setupDeps export DEBIAN_FRONTEND='noninteractive' ; export COMPOSER_ALLOW_SUPERUSER=1 ; - export COMPOSER_CACHE_DIR='/root/.composer/cache' ; + export COMPOSER_CACHE_DIR=~/.composer/cache ; export MOODLE_START_BEHAT_SERVERS='NO' ; export CI_BUILD_DIR='/tmp/plugin' ; export MOODLE_BEHAT_WWWROOT="http://$BITBUCKET_DOCKER_HOST_INTERNAL:8000" ; @@ -22,7 +22,7 @@ definitions: startbehat: &startBehat export MPATH="$BITBUCKET_CLONE_DIR/moodle" ; docker run -d -p 4444:4444 --shm-size=1g -v "$MPATH:$MPATH" 'selenium/standalone-firefox:3' && - { php -S 0.0.0.0:8000 -t "$moodle" >/dev/null 2>&1 & } && + { php -S 0.0.0.0:8000 -t "$MPATH" >/dev/null 2>&1 & } && sleep 10s services: mariadb: