Skip to content

Instantly share code, notes, and snippets.

@Zhuoqin
Last active May 12, 2021 17:45
Show Gist options
  • Save Zhuoqin/a6eaed701e9fa0d6d7d0e4385077d6df to your computer and use it in GitHub Desktop.
Save Zhuoqin/a6eaed701e9fa0d6d7d0e4385077d6df to your computer and use it in GitHub Desktop.
After checking a couple of online examples, I created an example of git lab ci for moodle plugin ci testing
image: moodlehq/moodle-php-apache:7.3-stretch
services:
- postgres:9.6
variables:
MOODLE_BRANCH: "MOODLE_39_STABLE"
DB: "pgsql"
POSTGRES_DB: moodle
POSTGRES_DB_USED: mdlunit
POSTGRES_USER: moodle
POSTGRES_PASSWORD: moodle
TRAVIS_BUILD_DIR: "$CI_PROJECT_DIR"
# - 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:
- ls
- 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 $POSTGRES_DB_USED;" || true
- echo "Install NPM"
- curl -sL https://deb.nodesource.com/setup_14.x | bash -
- apt-get install -y nodejs
- cd ..
- rm -rf -- ci
# Install composer.
- curl -sS https://getcomposer.org/installer | php
- mv composer.phar /usr/local/bin/composer
- composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
- chmod u+x ci/bin/moodle-plugin-ci
- chmod u+x ci/bin/*
- umask u+x
- ls
- pwd
- moodle-plugin-ci install --db-user=$POSTGRES_USER --db-name=$POSTGRES_DB_USED --db-pass=$POSTGRES_PASSWORD --db-host=postgres -vvv
- ls
.job_template: &job_definition
script:
# - 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
# install docker inside of debian
- apt-get install -y apt-transport-https ca-certificates gnupg lsb-release
- curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
- apt-get update
- apt-get install -y docker-ce docker-ce-cli containerd.io
- service docker start
# run behat test using docker started selenium
- moodle-plugin-ci behat
- exit $EXIT_STATUS
Test:
<<: *job_definition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment