-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy path.gitlab-ci.yml
executable file
·156 lines (133 loc) · 4.46 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
image: php:7.4
variables:
SSH_PRIVATE_KEY: ""
SSH_USER: ""
SSH_HOSTNAME: ""
SSH_PORT: ""
SSH_PATH: ""
SITE_URL: ""
SITE_USER: ""
SITE_USER_PASS: ""
stages:
- unit_tests
- build
- deploy
- acceptance_tests
unit_tests:
stage: unit_tests
only:
- develop
image: wordpress:cli-2.6
services:
- name: mysql:5.7
alias: db
variables:
MYSQL_DATABASE: "testdb"
MYSQL_ROOT_PASSWORD: "dbrootpass"
MYSQL_USER: "wordpress"
MYSQL_PASSWORD: "wordpress"
script:
# Install composer and PHP dependencies
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && php composer-setup.php
- php composer.phar install
# Move the plugin files to the separate folder
- mkdir ssp && mv `ls -A | grep -v ssp` ssp
# Download WordPress
- wp core download
# Prepare testing environment file
- touch .env.testing
- echo "TEST_WP_ROOT=$(pwd)" >> .env.testing
- echo "TEST_DB_HOST=db" >> .env.testing
- echo "TEST_DB_NAME=$MYSQL_DATABASE" >> .env.testing
- echo "TEST_DB_USER=$MYSQL_USER" >> .env.testing
- echo "TEST_DB_PASSWORD=$MYSQL_PASSWORD" >> .env.testing
- echo "TEST_DOMAIN=test.com" >> .env.testing
- mv .env.testing ssp/
# Move the plugin to the plugins folder
- mv ssp ./wp-content/plugins/seriously-simple-podcasting
- cd wp-content/plugins/seriously-simple-podcasting
# Run tests
- ls -la
- vendor/bin/codecept run wpunit
build:
stage: build
only:
- develop
artifacts:
paths:
- dist
script:
# Install Composer
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php composer-setup.php
- php -r "unlink('composer-setup.php');"
- chmod +x composer.phar
- mv composer.phar /usr/local/bin/composer
# Install NPM and its dependencies
- curl -fsSL https://deb.nodesource.com/setup_17.x | bash -
- apt-get update -y
- apt-get install -y nodejs
- npm install --ignore-scripts
- apt-get install zip unzip -yqq
# Build the plugin
- export NODE_OPTIONS=--openssl-legacy-provider
- npm rebuild node-sass
- npm run predeploy
# Create the dist plugin folder for the deployment
- mkdir dist
- cp -r assets dist/assets
- cp -r build dist/build
- cp -r php dist/php
- cp -r templates dist/templates
- cp -r vendor dist/vendor
- cp LICENSE dist/LICENSE
- cp index.php dist/index.php
- cp readme.txt dist/readme.txt
- cp seriously-simple-podcasting.php dist/seriously-simple-podcasting.php
deploy:
stage: deploy
only:
- develop
dependencies:
- build
script:
- ls -la
- apt-get update
- apt-get install openssh-client openssh-server -yqq > /dev/null
- eval $(ssh-agent -s)
- ssh-add <(echo $SSH_PRIVATE_KEY | base64 --decode)
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\tPort 18765" > ~/.ssh/config'
- ssh -p$SSH_PORT $SSH_USER@$SSH_HOSTNAME "rm -rf $SSH_PATH/deploying-ssp && mkdir $SSH_PATH/deploying-ssp"
- scp -P$SSH_PORT -r dist/* $SSH_USER@$SSH_HOSTNAME:$SSH_PATH/deploying-ssp
- ssh -p$SSH_PORT $SSH_USER@$SSH_HOSTNAME "rm -rf $SSH_PATH/wp-content/plugins/seriously-simple-podcasting && mv $SSH_PATH/deploying-ssp $SSH_PATH/wp-content/plugins/seriously-simple-podcasting && cd $SSH_PATH && wp db import seed.sql"
acceptance_tests:
stage: acceptance_tests
only:
- develop
script:
# Install Composer dependencies
- apt-get update -yqq
- apt-get install -yqq libfreetype6-dev libjpeg62-turbo-dev libpng-dev
# @see https://hub.docker.com/_/php
- docker-php-ext-configure gd --with-freetype --with-jpeg > /dev/null
- docker-php-ext-install gd > /dev/null
- apt-get install zip unzip -yqq
- apt-get install git -yqq
# Install Composer
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php composer-setup.php
- php -r "unlink('composer-setup.php');"
- chmod +x composer.phar
- mv composer.phar /usr/local/bin/composer
# Get all libraries
- composer install
# Prepare environment
- touch .env.testing
- echo "SITE_URL=$SSH_USER" >> .env.testing
- echo "SITE_USER=$SITE_USER" >> .env.testing
- echo "SITE_USER_PASS=$SITE_USER_PASS" >> .env.testing
- echo "PODCAST_GUID=115e423a-72d2-531e-9d3c-ece7dd4b74fe" >> .env.testing
# Run Acceptance tests
- vendor/bin/codecept run acceptance --steps