Skip to content

Commit

Permalink
Merge branch 'release/3.x/3.6.0' into 3.x-master
Browse files Browse the repository at this point in the history
  • Loading branch information
Tara committed Dec 10, 2023
2 parents cc8bc42 + b53cc1f commit a1c5caf
Show file tree
Hide file tree
Showing 37 changed files with 223 additions and 6,341 deletions.
6 changes: 5 additions & 1 deletion .ahoy.yml
Expand Up @@ -24,6 +24,10 @@ commands:
usage: Stop Docker containers.
cmd: docker compose stop "$@"

watch:
usage: Use Compose Watch for live development.
cmd: docker compose watch

cli:
usage: Start a shell.
cmd: docker compose exec govcms bash
Expand All @@ -38,7 +42,7 @@ commands:

phpunit:
usage: Run PHPUnit tests.
cmd: docker compose exec govcms phpunit "$@"
cmd: docker compose exec govcms sudo -u root -E sudo -u www-data -E /app/bin/phpunit "$@"

drupal-check:
usage: Static analysis tool to check for correctness and deprecation errors.
Expand Down
126 changes: 93 additions & 33 deletions .circleci/config.yml
@@ -1,15 +1,31 @@
version: 2

jobs:
validate:code:
validate-composer:
docker:
- image: cimg/php:8.1
steps:
- checkout
- run:
name: Validate distribution composer.json
command: |
composer validate --no-check-all
drupal-practices:
docker:
- image: cimg/php:8.1
steps:
- checkout
- run:
name: Checkout tests
command: |
composer create-project govcms/tests:3.x-dev tests
- run:
name: Check Drupal best practices
command: |
cd tests && composer install
./vendor/bin/phpcs --standard=phpcs.govcms.xml -p || true
cd tests
./vendor/bin/phpcs --standard=phpcs.govcms.xml || true
build:
docker:
- image: cimg/php:8.1
Expand All @@ -22,9 +38,17 @@ jobs:
- run:
name: Install GovCMS distribution
command: |
composer update --profile --prefer-dist --optimize-autoloader
composer show -i
test:basic:
composer update --profile --prefer-dist --optimize-autoloader --no-scripts
- run:
name: List all packages within the GovCMS distribution
command: |
composer show -i -D
- run:
name: List outdated packages within the GovCMS distribution
command: |
composer outdated -D
test-basic:
docker:
- image: govcmstesting/php:8.1-apache
- image: cimg/mariadb:10.11
Expand All @@ -40,13 +64,13 @@ jobs:
command: |
composer update --profile --prefer-dist --optimize-autoloader
- run:
name: Get PHP and drush version status
name: Get PHP and Drush version status
command: |
php -v
composer --version
bin/drush version
- run:
name: Wait for MariaDb to be ready
name: Wait for MariaDB to be ready
command: dockerize -wait tcp://127.0.0.1:3306 -timeout 1m
- run:
name: Install GovCMS site
Expand All @@ -59,7 +83,43 @@ jobs:
cd web
../bin/drush status
../bin/drush pm:list --no-core
test:cypress:
test-phpunit:
docker:
- image: govcmstesting/php:8.1-apache
environment:
SIMPLETEST_BASE_URL: "http://local.govcms.gov.au"
SIMPLETEST_DB: "sqlite://localhost/sites/default/files/.ht.sqlite"
working_directory: /app
steps:
- checkout
- run:
name: Install GovCMS dependencies
command: |
composer update --profile --prefer-dist --optimize-autoloader
composer config --no-plugins allow-plugins.phpstan/extension-installer 1
composer require --dev drupal/core-dev:"^10.1"
chown -R www-data:www-data web/sites
rm -rf tests
- run:
name: Setup webserver
command: |
rm -rf /var/www/html
ln -sf /app/web /var/www/html
cp .circleci/httpd.conf.circle /etc/apache2/sites-available/default.conf
a2ensite default
echo "127.0.0.1 local.govcms.gov.au" | tee --append /etc/hosts
service apache2 restart
- run:
name: Checkout tests
command: |
composer create-project govcms/tests:3.x-dev tests
- run:
name: Execute the PHPUnit test for the govcms_security module
command: |
sudo -u root -E sudo -u www-data -E ./bin/phpunit -c web/core web/profiles/govcms/modules/custom/core/govcms_security || true
test-cypress:
docker:
- image: govcmstesting/php:8.1-apache
- image: cimg/mariadb:10.11
Expand All @@ -70,63 +130,63 @@ jobs:
working_directory: /app
steps:
- checkout
- run:
name: Install GovCMS dependencies
command: |
composer update --profile --prefer-dist --optimize-autoloader
chown -R www-data:www-data web/sites
rm -rf tests
- run:
name: Setup webserver
command: |
rm -rf /var/www/html
ln -sf /app/web /var/www/html
cp /app/.circleci/httpd.conf.circle /etc/apache2/sites-available/default.conf
a2ensite default
echo "127.0.0.1 local.govcms.gov.au" | tee --append /etc/hosts
service apache2 restart
- run:
name: Wait for MariaDb to be ready
name: Wait for MariaDB to be ready
command: dockerize -wait tcp://127.0.0.1:3306 -timeout 1m
- run:
name: Checkout tests
command: |
composer create-project govcms/tests:3.x-dev tests
- run:
name: Install GovCMS site
command: |
composer update --profile --prefer-dist --optimize-autoloader
cd web
../bin/drush site-install -y govcms --db-url=mysql://root:govcms@127.0.0.1:3306/govcms --site-name='GovCMS' --account-pass=password install_configure_form.enable_update_status_emails=NULL install_configure_form.enable_update_status_module=NULL || true
./bin/drush site-install -y govcms --db-url=mysql://root:govcms@127.0.0.1:3306/govcms --site-name='GovCMS' --account-pass=password install_configure_form.enable_update_status_emails=NULL install_configure_form.enable_update_status_module=NULL || true
- run:
name: Install Cypress Dependencies
command: |
cp /app/.circleci/cypress.env.json /app/tests/cy/cypress.env.json
cd tests/cy
yarn
- run:
name: Run Cypress tests
command: |
cd tests/cy
cp /app/.circleci/cypress.env.json /app/tests/cy/cypress.env.json
yarn cypress:run
- store_artifacts:
path: tests/cy/cypress/videos
- store_artifacts:
path: tests/cy/cypress/screenshots

