-
Notifications
You must be signed in to change notification settings - Fork 20
130 lines (104 loc) · 4.86 KB
/
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
name: Codeception Tests
on:
workflow_dispatch:
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop
jobs:
ci:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest ]
env:
cache_version: 2 # increment to flush all caches
PROJECT_ID: square1
COMPOSE_INTERACTIVE_NO_CLI: 1
COMPOSE_FILE: docker-compose.yml:docker-compose.gh.yml
steps:
- name: Set up PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: '8.0'
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v3
- name: Open permissions on output and directories
run: chmod 777 dev/tests/tests/_output
- name: Create .env
run: |
echo "${{ secrets.COMPOSER_ENV }}" > .env
- name: Create local config
run: |
php -r "file_exists( 'local-config.php' ) || copy( 'local-config-sample.php', 'local-config.php' );"
php -r "file_exists( 'wp-content/themes/core/local-config.json' ) || copy( 'wp-content/themes/core/local-config-sample.json', 'wp-content/themes/core/local-config.json' );"
php -r "file_exists( 'dev/tests/.env' ) || copy( 'dev/tests/.env-dist', 'dev/tests/.env' );"
echo "define( 'TWIG_CACHE', false );" >> local-config.php
echo "define( 'FORCE_SSL_LOGIN', false );" >> local-config.php
echo "define( 'FORCE_SSL_ADMIN', false );" >> local-config.php
printf 'SQ1_UID=%d\nSQ1_GID=%d\n' $(id -u) $(id -g) > dev/docker/.env
- name: Create composer config files
run: |
mkdir -p dev/docker/composer
printf '{ "config": {}, "repositories": { "packagist": { "type": "composer", "url": "https://packagist.org" } } }' > dev/docker/composer/config.json
printf '{ "github-oauth": { "github.com": "%s" } }\n' "${{ secrets.GITHUB_TOKEN }}" > dev/docker/composer/auth.json
- name: Check for Cached Composer Dependencies
uses: actions/cache@v3
with:
path: dev/docker/composer/cache
key: ${{ runner.os }}-${{ env.cache_version }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-${{ env.cache_version }}-composer-
- name: Create docker network
run: docker network create --driver=bridge --subnet=172.20.10.0/24 global_proxy
working-directory: dev/docker
- name: Start project containers
run: docker-compose --project-name=${{ env.PROJECT_ID }} up -d --force-recreate
working-directory: dev/docker
- name: Install composer dependencies
run: docker-compose --project-name=${{ env.PROJECT_ID }} exec -T php-fpm composer install --optimize-autoloader -d /application/www
working-directory: dev/docker
- name: Set up node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install gulp-cli
run: npm install gulp-cli -g
- name: Install node modules
run: yarn install --frozen-lockfile --prefer-offline
- name: Build assets
run: npm run server_dist
- name: Validate assets
run: npm run validate
- name: Create test databases
run: |
mysql -h 127.0.0.1 -uroot -ppassword -e "CREATE DATABASE tribe_square1_tests;"
mysql -h 127.0.0.1 -uroot -ppassword -e "CREATE DATABASE tribe_square1_acceptance;"
- name: Create cache dir
run: |
mkdir -p ${{ github.workspace }}/cache/
chmod -R 777 ${{ github.workspace }}/cache/
- name: Run unit tests
run: docker-compose --project-name=${{ env.PROJECT_ID }} exec -T php-tests php /application/www/vendor/bin/codecept --config "/application/www/dev/tests" run unit
working-directory: dev/docker
- name: Run integration tests
run: docker-compose --project-name=${{ env.PROJECT_ID }} exec -T php-tests php /application/www/vendor/bin/codecept --config "/application/www/dev/tests" run integration
working-directory: dev/docker
- name: Run acceptance tests
run: docker-compose --project-name=${{ env.PROJECT_ID }} exec -T php-tests php /application/www/vendor/bin/codecept --config "/application/www/dev/tests" run acceptance
working-directory: dev/docker
- name: Run webdriver tests
run: docker-compose --project-name=${{ env.PROJECT_ID }} exec -T php-tests php /application/www/vendor/bin/codecept -vvv --config "/application/www/dev/tests" run webdriver
working-directory: dev/docker
- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: test-artifacts
path: dev/tests/tests/_output/