-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (179 loc) · 8.09 KB
/
ci-cd.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Continuous Integration & Continuous Deployment
on: [push]
env:
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
jobs:
phpcs:
name: phpcs
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
tools: composer:v2, phpcs, cs2pr
- uses: actions/checkout@v4
- run: composer install --prefer-dist
- run: ./vendor/bin/phpcs --report=checkstyle | cs2pr
php-deprecation-detector:
name: php-deprecation-detector
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
tools: psalm, composer:v2
- uses: actions/checkout@v4
- run: cd tools/php-deprecation-detector && composer install --prefer-dist
# PHP 8.2 is not already supported by this tools:
# @see https://github.com/wapmorgan/PhpDeprecationDetector/issues/73
- run: ./tools/php-deprecation-detector/vendor/bin/phpdd --target 8.1 \
--file-extensions php,module,inc,install,test,profile,theme,info \
./web/modules/custom
- run: ./tools/php-deprecation-detector/vendor/bin/phpdd --target 8.1 --file-extensions php ./behat
php-cs-fixer:
name: php-cs-fixer
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
tools: php-cs-fixer, cs2pr, composer:v2
- uses: actions/checkout@v4
- run: cd tools/php-cs-fixer && composer install --prefer-dist
- run: ./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --using-cache=no --dry-run --format=checkstyle | cs2pr
phpstan:
name: phpstan
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
tools: phpstan, cs2pr, composer:v2
- uses: actions/checkout@v4
- run: composer install
- run: ./vendor/bin/phpstan analyse ./web/modules/custom ./behat --error-format=checkstyle | cs2pr
psalm:
name: psalm
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
tools: psalm, composer:v2
- uses: actions/checkout@v4
- run: composer install --prefer-dist
- run: cd tools/psalm && composer install --prefer-dist
- run: ./tools/psalm/vendor/bin/psalm --output-format=github --no-cache
upgrade-status:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker compose -f docker-compose.yml -f docker-compose.ci.yml pull --include-deps test browser elasticsearch
- name: Build the docker compose stack
run: |
docker compose -f docker-compose.yml -f docker-compose.ci.yml build --build-arg user=$(id -u) --build-arg group=$(id -g) test
mkdir -p ./log ./backups
- name: Run the docker stack
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml up -d test browser elasticsearch
- name: Bootstrap
run: docker compose exec -T test docker-as-wait db:3306 elasticsearch:9200 -- docker-as-drupal bootstrap
- name: Enable upgrade status
run: docker compose exec -T test docker-as-wait db:3306 -- ./vendor/bin/drush en upgrade_status -y
- name: Run upgrade status
run: docker compose exec -T test docker-as-wait db:3306 -- /var/www/vendor/bin/drush upgrade_status:analyze --ignore-contrib --ignore-uninstalled --all
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker compose -f docker-compose.yml -f docker-compose.ci.yml pull --include-deps test
- name: Build the docker compose stack
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml up --build -d test
- name: Run unit tests
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -T test docker-as-wait db:3306 test:80 -- docker-as-drupal phpunit --skip-default-stops --group=gos --exclude-group=gos_functional
# functional-tests:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - run: docker compose -f docker-compose.yml -f docker-compose.ci.yml pull --include-deps test browser elasticsearch
# - name: Build the docker compose stack
# run: |
# docker compose -f docker-compose.yml -f docker-compose.ci.yml up --build -d test browser elasticsearch
# mkdir -p ./log ./backups
# - name: Bootstrap
# run: docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -T test docker-as-wait db:3306 elasticsearch:9200 -- docker-as-drupal bootstrap --install-only
# - name: Run Functional tests
# run: docker compose -f docker-compose.yml -f docker-compose.ci.yml exec -T test docker-as-wait db:3306 test:80 browser:4444 elasticsearch:9200 -- docker-as-drupal phpunit --skip-default-stops --group=gos_functional --user=www-data
# - name: Upload Artifact
# uses: actions/upload-artifact@v4
# if: failure()
# with:
# path: ./log
behat-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker compose -f docker-compose.yml -f docker-compose.ci.yml pull --include-deps test browser elasticsearch
- name: Build the docker compose stack
run: |
docker compose -f docker-compose.yml -f docker-compose.ci.yml build --build-arg user=$(id -u) --build-arg group=$(id -g) test
mkdir -p ./log ./backups
- name: Run the docker stack
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml up -d test browser elasticsearch
- name: Bootstrap
run: docker compose exec -T test docker-as-wait db:3306 elasticsearch:9200 -- docker-as-drupal bootstrap --force --with-default-content
- name: Warmup Elasticsearch
run: |
docker compose exec -T test docker-as-wait db:3306 elasticsearch:9200 -- /var/www/vendor/bin/drush eshd -y
docker compose exec -T test docker-as-wait db:3306 elasticsearch:9200 -- /var/www/vendor/bin/drush eshs
docker compose exec -T test docker-as-wait db:3306 elasticsearch:9200 -- /var/www/vendor/bin/drush eshr
docker compose exec -T test docker-as-wait db:3306 elasticsearch:9200 -- /var/www/vendor/bin/drush queue:run elasticsearch_helper_indexing
- name: Run Behat tests
run: docker compose exec -T test docker-as-wait db:3306 test:80 browser:4444 -- docker-as-drupal behat --skip-db-reset --skip-default-content
- name: Upload Artifact
uses: actions/upload-artifact@v4
if: failure()
with:
path: ./log
deploy_prod:
name: Deploy to Production
needs: [phpcs, php-cs-fixer, phpstan, psalm, unit-tests, behat-tests]
environment:
name: Production
url: https://api.swissgames.garden
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
env:
PRIVATE_SSH_KEY: ${{ secrets.PRIVATE_SSH_KEY }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/deploy
with:
stage: production
ssh_private_key: ${{ secrets.PRIVATE_SSH_KEY }}
deploy_staging:
name: Deploy to Staging
needs: [phpcs, php-cs-fixer, phpstan, psalm, unit-tests, behat-tests]
environment:
name: Staging
url: https://staging-api.swissgames.garden
if: github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
env:
PRIVATE_SSH_KEY: ${{ secrets.PRIVATE_SSH_KEY }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/deploy
with:
stage: staging
ssh_private_key: ${{ secrets.PRIVATE_SSH_KEY }}