workflows:
version: 2
main:
jobs:
- validate:code
- validate-composer
- drupal-practices
- build:
requires:
- validate:code
filters:
tags:
only: /.*/
branches:
only: /.*/
- test:basic:
- validate-composer
- test-basic:
requires:
- build
- test-phpunit:
requires:
- build
filters:
tags:
only: /.*/
branches:
only: /.*/
- test:cypress:
- test-cypress:
requires:
- build
filters:
tags:
only: /.*/
branches:
only: /.*/
64 changes: 44 additions & 20 deletions .docker/Dockerfile.govcms
@@ -1,41 +1,65 @@
FROM drupal:10-php8.1
# Stage 1: Build the application
FROM drupal:10-php8.1 as builder

# Set timezone to Australia/Sydney by default
RUN ln -sf /usr/share/zoneinfo/Australia/Sydney /etc/localtime

RUN apt-get update && \
apt-get install -q -y libicu-dev sqlite3 mariadb-client git unzip rsync nano && \
apt-get autoclean && \
apt-get autoremove && \
# Install required packages and PHP extensions
RUN \
--mount=type=cache,target=/var/cache/apt \
apt-get update && \
apt-get install -y --no-install-recommends libicu-dev sqlite3 mariadb-client git unzip rsync sudo && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
docker-php-ext-configure intl && \
docker-php-ext-install intl

# Configure PHP settings
RUN echo "memory_limit = 512M" >> /usr/local/etc/php/conf.d/docker-php-ram-limit.ini && \
echo "upload_max_filesize = 100M" >> /usr/local/etc/php/conf.d/docker-php-upload-limit.ini && \
echo "post_max_size = 100M" >> /usr/local/etc/php/conf.d/docker-php-upload-limit.ini

# Set Composer environment variables
ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_MEMORY_LIMIT=-1
ENV SIMPLETEST_BASE_URL="http://localhost"
ENV SIMPLETEST_DB='mysql://drupal:drupal@mariadb/drupal'

# Set working directory
WORKDIR /app

# Copy only the necessary files for dependency installation
COPY composer.json ./

# Install Composer dependencies
RUN \
--mount=type=cache,mode=0777,target=/root/.composer/cache \
composer config --no-plugins allow-plugins.phpstan/extension-installer 1 && \
composer require palantirnet/drupal-rector drupal/core-dev:"^10.0" mglaman/drupal-check --dev --no-update && \
composer update --no-scripts --no-autoloader && \
cp vendor/palantirnet/drupal-rector/rector.php .

# Create a symbolic link
RUN rm -rf /opt/drupal && \
ln -sf /app/web /var/www/html

# Stage 2: Final application image
FROM builder as site

# Set the working directory
WORKDIR /app

# Copy the rest of the application files
COPY . /app/

# RUN --mount=type=secret,id=github_token,dst=/app/auth.json set -eux; \
RUN set -eux; \
composer update; \
composer config --no-plugins allow-plugins.phpstan/extension-installer 1;\
composer require palantirnet/drupal-rector \
drupal/core-dev:"^10.0" \
mglaman/drupal-check --dev; \
cp vendor/palantirnet/drupal-rector/rector.php .;

RUN set -eux; \
chown -R www-data:www-data web/sites web/modules web/themes; \
rm -rf /opt/drupal; \
ln -sf /app/web /var/www/html;

ENV PATH=${PATH}:/app/bin
# Configure Composer
RUN \
--mount=type=cache,mode=0777,target=/root/.composer/cache \
composer config --no-plugins allow-plugins.phpstan/extension-installer 1 && \
composer install

# Adjust ownership
RUN chown -R www-data:www-data web/sites web/modules web/themes

# Set the PATH environment variable
ENV PATH=${PATH}:/app/bin
5 changes: 0 additions & 5 deletions .docker/auth.json.example

This file was deleted.

12 changes: 2 additions & 10 deletions DEVELOPMENT.md
Expand Up @@ -58,22 +58,14 @@ Follow the below steps to set up your local development environment for GovCMS:
cd govcms
```

3. Copy the auth.json.example file to auth.json (for Composer and GitHub API rate limit ):

```console
cd .docker
cp auth.json.example auth.json
vi auth.json
```

4. Start the Docker containers by running the following command:
3. Start the Docker containers by running the following command:

```console
cd govcms
docker compose up -d
```

5. The website should now be running at http://localhost:8888. You can access the website by opening this URL in your
4. The website should now be running at http://localhost:8888. You can access the website by opening this URL in your
browser.

## Running Tests
Expand Down

0 comments on commit a1c5caf

Please sign in to comment.