-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci-template.yml
77 lines (72 loc) · 3.08 KB
/
.gitlab-ci-template.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
## Gitlab CI/CD template for Moodle plugins By Ldesign Media.
## Author: Hamza Tamyachte
## Copyright 17/07/2024 Mfreak.nl | LdesignMedia.nl - Luuk Verhoeven
services:
- mysql:latest
- name: selenium/standalone-chrome:3
alias: selenium-standalone-chrome
variables:
PHP_VERSION: "8.0"
TRAVIS_BUILD_DIR: "$CI_PROJECT_DIR"
MOODLE_REPO: "https://github.com/moodle/moodle.git"
# Moodle branches.
# Workplace.
MOODLE_BRANCH_WORKPLACE404S: WORKPLACE_404_3
MOODLE_BRANCH_WORKPLACE403S: WORKPLACE_403_7
MOODLE_BRANCH_WORKPLACE402S: WORKPLACE_402_10
MOODLE_BRANCH_WORKPLACE401S: WORKPLACE_401_13
# LMS.
MOODLE_BRANCH_LMS404: MOODLE_404_STABLE
MOODLE_BRANCH_LMS403: MOODLE_403_STABLE
MOODLE_BRANCH_LMS402: MOODLE_402_STABLE
MOODLE_BRANCH_LMS401: MOODLE_401_STABLE
MOODLE_BRANCH_LMS400: MOODLE_400_STABLE
MOODLE_BRANCH_LMS39: MOODLE_39_STABLE
# Selenium.
MOODLE_BEHAT_WDHOST: "http://selenium-standalone-chrome:4444/wd/hub"
MOODLE_START_BEHAT_SERVERS: "NO"
# Database.
DB: "mysqli"
MYSQL_ROOT_PASSWORD: "superrootpass"
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
.scriptshorttest: &scriptshorttest
image: moodlehq/moodle-workplace-plugin-ci:$PHP_VERSION
script:
# Update packages and/or install.
- apt update && apt install -y mariadb-client
- cd $CI_PROJECT_DIR/..
- echo $MOODLE_REPO
- rm -rf moodle
# Install Moodle includes the setup of PHPUnit and Behat when tests exist in the plugin directory.
- export IPADDRESS=`grep "${HOSTNAME}$" /etc/hosts |awk '{print $1}'`
- export MOODLE_BEHAT_WWWROOT="http://${IPADDRESS}:8000"
- moodle-plugin-ci install --db-user=root --db-pass=superrootpass --db-host=mysql -vvv
- cd moodle
- php -S ${IPADDRESS}:8000 -t $CI_PROJECT_DIR/../moodle > /dev/null 2>&1 &
- |
ORANGE='\033[38;5;214m'
RESET='\033[0m'
run_with_error_handling() {
local command="$1"
local allow_errors_var="$2"
local allow_errors_value="${!allow_errors_var}"
if [ "$allow_errors_value" = "true" ]; then
eval "$command" || true
echo -e "${ORANGE}-- ${command^^} ERRORS SKIPPED${RESET}"
else
eval "$command"
fi
}
run_with_error_handling "moodle-plugin-ci phplint" "ALLOW_ERRORS_PHPLINT"
run_with_error_handling "moodle-plugin-ci phpcpd" "ALLOW_ERRORS_PHPCPD"
run_with_error_handling "moodle-plugin-ci phpmd" "ALLOW_ERRORS_PHPMD"
run_with_error_handling "moodle-plugin-ci codechecker" "ALLOW_ERRORS_CODECHECKER"
run_with_error_handling "moodle-plugin-ci mustache" "ALLOW_ERRORS_MUSTACHE"
run_with_error_handling "moodle-plugin-ci validate" "ALLOW_ERRORS_VALIDATE"
run_with_error_handling "moodle-plugin-ci savepoints" "ALLOW_ERRORS_SAVEPOINTS"
run_with_error_handling "moodle-plugin-ci grunt" "ALLOW_ERRORS_GRUNT"
run_with_error_handling "moodle-plugin-ci phpdoc" "ALLOW_ERRORS_PHPDOC"
run_with_error_handling "moodle-plugin-ci phpunit" "ALLOW_ERRORS_PHPUNIT"
run_with_error_handling "moodle-plugin-ci behat --suite default --profile chrome" "ALLOW_ERRORS_BEHAT"
except:
- tags