diff --git a/.env b/.env index e223e13c..c377b319 100644 --- a/.env +++ b/.env @@ -9,20 +9,16 @@ PROJECT_NAME=strategia # OpenShift project name OC_PROJECT_NAME=hki-kanslia-strategia-talous-test -STAGE_FILE_PROXY_ORIGIN="https://helfikaupunkijahallinto.blob.core.windows.net" +STAGE_FILE_PROXY_ORIGIN= STAGE_FILE_PROXY_ORIGIN_DIR= # Local hostname DRUPAL_HOSTNAME=strategia.docker.so # Docker image -DRUPAL_IMAGE=ghcr.io/city-of-helsinki/drupal-web:8.1 +DRUPAL_IMAGE=ghcr.io/city-of-helsinki/drupal-web:8.2 -# Default source @alias where to sync database and files from -DRUPAL_SYNC_SOURCE=main +COMPOSE_PROFILES=queue # Public webroot DRUPAL_WEBROOT=public - -# Don't sync files -DRUPAL_SYNC_FILES=no diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 975c3a4e..31a819c6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,11 +5,13 @@ on: 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.2-alpine + options: --hostname app services: db: @@ -31,7 +33,7 @@ jobs: run: composer install --no-interaction - name: Scan security updates - run: drush pm:security + run: 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 @@ -53,11 +55,7 @@ jobs: - name: Start services run: | - drush runserver $SIMPLETEST_BASE_URL > /dev/null 2>&1 & - chromedriver --port=4444 > /dev/null 2>&1 & - # Chromium browser is required to run 'functional-javascript' and - # 'existing-site-javascript' tests. - chromium-browser --headless --disable-gpu --no-sandbox --remote-debugging-port=9222 & + 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 @@ -65,4 +63,5 @@ jobs: - name: Run PHPUnit tests run: | composer test-php public/modules/custom - [ -d "tests/" ] && composer test-php tests/ || echo "No DTT tests found. Ignoring..." + if [ -d "tests/" ]; then composer test-php tests/; else echo "No DTT tests found. Ignoring..."; fi + diff --git a/.github/workflows/test.yml.dist b/.github/workflows/test.yml.dist deleted file mode 100644 index 202ddc9c..00000000 --- a/.github/workflows/test.yml.dist +++ /dev/null @@ -1,37 +0,0 @@ -on: [push] -name: CI -env: - SIMPLETEST_DB: "mysql://drupal:drupal@db:3306/drupal" - SIMPLETEST_BASE_URL: "http://127.0.0.1:8080" - SYMFONY_DEPRECATIONS_HELPER: max[direct]=0 -jobs: - tests: - runs-on: ubuntu-latest - container: - image: ghcr.io/city-of-helsinki/drupal-php-docker:8.0 - - services: - db: - image: druidfi/db:mysql5.7-drupal - ports: - - 3306:3306 - - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 1 - - - name: Build project - run: composer install - - - name: Run PHPCS - run: vendor/bin/phpcs public/modules/custom/ --standard=Drupal - - - name: Install Drupal - run: php -d sendmail_path=$(which true); drush --yes -v site-install --existing-config --db-url="$SIMPLETEST_DB" - - - name: Run PHPUnit tests - run: | - drush runserver $SIMPLETEST_BASE_URL > /dev/null 2>&1 & - chromedriver --port=4444 > /dev/null 2>&1 & - vendor/bin/phpunit -c $GITHUB_WORKSPACE/phpunit.xml.dist --verbose diff --git a/azure-pipelines-master.yml.dist b/azure-pipelines-master.yml.dist deleted file mode 100644 index a91a679b..00000000 --- a/azure-pipelines-master.yml.dist +++ /dev/null @@ -1,36 +0,0 @@ -# File: drupal-helfi/azure-pipelines.yml - -# Continuous integration (CI) triggers cause a pipeline to run whenever you push -# an update to the specified branches or you push specified tags. -trigger: - branches: - include: - - dev - paths: - exclude: - - README.md - -# Pull request (PR) triggers cause a pipeline to run whenever a pull request is -# opened with one of the specified target branches, or when updates are made to -# such a pull request. -# -# GitHub creates a new ref when a pull request is created. The ref points to a -# merge commit, which is the merged code between the source and target branches -# of the pull request. -# -# Opt out of pull request validation -pr: none - -# By default, use self-hosted agents -pool: Default - -resources: - repositories: - # Azure DevOps repository - - repository: drupal-REPLACEME - type: git - # project/repository - name: drupal-helfi/drupal-REPLACEME - -extends: - template: azure-pipelines-drupal-master.yml@drupal-REPLACEME diff --git a/azure-pipelines-pull-request.yml.dist b/azure-pipelines-pull-request.yml.dist deleted file mode 100644 index b77b7f2d..00000000 --- a/azure-pipelines-pull-request.yml.dist +++ /dev/null @@ -1,34 +0,0 @@ -# File: drupal-helfi/azure-pipelines.yml - -# Continuous integration (CI) triggers cause a pipeline to run whenever you push -# an update to the specified branches or you push specified tags. -# -# Opt out of CI triggers -trigger: none - -# Pull request (PR) triggers cause a pipeline to run whenever a pull request is -# opened with one of the specified target branches, or when updates are made to -# such a pull request. -# -# GitHub creates a new ref when a pull request is created. The ref points to a -# merge commit, which is the merged code between the source and target branches -# of the pull request. -pr: - branches: - include: - - main - - dev - -# By default, use self-hosted agents -pool: Default - -resources: - repositories: - # Azure DevOps repository - - repository: drupal-REPLACEME - type: git - # project/repository - name: drupal-helfi/drupal-REPLACEME - -extends: - template: azure-pipelines-drupal-pull-request.yml@drupal-REPLACEME diff --git a/azure-pipelines-release.yml b/azure-pipelines-release.yml deleted file mode 100644 index 36fab5fb..00000000 --- a/azure-pipelines-release.yml +++ /dev/null @@ -1,36 +0,0 @@ -# File: drupal-helfi/azure-pipelines.yml - -# Continuous integration (CI) triggers cause a pipeline to run whenever you push -# an update to the specified branches or you push specified tags. -trigger: - branches: - include: - - main - paths: - exclude: - - README.md - -# Pull request (PR) triggers cause a pipeline to run whenever a pull request is -# opened with one of the specified target branches, or when updates are made to -# such a pull request. -# -# GitHub creates a new ref when a pull request is created. The ref points to a -# merge commit, which is the merged code between the source and target branches -# of the pull request. -# -# Opt out of pull request validation -pr: none - -# By default, use self-hosted agents -pool: Default - -resources: - repositories: - # Azure DevOps repository - - repository: strategia-talous-pipelines - type: git - # project/repository - name: strategia-talous/strategia-talous-pipelines - -extends: - template: azure-pipelines-drupal-release.yml@strategia-talous-pipelines diff --git a/azure-pipelines-release.yml.dist b/azure-pipelines-release.yml.dist deleted file mode 100644 index f99d4d37..00000000 --- a/azure-pipelines-release.yml.dist +++ /dev/null @@ -1,37 +0,0 @@ -# File: drupal-helfi/azure-pipelines.yml - -# Continuous integration (CI) triggers cause a pipeline to run whenever you push -# an update to the specified branches or you push specified tags. -trigger: - branches: - include: - - release/* - - refs/tags/* - paths: - exclude: - - README.md - -# Pull request (PR) triggers cause a pipeline to run whenever a pull request is -# opened with one of the specified target branches, or when updates are made to -# such a pull request. -# -# GitHub creates a new ref when a pull request is created. The ref points to a -# merge commit, which is the merged code between the source and target branches -# of the pull request. -# -# Opt out of pull request validation -pr: none - -# By default, use self-hosted agents -pool: Default - -resources: - repositories: - # Azure DevOps repository - - repository: drupal-REPLACEME - type: git - # project/repository - name: drupal-helfi/drupal-REPLACEME - -extends: - template: azure-pipelines-drupal-release.yml@drupal-REPLACEME diff --git a/composer.json b/composer.json index 591855bd..83b6127e 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,8 @@ "drupal/coder": "^8.3", "drupal/core-dev": "^9.1", "phpspec/prophecy-phpunit": "^2", - "phpunit/phpunit": "^9.6" + "phpunit/phpunit": "^9.6", + "weitzman/drupal-test-traits": "^2.1" }, "conflict": { "drupal/drupal": "*" @@ -44,6 +45,9 @@ "cweagans/composer-patches": true, "drupal/core-composer-scaffold": true, "php-http/discovery": false + }, + "audit": { + "abandoned": "report" } }, "extra": { diff --git a/composer.lock b/composer.lock index 89846a71..82470477 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ab440ced4d10a2ae5b572a58dc17c1dc", + "content-hash": "e82aed68b0fec0f307b7fcca1321cecd", "packages": [ { "name": "asm89/stack-cors", @@ -14332,16 +14332,16 @@ }, { "name": "composer/composer", - "version": "2.2.21", + "version": "2.2.22", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "978198befc71de0b18fc1fc5a472c03b184b504a" + "reference": "fedc76ee3f3e3d57d20993b9f4c5fcfb2f8596aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/978198befc71de0b18fc1fc5a472c03b184b504a", - "reference": "978198befc71de0b18fc1fc5a472c03b184b504a", + "url": "https://api.github.com/repos/composer/composer/zipball/fedc76ee3f3e3d57d20993b9f4c5fcfb2f8596aa", + "reference": "fedc76ee3f3e3d57d20993b9f4c5fcfb2f8596aa", "shasum": "" }, "require": { @@ -14411,7 +14411,7 @@ "support": { "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/composer/issues", - "source": "https://github.com/composer/composer/tree/2.2.21" + "source": "https://github.com/composer/composer/tree/2.2.22" }, "funding": [ { @@ -14427,7 +14427,7 @@ "type": "tidelift" } ], - "time": "2023-02-15T12:07:40+00:00" + "time": "2023-09-29T08:53:46+00:00" }, { "name": "composer/metadata-minifier", @@ -17886,6 +17886,59 @@ } ], "time": "2021-07-28T10:34:58+00:00" + }, + { + "name": "weitzman/drupal-test-traits", + "version": "2.1.0", + "source": { + "type": "git", + "url": "git@gitlab.com:weitzman/drupal-test-traits.git", + "reference": "e40ee4e8e41f229d297c5e714fd63c4a00c633a2" + }, + "dist": { + "type": "zip", + "url": "https://gitlab.com/api/v4/projects/weitzman%2Fdrupal-test-traits/repository/archive.zip?sha=e40ee4e8e41f229d297c5e714fd63c4a00c633a2", + "reference": "e40ee4e8e41f229d297c5e714fd63c4a00c633a2", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "installer-paths": { + "web/core": [ + "type:drupal-core" + ] + }, + "drupal-scaffold": { + "locations": { + "web-root": "web/" + }, + "file-mapping": { + "[project-root]/.editorconfig": false, + "[project-root]/.gitattributes": false, + "[project-root]/.gitignore": false + } + } + }, + "autoload": { + "psr-4": { + "weitzman\\DrupalTestTraits\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Moshe Weitzman", + "email": "weitzman@tejasa.com" + } + ], + "description": "Traits for testing Drupal sites that have user content (versus unpopulated sites).", + "time": "2023-04-23T03:17:53+00:00" } ], "aliases": [], @@ -17897,5 +17950,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/tools/make/project/robo.mk b/tools/make/project/robo.mk deleted file mode 100644 index 8780af09..00000000 --- a/tools/make/project/robo.mk +++ /dev/null @@ -1,86 +0,0 @@ -STONEHENGE_PATH ?= ${HOME}/stonehenge -PROJECT_DIR ?= ${GITHUB_WORKSPACE} -SITE_PREFIX ?= / - -SETUP_ROBO_TARGETS := -CI_POST_INSTALL_TARGETS := - -ifeq ($(CI),true) - SETUP_ROBO_TARGETS += install-stonehenge start-stonehenge set-permissions - CI_POST_INSTALL_TARGETS += fix-files-permission -endif - -SETUP_ROBO_TARGETS += up composer-install $(CI_POST_INSTALL_TARGETS) update-automation - -ifeq ($(DRUPAL_BUILD_FROM_SCRATCH),true) - SETUP_ROBO_TARGETS += install-drupal post-install-tasks -else - SETUP_ROBO_TARGETS += install-drupal-from-dump post-install-tasks -endif - -install-stonehenge: $(STONEHENGE_PATH)/.git - -$(STONEHENGE_PATH)/.git: - git clone -b 3.x https://github.com/druidfi/stonehenge.git $(STONEHENGE_PATH) - -PHONY += start-stonehenge -start-stonehenge: - cd $(STONEHENGE_PATH) && COMPOSE_FILE=docker-compose.yml make up - -$(PROJECT_DIR)/helfi-test-automation-python/.git: - git clone https://github.com/City-of-Helsinki/helfi-test-automation-python.git $(PROJECT_DIR)/helfi-test-automation-python - -PHONY += update-automation -update-automation: $(PROJECT_DIR)/helfi-test-automation-python/.git - git pull - -PHONY += install-drupal -install-drupal: - $(call docker_run_ci,app,drush si minimal -y) - $(call docker_run_ci,app,drush cr) - $(call docker_run_ci,app,drush si minimal --existing-config -y) - $(call docker_run_ci,app,drush deploy) - -PHONY += install-drupal-from-dump -install-drupal-from-dump: - $(call docker_run_ci,app,drush sql-drop -y) - $(call docker_run_ci,app,mysql --user=drupal --password=drupal --database=drupal --host=db --port=3306 -A < latest.sql) - $(call docker_run_ci,app,drush deploy) - -PHONY += post-install-tasks -post-install-tasks: - $(call docker_run_ci,app,drush upwd helfi-admin Test_Automation) - $(call docker_run_ci,app,drush en helfi_example_content syslog -y) - $(call docker_run_ci,app,drush helfi:migrate-fixture tpr_unit --publish) - $(call docker_run_ci,app,drush helfi:migrate-fixture tpr_service --publish) - $(call docker_run_ci,app,drush helfi:migrate-fixture tpr_errand_service --publish) - $(call docker_run_ci,app,drush helfi:migrate-fixture tpr_service_channel --publish) - $(call docker_run_ci,app,drush pmu editoria11y -y) - -PHONY += save-dump -save-dump: - $(call docker_run_ci,app,drush sql-dump --result-file=/app/latest.sql) - -PHONY += robo-shell -robo-shell: - @docker compose $(DOCKER_COMPOSE_FILES) exec robo sh - -PHONY += set-permissions -set-permissions: - chmod 777 /home/runner/.cache/composer -R - chmod 777 -R $(PROJECT_DIR) - -PHONY += fix-files-permission -fix-files-permission: - mkdir $(PROJECT_DIR)public/sites/default/files -p && chmod 777 -R $(PROJECT_DIR)public/sites/default/files - -define docker_run_ci - docker compose exec -T $(1) sh -c "$(2)" -endef - -PHONY += setup-robo -setup-robo: $(SETUP_ROBO_TARGETS) - -PHONY += run-robo-tests -run-robo-tests: - $(call docker_run_ci,robo,cd /app/helfi-test-automation-python && chmod +x run_all_tests.sh && PREFIX=$(SITE_PREFIX) BASE_URL=$(DRUPAL_HOSTNAME) ./run_all_tests.sh)