-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.gitlab-ci.yml
102 lines (95 loc) · 3.57 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
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: availability_gwpayments
.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)
- /root/ci/bin/moodle-plugin-ci phplint || exit_code+=($?)
- /root/ci/bin/moodle-plugin-ci phpcpd || exit_code+=($?)
- /root/ci/bin/moodle-plugin-ci phpmd || exit_code+=($?)
- /root/ci/bin/moodle-plugin-ci codechecker || exit_code+=($?)
- /root/ci/bin/moodle-plugin-ci validate || exit_code+=($?)
- /root/ci/bin/moodle-plugin-ci savepoints || exit_code+=($?)
- /root/ci/bin/moodle-plugin-ci mustache || exit_code+=($?)
- /root/ci/bin/moodle-plugin-ci grunt || exit_code+=($?)
- /root/ci/bin/moodle-plugin-ci phpdoc || exit_code+=($?)
- /root/ci/bin/moodle-plugin-ci phpunit || exit_code+=($?)
- /root/ci/bin/moodle-plugin-ci behat || exit_code+=($?)
- for i in ${exit_code[@]}; do echo "Exit code ${exit_code[$i]}"; if [ "${exit_code[$i]}" -gt 0 ]; then exit 1; fi; done;
Moodle 3.11:
<<: *job_definition
variables:
MOODLE_BRANCH: "MOODLE_311_STABLE"
Moodle 3.10:
<<: *job_definition
variables:
MOODLE_BRANCH: "MOODLE_310_STABLE"
deploy.gitlab:
stage: deploy
image: registry.gitlab.com/gitlab-org/release-cli:latest
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.
releaseto.moodle.org:
image: php:7.4-cli
stage: release
rules:
- if: $CI_COMMIT_TAG
artifacts:
paths:
- /tmp/newbuild.zip
expire_in: 1 week
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}" | jq