Skip to content

Instantly share code, notes, and snippets.

@ragusa87
Forked from Dagefoerde/.gitlab-ci.dist.yml
Last active May 6, 2021 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ragusa87/d7aca93567ae84c965a805e8d1b29fe7 to your computer and use it in GitHub Desktop.
Save ragusa87/d7aca93567ae84c965a805e8d1b29fe7 to your computer and use it in GitHub Desktop.
GitLab CI configuration for testing Moodle plugins using moodle-plugin-ci. Thanks to @danielneis who contributed a first version (cf. https://github.com/moodlerooms/moodle-plugin-ci/pull/36).
image: moodlehq/moodle-php-apache:7.0-stretch
services:
- postgres:latest
cache:
paths:
- vendor/
- node_modules/
variables:
MOODLE_BRANCH: "MOODLE_35_STABLE"
DB: "pgsql"
POSTGRES_DB: moodle
POSTGRES_DB_USED: mdlunit
POSTGRES_USER: moodle
POSTGRES_PASSWORD: moodle
TRAVIS_BUILD_DIR: "$CI_PROJECT_DIR"
# Prepare the moodle-plugin-ci env.$schema:
# - Moodle installation MUST be outside $CI_PROJECT_DIR
# - moodle-plugin-ci MUST be in the $PATH
# - Database MUST be dropped prior to installation
# - Composer MUST be in the path for moodle-plugin-ci
# - Moodle 3.5 require Node v8 <9
before_script:
- apt-get update
- seq 1 8 | xargs -I{} mkdir -p /usr/share/man/man{} # fix issue with postgresql-client on slim images. https://bit.ly/2JzEMZf
- apt-get install -y git unzip postgresql-client-9.6
- echo "Uninstall previous Moodle version"
- export PGPASSWORD=$POSTGRES_PASSWORD
- psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "DROP DATABASE IF EXISTS mdlunit;" || true
- echo "Install NPM"
- curl -sL https://deb.nodesource.com/setup_8.x | bash -
- apt-get install -y nodejs
- echo "Run moodle-plugin-ci"
- rm -Rf ../tmp && mkdir ../tmp && cd ../tmp
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
- rm -Rf ci && rm -Rf moodle && composer create-project -n --no-dev moodlerooms/moodle-plugin-ci ci ^2
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
- chmod u+x ci/bin/moodle-plugin-ci
- echo "Run Moodle installation from tmp"
- ./ci/bin/moodle-plugin-ci install --db-user=$POSTGRES_USER --db-name=$POSTGRES_DB_USED --db-pass=$POSTGRES_PASSWORD --db-host=postgres -vvv -n --ansi
.job_template: &job_definition
script:
- EXIT_STATUS=0
- moodle-plugin-ci codechecker
- moodle-plugin-ci phpunit
- moodle-plugin-ci phplint
- moodle-plugin-ci phpcpd
- moodle-plugin-ci phpmd
- moodle-plugin-ci savepoints
- moodle-plugin-ci mustache
- moodle-plugin-ci grunt
- moodle-plugin-ci validate
- moodle-plugin-ci behat
- exit $EXIT_STATUS
mdl35-71:
<<: *job_definition
image: moodlehq/moodle-php-apache:7.0-stretch
tags:
- docker
variables:
MOODLE_BRANCH: "MOODLE_35_STABLE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment