-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (142 loc) · 5.17 KB
/
main.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
name: Main CI/CD Pipeline
on:
push:
branches:
- master
pull_request:
branches:
- master
# schedule:
# - cron: '0 6 * * *' # Nightly at 6 AM
workflow_dispatch:
jobs:
# Uncomment for SonarQube analysis
# sonarscan:
# runs-on: ubuntu-latest
# container:
# image: sonarsource/sonar-scanner-cli:latest
# env:
# SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
# SONAR_LOGIN: ${{ secrets.SONAR_LOGIN}}
# steps:
# - uses: actions/checkout@v4
# - name: Run SonarQube scan
# run: sonar-scanner -Dsonar.projectKey=LANDOSTAND_DRUPAL
analyze:
runs-on: ubuntu-latest
container:
image: mobomo/drupalstand-ci:8.3-ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
composer install --no-interaction --no-progress
# npm install --prefix webroot/themes/contrib/uswds_base
- name: Full Analysis
run: |
./vendor/bin/phpstan analyze --no-progress --memory-limit 1G -c phpstan.neon
lint:
runs-on: ubuntu-latest
container:
image: mobomo/drupalstand-ci:8.3-ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
composer install --no-interaction --no-progress
# npm install --prefix webroot/themes/contrib/uswds_base
- name: Install Linters and Sniffers
run: |
composer global config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer global require --dev drupal/coder php-parallel-lint/php-parallel-lint --no-interaction
- name: PHP Lint
run: |
# avoid "no file found to check" error
touch ./webroot/modules/custom/index.php ./webroot/themes/custom/index.php
./vendor/bin/parallel-lint -e php,module,inc,install,test,profile,theme ./webroot/modules/custom ./webroot/themes/custom
- name: PHP CodeSniff (ignore warnings)
run: |
./vendor/bin/phpcs -ns --standard=./phpcs.xml
- name: Theme Lint
run: |
# cd webroot/themes/contrib/uswds_base && npx gulp lintCi
unit_test:
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:10.6.19
env:
MYSQL_DATABASE: drupal10
MYSQL_USER: drupal10
MYSQL_PASSWORD: drupal10
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
container:
image: mobomo/drupalstand-ci:8.3-ubuntu-latest
env:
DRUPAL_DB_USER: drupal10
DRUPAL_DB_NAME: drupal10
DRUPAL_DB_PASS: drupal10
DRUPAL_DB_HOST: mariadb
DRUPAL_DB_PORT: 3306
DRUPAL_CONFIG_DIR: /app/config
ENVIRONMENT: ci
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
composer install --no-interaction --no-progress
# npm install --prefix webroot/themes/contrib/uswds_base
- name: Wait for MySQL Ready
shell: bash
run: |
failcounter=0
timeout_in_sec=120
until mysql -h $DRUPAL_DB_HOST -u $DRUPAL_DB_NAME -p$DRUPAL_DB_PASS -D $DRUPAL_DB_NAME --silent -e "show databases;"
do
let "failcounter += 1"
echo "Waiting for database connection... ($failcounter/$timeout_in_sec)"
if [[ $failcounter -gt timeout_in_sec ]]; then
echo "Timeout ($timeout_in_sec seconds) reached; failed to connect to database"
exit 1
fi
sleep 2
done
- name: Initialize Drupal + Verify Config can import
run: |
# For some reason drush locks to "127.0.0.1" if this is set.
unset CI
echo "memory_limit = 768M" >> /etc/php/8.3/cli/conf.d/my-php.ini
./vendor/bin/drush site:install minimal --yes --account-name=admin --account-pass=admin --db-url="mysql://$DRUPAL_DB_USER:$DRUPAL_DB_PASS@$DRUPAL_DB_HOST:$DRUPAL_DB_PORT/$DRUPAL_DB_NAME" -vvv install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=NULL
if [ -f "./config/default/system.site.yml" ]; then
cat ./config/default/system.site.yml | grep uuid | tail -c +7 | head -c 36 | ./vendor/bin/drush config-set -y system.site uuid -
./vendor/bin/drush config:import --yes || true
./vendor/bin/drush config:import --yes || true
./vendor/bin/drush config:import --yes
fi
- name: Unit Test
run: php ./vendor/bin/phpunit -c ./phpunit.xml
functional_test:
runs-on: ubuntu-latest
container:
image: cypress/included:latest
steps:
- uses: actions/checkout@v4
- name: Testing
run: cd tests && cypress run
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results
path: tests/test-results
- name: Upload videos
uses: actions/upload-artifact@v4
with:
name: videos
path: tests/cypress/videos
- name: Upload screenshots
uses: actions/upload-artifact@v4
with:
name: screenshots
path: tests/cypress/screenshots