-
Notifications
You must be signed in to change notification settings - Fork 5
102 lines (87 loc) · 3.8 KB
/
test.yml
File metadata and controls
102 lines (87 loc) · 3.8 KB
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
on:
pull_request:
push:
branches: ['master', 'develop']
name: CI
env:
SYMFONY_DEPRECATIONS_HELPER: disabled
SIMPLETEST_BASE_URL: http://app:8888
APP_ENV: "test"
ASU_ELASTICSEARCH_ADDRESS: "http://elastic:9200"
ASU_ELASTICSEARCH_USERNAME: "test"
ASU_ELASTICSEARCH_PASSWORD: "pass"
ASU_DJANGO_BACKEND_URL: "https://django-backend-test-url.fi"
jobs:
tests:
runs-on: ubuntu-latest
container:
image: ghcr.io/city-of-helsinki/drupal-php-docker:8.3-alpine
options: --hostname app
services:
db:
image: mysql:8
env:
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
MYSQL_DATABASE: drupal
MYSQL_ROOT_PASSWORD: drupal
ports:
- 3306:3306
elastic:
image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
env:
xpack.security.enabled: false
discovery.type: single-node
ports:
- 9200:9200
steps:
- uses: actions/checkout@v4
- name: Set browsertest output folder
run: |
echo "BROWSERTEST_OUTPUT_DIRECTORY=$GITHUB_WORKSPACE/public/sites/simpletest" >> $GITHUB_ENV
- name: Build project
run: composer install --no-interaction
- name: Scan security updates
run: composer audit --abandoned=ignore
- name: Check that subtheme is not built with dev mode
run: if grep -q 'sourceMappingURL=' -R public/themes/custom/hdbt_subtheme/dist/css; then exit 1; fi
- name: Run PHPCS
run: |
vendor/bin/phpcs public/modules/custom/ --ignore="*.js,*.css" --extensions=php,module,install --standard=Drupal,DrupalPractice
vendor/bin/phpcs public/themes/custom/ --ignore="*.js,*.css" --extensions=php,theme --standard=Drupal,DrupalPractice
- name: Run phpstan
run: vendor/bin/phpstan analyse phpstan.neon
- name: Download latest dump
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh run download -n latest.sql
- name: Install Drupal
run: |
mysql --user=drupal --password=drupal --database=drupal --host=db --port=3306 -A < latest.sql
# The DB dump can occasionally contain an invalid view config row with
# an empty ID (config name "views.view." or other malformed variants).
# That breaks Drupal core's
# block_content post-update which iterates all views and expects every
# view entity to have a non-empty ID.
mysql --user=drupal --password=drupal --database=drupal --host=db --port=3306 -A -e "DELETE FROM config WHERE name = 'views.view.';"
drush php:eval '$storage = \Drupal::service("config.storage"); foreach ($storage->listAll("views.view.") as $name) { $data = $storage->read($name); if (empty($data["id"])) { $storage->delete($name); } }'
# deploy runs updatedb before cim; overlay sync first so DB matches
# conf/cmi (e.g. views without deprecated plugins) before post-updates.
drush cim -y --partial
drush deploy
- name: Start services
run: |
drush runserver $SIMPLETEST_BASE_URL --dns > /dev/null 2>&1 &
# Wait for drush server to start.
for i in {1..5}; do RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$SIMPLETEST_BASE_URL" || true); if [ "$RESPONSE_CODE" -gt "301" ] || [ "$RESPONSE_CODE" -lt "200" ]; then sleep 2; fi; done
- name: Run PHPUnit tests
run: |
composer test-php public/modules/custom
if [ -d "tests/" ]; then composer test-php tests/; else echo "No DTT tests found. Ignoring..."; fi
- name: Create an artifact from test report
uses: actions/upload-artifact@v4
if: always()
with:
name: results
path: ${{ env.BROWSERTEST_OUTPUT_DIRECTORY }}
retention-days: 1