-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.gitlab-ci.yml
172 lines (163 loc) · 5.77 KB
/
.gitlab-ci.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# QUICK SETUP:
# Install Runner `brew install gitlab-runner` & `brew services start gitlab-runner` - https://docs.gitlab.com/runner/install/
# Install Docker - `brew cask install docker`
# Run Docker via GUI
# Run `gitlab-runner exec docker <job>`
# More info in ./doc/development.md
variables:
TRAVIS_BUILD_DIR: "$CI_PROJECT_DIR"
IGNORE_PATHS: "vendor,node_modules"
PHPUNIT_IGNORE_PATHS: "$IGNORE_PATHS,cli"
cache:
paths:
- $HOME/.composer/cache
- $HOME/.npm
before_script:
# Check distro.
- cat /etc/os-release
# Install correct DB dynamically.
- apt update && apt install git-core $DBAPT npm -y > /dev/null
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
- source ~/.bashrc
- nvm install 14.0.0
- nvm use 14.0.0
- service $DBSERVICE start
- cd $CI_PROJECT_DIR/..
- curl -sS https://getcomposer.org/installer | php
- mv composer.phar /usr/local/bin/composer
# Cleaning up.
- echo "Cleaning up old ./ci" && rm -rf $CI_PROJECT_DIR/ci
- echo "Cleaning up old ./moodle" && rm -rf $CI_PROJECT_DIR/moodle
- composer create-project --no-interaction --no-dev --prefer-dist --quiet moodlehq/moodle-plugin-ci ci ^3
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
# MySQL/MariaDB special..... Allow for user w/o password.
# Setting auth type to mysqlnative - essential for phpdoc to work, but probs good/easier (for testing) anyway...
# Credit: https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost.
# Turns out PostgreSQL is special too. We need to update the 'access' config file - which varies by distro....
# To find it location: https://stackoverflow.com/questions/14025972/postgresql-how-to-find-pg-hba-conf-file-using-mac-os-x/16674380#16674380
- >
if [ $DB == "mysqli" ] || [ $DB == "mariadb" ]; then
mysql -e 'USE mysql; SELECT User, Host, plugin FROM mysql.user; UPDATE user SET plugin="mysql_native_password" WHERE User="root"; FLUSH PRIVILEGES; SELECT User, Host, plugin FROM mysql.user;'
elif [ $DB == "pgsql" ]; then
ls -lah /etc/postgresql
echo "host all all 127.0.0.1/32 trust" >| /etc/postgresql/11/main/pg_hba.conf
fi
- service $DBSERVICE restart
# echo "host all all 127.0.0.1 trust" | tee -a /var/lib/pgsql/data/pg_hba.conf
# find / pg_hba.conf -type f -exec echo "host all all 127.0.0.1 trust" | tee -a {} \;
# Change localhost to 127.0.0.1 for phpdoc.
- moodle-plugin-ci install --db-host=127.0.0.1 --db-type=$DB -v
.job_template: &job_definition
script:
- EXIT_STATUS=0
- moodle-plugin-ci phplint || EXIT_STATUS=$? ; echo "EXIT STATUS - $EXIT_STATUS"
- moodle-plugin-ci phpcpd || EXIT_STATUS=$? ; echo "EXIT STATUS - $EXIT_STATUS"
- moodle-plugin-ci phpmd || EXIT_STATUS=$? ; echo "EXIT STATUS - $EXIT_STATUS"
- moodle-plugin-ci phpdoc || EXIT_STATUS=$? ; echo "EXIT STATUS - $EXIT_STATUS"
- moodle-plugin-ci phpunit --coverage-text || EXIT_STATUS=$? ; echo "EXIT STATUS - $EXIT_STATUS"
- moodle-plugin-ci codechecker || EXIT_STATUS=$? ; echo "EXIT STATUS - $EXIT_STATUS"
- moodle-plugin-ci validate || EXIT_STATUS=$? ; echo "EXIT STATUS - $EXIT_STATUS"
- moodle-plugin-ci grunt -t css || EXIT_STATUS=$? ; echo "EXIT STATUS - $EXIT_STATUS" # Thanks https://github.com/open-lms-open-source/moodle-plugin-ci/issues/72#issuecomment-358426352
# - moodle-plugin-ci savepoints || EXIT_STATUS=$? ; echo "EXIT STATUS - $(tput bold)$EXIT_STATUS$(tput sgr0)"
- exit $EXIT_STATUS
# TODO - Make mysql work. Switch to different distro or install mysql.
# Setup jobs as stages to run sequentially.
stages:
# - job1
# - job2
# - job3
# - job4
# - job5
# - job6
# - job7
- job8
# - job9
# TODO - Only test highest and lowest.
# Test each active version of PHP.
#job1:
# <<: *job_definition
# stage: job1
# image: moodlehq/moodle-php-apache:7.2
# variables:
# MOODLE_BRANCH: "MOODLE_35_STABLE"
# DB: mariadb
# DBAPT: default-mysql-server
# DBSERVICE: mysql
#
#job2:
# <<: *job_definition
# stage: job2
# image: moodlehq/moodle-php-apache:7.2
# variables:
# MOODLE_BRANCH: "MOODLE_35_STABLE"
# DB: mariadb
# DBAPT: mariadb-server
# DBSERVICE: mysql
#job3:
# <<: *job_definition
# stage: job3
# image: moodlehq/moodle-php-apache:7.2
# variables:
# MOODLE_BRANCH: "MOODLE_35_STABLE"
# DB: pgsql
# DBAPT: postgresql postgresql-contrib
# DBSERVICE: postgresql
#
#job4:
# <<: *job_definition
# stage: job4
# image: moodlehq/moodle-php-apache:7.3
# variables:
# MOODLE_BRANCH: "MOODLE_35_STABLE"
# DB: mariadb
# DBAPT: mysql-server
# DBSERVICE: mysql
#
#job5:
# <<: *job_definition
# stage: job5
# image: moodlehq/moodle-php-apache:7.3
# variables:
# MOODLE_BRANCH: "MOODLE_35_STABLE"
# DB: mariadb
# DBAPT: mariadb-server
# DBSERVICE: mysql
#
#job6:
# <<: *job_definition
# stage: job6
# image: moodlehq/moodle-php-apache:7.3
# variables:
# MOODLE_BRANCH: "MOODLE_35_STABLE"
# DB: pgsql
# DBAPT: postgresql postgresql-contrib
# DBSERVICE: postgresql
#
### Only test the earliest and latest supported version of Moodle.
#job7:
# <<: *job_definition
# stage: job7
# image: moodlehq/moodle-php-apache:7.4
# variables:
# MOODLE_BRANCH: "MOODLE_39_STABLE"
# DB: mariadb
# DBAPT: default-mysql-server
# DBSERVICE: mysql
job8:
<<: *job_definition
stage: job8
image: moodlehq/moodle-php-apache:7.4
variables:
MOODLE_BRANCH: "MOODLE_39_STABLE"
DB: mariadb
DBAPT: mariadb-server
DBSERVICE: mysql
#job9:
# <<: *job_definition
# stage: job9
# image: moodlehq/moodle-php-apache:7.4
# variables:
# MOODLE_BRANCH: "MOODLE_39_STABLE"
# DB: pgsql
# DBAPT: postgresql postgresql-contrib
# DBSERVICE: postgresql