diff --git a/.env b/.env index 149d63c81..38e5c0873 100644 --- a/.env +++ b/.env @@ -9,7 +9,7 @@ COMPOSE_PROJECT_NAME=hel-fi-drupal-grant-applications DRUPAL_HOSTNAME=hel-fi-drupal-grant-applications.docker.so # Docker image -DRUPAL_IMAGE=ghcr.io/city-of-helsinki/drupal-web:8.2 +DRUPAL_IMAGE=ghcr.io/city-of-helsinki/drupal-web:8.3 # Default source @alias where to sync database and files from DRUPAL_SYNC_SOURCE=main diff --git a/.github/workflows/artifact.yml b/.github/workflows/artifact.yml index 535dc82bb..969bfa81d 100644 --- a/.github/workflows/artifact.yml +++ b/.github/workflows/artifact.yml @@ -8,32 +8,32 @@ name: Build artifacts jobs: build: runs-on: ubuntu-latest - container: - image: ghcr.io/city-of-helsinki/drupal-php-docker:8.3-alpine - - services: - db: - image: mysql:8 - env: - MYSQL_USER: drupal - MYSQL_PASSWORD: drupal - MYSQL_DATABASE: drupal - MYSQL_ROOT_PASSWORD: drupal - ports: - - 3306:3306 - steps: - uses: actions/checkout@v4 + - name: Install and start Stonehenge + run: | + git clone -b 5.x https://github.com/druidfi/stonehenge.git ~/stonehenge + cd ~/stonehenge && make up + + # This must be done after we start Stonehenge. + - name: Setup Docker compose environment variables + run: | + echo "COMPOSE_FILE=compose.yaml:compose.ci.yaml" >> $GITHUB_ENV + + - name: Start project + run: make up + - name: Build project - run: composer install --no-interaction + run: docker compose exec app bash -c "composer install --no-interaction" - name: Setup drupal and save database dump run: | - drush si -y && drush cr - drush si --existing-config -y - drush cim -y - drush sql-dump --result-file=${GITHUB_WORKSPACE}/latest.sql + docker compose exec app bash -c "drush si -y && drush cr" + docker compose exec app bash -c "drush si --existing-config -y" + docker compose exec app bash -c "drush cr" + docker compose exec app bash -c "drush cim -y" + docker compose exec app bash -c "drush sql-dump --result-file=/app/latest.sql" - name: Upload latest database dump uses: actions/upload-artifact@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a367baad5..27855f1ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,33 +3,12 @@ on: push: branches: ['main', 'dev'] name: CI -env: - SYMFONY_DEPRECATIONS_HELPER: disabled - SIMPLETEST_BASE_URL: http://app:8888 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 steps: - uses: actions/checkout@v4 - - name: Set browsertest output folder - run: | - echo "BROWSERTEST_OUTPUT_DIRECTORY=$GITHUB_WORKSPACE/public/sites/simpletest" >> $GITHUB_ENV - # TODO this does not pass #- name: Make sure configuration was exported in correct language (en or und) # run: | @@ -41,22 +20,36 @@ jobs: # exit 1 # fi + - name: Install and start Stonehenge + run: | + git clone -b 5.x https://github.com/druidfi/stonehenge.git ~/stonehenge + cd ~/stonehenge && make up + + # This must be done after we start Stonehenge. + - name: Setup Docker compose environment variables + run: | + echo "COMPOSE_FILE=compose.yaml:compose.ci.yaml" >> $GITHUB_ENV + echo "COMPOSE_PROFILES=" >> $GITHUB_ENV + + - name: Start project + run: make up + - name: Build project - run: composer install --no-interaction + run: docker compose exec app bash -c "composer install --no-interaction" - name: Scan security updates - run: composer audit + run: docker compose exec app bash -c "composer audit" - 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 + run: docker compose exec app bash -c "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/ - vendor/bin/phpcs public/themes/custom/ + docker compose exec app bash -c "vendor/bin/phpcs public/modules/custom/" + docker compose exec app bash -c "vendor/bin/phpcs public/themes/custom/" - name: Run phpstan - run: vendor/bin/phpstan analyze + run: docker compose exec app bash -c "vendor/bin/phpstan analyze" - name: Download latest dump env: @@ -65,25 +58,26 @@ jobs: - name: Install Drupal run: | - mysql --user=drupal --password=drupal --database=drupal --host=db --port=3306 -A < latest.sql - drush deploy + docker compose exec app bash -c "mysql --user=drupal --password=drupal --database=drupal --host=db --port=3306 -A < latest.sql" + docker compose exec app bash -c "drush deploy" - - name: Start services + - name: Run PHPUnit tests run: | - drush runserver $SIMPLETEST_BASE_URL --dns > /dev/null 2>&1 & + docker compose exec app bash -c "mkdir -p /app/results" - # 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 + if [ -d "tests/" ]; then + docker compose exec app bash -c "composer test-php tests/" + fi + docker compose exec app bash -c "composer test-php public/modules/custom" - - 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: Export logs + if: always() + run: docker compose logs app > results/service.log - name: Create an artifact from test report uses: actions/upload-artifact@v4 if: always() with: name: results - path: ${{ env.BROWSERTEST_OUTPUT_DIRECTORY }} + path: results/ retention-days: 1 diff --git a/.github/workflows/update-config.yml b/.github/workflows/update-config.yml index d36258dd6..64af85621 100644 --- a/.github/workflows/update-config.yml +++ b/.github/workflows/update-config.yml @@ -9,7 +9,8 @@ jobs: update-config: runs-on: ubuntu-latest container: - image: ghcr.io/city-of-helsinki/drupal-php-docker:8.3-alpine + image: ghcr.io/city-of-helsinki/drupal-web:8.3 + options: --hostname app --user 1001 services: db: image: mysql:8 diff --git a/composer.lock b/composer.lock index 36981956e..6d9d05f96 100644 --- a/composer.lock +++ b/composer.lock @@ -815,16 +815,16 @@ }, { "name": "consolidation/annotated-command", - "version": "4.10.0", + "version": "4.10.1", "source": { "type": "git", "url": "https://github.com/consolidation/annotated-command.git", - "reference": "1e830ba908c9ffb1ba7ca056203531b27188812c" + "reference": "362310b13ececa9f6f0a4a880811fa08fecc348b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/1e830ba908c9ffb1ba7ca056203531b27188812c", - "reference": "1e830ba908c9ffb1ba7ca056203531b27188812c", + "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/362310b13ececa9f6f0a4a880811fa08fecc348b", + "reference": "362310b13ececa9f6f0a4a880811fa08fecc348b", "shasum": "" }, "require": { @@ -865,9 +865,9 @@ "description": "Initialize Symfony Console commands from annotated command class methods.", "support": { "issues": "https://github.com/consolidation/annotated-command/issues", - "source": "https://github.com/consolidation/annotated-command/tree/4.10.0" + "source": "https://github.com/consolidation/annotated-command/tree/4.10.1" }, - "time": "2024-04-05T21:05:39+00:00" + "time": "2024-12-13T19:55:40+00:00" }, { "name": "consolidation/config", @@ -1215,16 +1215,16 @@ }, { "name": "consolidation/site-alias", - "version": "4.1.0", + "version": "4.1.1", "source": { "type": "git", "url": "https://github.com/consolidation/site-alias.git", - "reference": "1056ceb93f6aafe6f7600d7bbe1b62b8488abccf" + "reference": "aff6189aae17da813d23249cb2fc0fff33f26d40" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/site-alias/zipball/1056ceb93f6aafe6f7600d7bbe1b62b8488abccf", - "reference": "1056ceb93f6aafe6f7600d7bbe1b62b8488abccf", + "url": "https://api.github.com/repos/consolidation/site-alias/zipball/aff6189aae17da813d23249cb2fc0fff33f26d40", + "reference": "aff6189aae17da813d23249cb2fc0fff33f26d40", "shasum": "" }, "require": { @@ -1268,22 +1268,22 @@ "description": "Manage alias records for local and remote sites.", "support": { "issues": "https://github.com/consolidation/site-alias/issues", - "source": "https://github.com/consolidation/site-alias/tree/4.1.0" + "source": "https://github.com/consolidation/site-alias/tree/4.1.1" }, - "time": "2024-04-05T15:58:04+00:00" + "time": "2024-12-13T19:05:11+00:00" }, { "name": "consolidation/site-process", - "version": "5.4.0", + "version": "5.4.2", "source": { "type": "git", "url": "https://github.com/consolidation/site-process.git", - "reference": "7ab3ffe4195a89b8dc334ea22e7881abe79ffd9a" + "reference": "e7fafc40ebfddc1a5ee99ee66e5d186fc1bed4da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/site-process/zipball/7ab3ffe4195a89b8dc334ea22e7881abe79ffd9a", - "reference": "7ab3ffe4195a89b8dc334ea22e7881abe79ffd9a", + "url": "https://api.github.com/repos/consolidation/site-process/zipball/e7fafc40ebfddc1a5ee99ee66e5d186fc1bed4da", + "reference": "e7fafc40ebfddc1a5ee99ee66e5d186fc1bed4da", "shasum": "" }, "require": { @@ -1325,9 +1325,9 @@ "description": "A thin wrapper around the Symfony Process Component that allows applications to use the Site Alias library to specify the target for a remote call.", "support": { "issues": "https://github.com/consolidation/site-process/issues", - "source": "https://github.com/consolidation/site-process/tree/5.4.0" + "source": "https://github.com/consolidation/site-process/tree/5.4.2" }, - "time": "2024-04-06T00:00:28+00:00" + "time": "2024-12-13T19:25:56+00:00" }, { "name": "cweagans/composer-patches", @@ -23508,6 +23508,6 @@ "platform": { "ext-json": "*" }, - "platform-dev": {}, + "platform-dev": [], "plugin-api-version": "2.6.0" } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0cb38bb62..b641aa3b2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,12 +15,11 @@ - - + + - - + ./public/modules/custom/*/tests/src/Unit diff --git a/tools/make/project/git.mk b/tools/make/project/git.mk index 50b03e875..c598f4d7b 100644 --- a/tools/make/project/git.mk +++ b/tools/make/project/git.mk @@ -1,3 +1,3 @@ PHONY += copy-commit-message-script copy-commit-message-script: - @$(foreach name,$(shell find public/modules/custom public/themes/custom public/modules/contrib public/themes/contrib -type d -name ".git" -exec dirname {} \; 2> /dev/null ) .,cp tools/commit-msg $(name)/.git/hooks || true;) + @$(foreach name,$(shell find . -type d -name ".git" -exec dirname {} \; 2> /dev/null ),cp tools/commit-msg $(name)/.git/hooks;)