Add a functional test to confirm build integrity #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test and confirm functional build | |
on: | |
workflow_dispatch: | |
push: | |
jobs: | |
setup_lamp_environment: | |
runs-on: ubuntu-latest | |
env: | |
path_to_site_codebase_on_runner: ${{ github.workspace }} # Base path where repo is cloned | |
services: | |
mysql: | |
image: mysql:5.7 | |
env: | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_DATABASE: drupal | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Set up PHP 8.2 | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: "8.2" | |
extensions: mbstring, curl, zip | |
coverage: none | |
- name: Setup Apache | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y software-properties-common | |
sudo add-apt-repository ppa:ondrej/php | |
sudo apt-get update | |
sudo apt-get install -y apache2 libapache2-mod-php8.2 php8.2-mysql | |
sudo sed -i 's#/var/www/html#${{ env.path_to_site_codebase_on_runner }}/web#g' /etc/apache2/sites-available/000-default.conf | |
sudo sed -i 's#/var/www/html#${{ env.path_to_site_codebase_on_runner }}/web#g' /etc/apache2/sites-available/default-ssl.conf | |
sudo systemctl restart apache2 | |
- name: Create settings.local.php | |
run: | | |
cat <<EOF > ${{ env.path_to_site_codebase_on_runner }}/web/sites/default/settings.local.php | |
<?php | |
\$databases['default']['default'] = array( | |
'driver' => 'mysql', | |
'database' => 'drupal', | |
'username' => 'root', | |
'password' => 'root', | |
'host' => '127.0.0.1', | |
'port' => '3306', | |
'prefix' => '', | |
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', | |
'driver' => 'mysql', | |
); | |
EOF | |
chmod 755 ${{ env.path_to_site_codebase_on_runner }}/web/sites/default/settings.local.php | |
- name: Install Composer Dependencies | |
run: | | |
cd ${{ env.path_to_site_codebase_on_runner }} | |
composer install --no-progress --no-interaction | |
- name: Initialize Drupal Installation | |
run: | | |
cd ${{ env.path_to_site_codebase_on_runner }} | |
./vendor/bin/drush si -y | |
./vendor/bin/drush en aqto_defaults -y | |
./vendor/bin/drush cr | |
./vendor/bin/drush uli | |
sudo chown -R www-data:www-data ${{ env.path_to_site_codebase_on_runner }}/web | |
# TODO: Since this should now be a functional environment, we could trigger some Playwright tests next. | |
- name: Start Apache Service | |
run: sudo systemctl start apache2 |