forked from sebsoftnl/moodle-tool_usersuspension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
117 lines (110 loc) · 4.07 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
stages:
- test
- deploy
- release
variables:
DB: "mysqli"
MYSQL_ROOT_PASSWORD: "superrootpass"
TRAVIS_BUILD_DIR: "$CI_PROJECT_DIR"
MOODLE_DIR: "/var/www/html/moodle"
# If we want to ignore some templates, provide them here.
#MUSTACHE_IGNORE_NAMES: "<file>.mustache, <file2>.mustache, ..., <filen>.mustache"
PLUGIN: 'tool_usersuspension'
PATHNAME: 'admin/tool/usersuspension'
REPOURL: 'https://github.com/sebsoftnl/moodle-tool_usersuspension'
REPOSYS: 'git'
# Moodle auto format = 0, Markdown = 4, Flat txt = 2
RELEASENOTEFORMAT: '0'
.job_template: &job_definition
stage: test
services:
- mysql:5.7
cache:
paths:
- $HOME/.composer/cache
- $HOME/.npm
allow_failure: false
image: git.sebsoft.nl:5050/sebsoft/open-source/moodle-cidocker:latest
script:
- cd /root/
- umask u+x
- cd $CI_PROJECT_DIR/..
- source /root/.nvm/nvm.sh
- /root/ci/bin/moodle-plugin-ci install --moodle=$MOODLE_DIR --db-user=root --db-pass=superrootpass --db-host=mysql -vvv
# Start actually running the CI now.
- exit_code+=(0)
- failures=()
- /root/ci/bin/moodle-plugin-ci phplint || failures+=("PHPLINT")
- /root/ci/bin/moodle-plugin-ci phpcpd || true
- /root/ci/bin/moodle-plugin-ci phpmd || failures+=("PHPMD")
- /root/ci/bin/moodle-plugin-ci codechecker || failures+=("CODECHECKER")
- /root/ci/bin/moodle-plugin-ci validate || failures+=("VALIDATE")
- /root/ci/bin/moodle-plugin-ci savepoints || failures+=("SAVEPOINTS")
- /root/ci/bin/moodle-plugin-ci mustache || failures+=("MUSTACHE")
- /root/ci/bin/moodle-plugin-ci grunt || failures+=("GRUNT")
- /root/ci/bin/moodle-plugin-ci phpdoc || failures+=("PHPDOC")
- /root/ci/bin/moodle-plugin-ci phpunit || failures+=("PHPUNIT")
- /root/ci/bin/moodle-plugin-ci behat || failures+=("GRUNT")
# Dump results..
- for i in ${failures[@]}; do echo "$i -- FAIL"; done;
- if [ "${#failures[@]}" -gt "0" ]; then echo "${#failures[@]} jobs failed"; exit 1; fi;
Moodle 4.1:
<<: *job_definition
variables:
MOODLE_BRANCH: "master"
MOODLE_VERSION: 410
Moodle 4.0:
<<: *job_definition
variables:
MOODLE_BRANCH: "MOODLE_400_STABLE"
deploy.gitlab:
stage: deploy
image: registry.gitlab.com/gitlab-org/release-cli:latest
allow_failure: true
rules:
- if: $CI_COMMIT_TAG # Run this job when a tag is created manually
script:
- echo 'running deploy to create release in Gitlab'
release:
name: 'Release $CI_COMMIT_TAG'
description: './CHANGES.md' # Just read the changes from changes.md
tag_name: '$CI_COMMIT_TAG'
ref: '$CI_COMMIT_TAG'
deploy.github:
stage: deploy
image: moodlehq/moodle-php-apache:7.4
script:
- echo "Deploying to Github..."
- git checkout -b main
- if [ "$(git remote | grep github | wc -l)" -eq "0" ]; then git remote add github $PUSHLOCATION; fi
- git branch -M main
- git push -u github main
- git push -u github --tags
- echo "Deploy to Github completed..."
only:
- tags
# After the deploy has been done, it's ready to be released to Moodle.org.
release:
image: php:7.4-cli
stage: release
rules:
- if: $CI_COMMIT_TAG
script:
- echo "Releasing this to Moodle.org"
- apt-get update
- apt-get -y install zip curl jq
- mkdir -p /tmp/release/$PLUGIN
- cp -Rfv ./ /tmp/release/$PLUGIN/
- cd /tmp/release
- zip -r /tmp/newbuild.zip ./ -x '*.git*'
- ITEMID=$(curl -s -F data=@/tmp/newbuild.zip "https://moodle.org/webservice/upload.php?token=$MOODLE_ORG_TOKEN" | jq --raw-output '.[0].itemid')
- curl -s https://moodle.org/webservice/rest/server.php
--data-urlencode "wstoken=${MOODLE_ORG_TOKEN}"
--data-urlencode "wsfunction=local_plugins_add_version"
--data-urlencode "moodlewsrestformat=json"
--data-urlencode "frankenstyle=${PLUGIN}"
--data-urlencode "zipdrafitemtid=${ITEMID}"
--data-urlencode "vcsrepositoryurl=${REPOURL}"
--data-urlencode "vcssystem=${REPOSYS}"
--data-urlencode "releasenotesformat=${RELEASENOTEFORMAT}"
--data-urlencode "vcstag=${CI_COMMIT_TAG}" | jq