Skip to content

Commit 12b69d9

Browse files
authored
Merge pull request #509 from City-of-Helsinki/dev
Dev to main
2 parents ab83b2d + 830d37a commit 12b69d9

21 files changed

+303
-501
lines changed

.github/workflows/artifact.yml

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,4 @@ on:
77
name: Build artifacts
88
jobs:
99
build:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: actions/checkout@v4
13-
14-
- name: Install and start Stonehenge
15-
run: |
16-
git clone -b 5.x https://github.com/druidfi/stonehenge.git ~/stonehenge
17-
cd ~/stonehenge && make up
18-
19-
# This must be done after we start Stonehenge.
20-
- name: Setup Docker compose environment variables
21-
run: |
22-
echo "COMPOSE_FILE=compose.yaml:compose.ci.yaml" >> $GITHUB_ENV
23-
24-
- name: Start project
25-
run: make up
26-
27-
- name: Build project
28-
run: docker compose exec app bash -c "composer install --no-interaction"
29-
30-
- name: Setup drupal and save database dump
31-
run: |
32-
docker compose exec app bash -c "drush si -y && drush cr"
33-
docker compose exec app bash -c "drush si --existing-config -y"
34-
docker compose exec app bash -c "drush cr"
35-
docker compose exec app bash -c "drush cim -y"
36-
docker compose exec app bash -c "drush sql-dump --result-file=/app/latest.sql"
37-
38-
- name: Upload latest database dump
39-
uses: actions/upload-artifact@v4
40-
with:
41-
name: latest.sql
42-
path: latest.sql
43-
retention-days: 10
10+
uses: city-of-helsinki/drupal-gh-actions/.github/workflows/build-artifact.yml@main

.github/workflows/test.yml

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -5,78 +5,4 @@ on:
55
name: CI
66
jobs:
77
tests:
8-
runs-on: ubuntu-latest
9-
steps:
10-
- uses: actions/checkout@v4
11-
12-
- name: Make sure configuration was exported in correct language (en or und)
13-
run: |
14-
OUTPUT=$(grep -oP '^langcode: \b(?!(?:en|und)\b)\w+' conf -R || true)
15-
16-
if [ ! -z "$OUTPUT" ]; then
17-
echo "Found configuration that does not match the pattern 'langcode: (en|und)':" >> $GITHUB_STEP_SUMMARY
18-
echo "$OUTPUT" >> $GITHUB_STEP_SUMMARY
19-
exit 1
20-
fi
21-
22-
- name: Install and start Stonehenge
23-
run: |
24-
git clone -b 5.x https://github.com/druidfi/stonehenge.git ~/stonehenge
25-
cd ~/stonehenge && make up
26-
27-
# This must be done after we start Stonehenge.
28-
- name: Setup Docker compose environment variables
29-
run: |
30-
echo "COMPOSE_FILE=compose.yaml:compose.ci.yaml" >> $GITHUB_ENV
31-
echo "COMPOSE_PROFILES=" >> $GITHUB_ENV
32-
33-
- name: Start project
34-
run: make up
35-
36-
- name: Build project
37-
run: docker compose exec app bash -c "composer install --no-interaction"
38-
39-
- name: Scan security updates
40-
run: docker compose exec app bash -c "composer audit"
41-
42-
- name: Check that subtheme is not built with dev mode
43-
run: docker compose exec app bash -c "if grep -q 'sourceMappingURL=' -R public/themes/custom/hdbt_subtheme/dist/css; then exit 1; fi"
44-
45-
- name: Run PHPCS
46-
run: |
47-
docker compose exec app bash -c "vendor/bin/phpcs public/modules/custom/"
48-
docker compose exec app bash -c "vendor/bin/phpcs public/themes/custom/"
49-
50-
- name: Run phpstan
51-
run: docker compose exec app bash -c "vendor/bin/phpstan analyze"
52-
53-
- name: Download latest dump
54-
env:
55-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56-
run: gh run download -n latest.sql
57-
58-
- name: Install Drupal
59-
run: |
60-
docker compose exec app bash -c "mysql --user=drupal --password=drupal --database=drupal --host=db --port=3306 -A < latest.sql"
61-
docker compose exec app bash -c "drush deploy"
62-
63-
- name: Run PHPUnit tests
64-
run: |
65-
docker compose exec app bash -c "mkdir -p /app/results"
66-
67-
if [ -d "tests/" ]; then
68-
docker compose exec app bash -c "composer test-php tests/"
69-
fi
70-
docker compose exec app bash -c "composer test-php public/modules/custom"
71-
72-
- name: Export logs
73-
if: always()
74-
run: docker compose logs app > results/service.log
75-
76-
- name: Create an artifact from test report
77-
uses: actions/upload-artifact@v4
78-
if: always()
79-
with:
80-
name: results
81-
path: results/
82-
retention-days: 1
8+
uses: city-of-helsinki/drupal-gh-actions/.github/workflows/project-tests.yml@main

.github/workflows/update-config.yml

Lines changed: 3 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3,106 +3,8 @@ on:
33
repository_dispatch:
44
types: [config_change]
55
name: Update config
6-
env:
7-
GH_TOKEN: ${{ github.token }}
86
jobs:
97
update-config:
10-
runs-on: ubuntu-latest
11-
container:
12-
image: ghcr.io/city-of-helsinki/drupal-web:8.3
13-
options: --hostname app --user 1001
14-
services:
15-
db:
16-
image: mysql:8
17-
env:
18-
MYSQL_USER: drupal
19-
MYSQL_PASSWORD: drupal
20-
MYSQL_DATABASE: drupal
21-
MYSQL_ROOT_PASSWORD: drupal
22-
ports:
23-
- 3306:3306
24-
25-
steps:
26-
- uses: actions/checkout@v4
27-
28-
- name: Check if required secrets are set
29-
env:
30-
AUTOMATIC_UPDATE_TOKEN: ${{ secrets.AUTOMATIC_UPDATE_TOKEN }}
31-
if: env.AUTOMATIC_UPDATE_TOKEN == ''
32-
run: exit 1
33-
34-
- name: Download latest dump
35-
env:
36-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37-
run: |
38-
gh run download -n latest.sql
39-
40-
- name: Prepare setup
41-
run: |
42-
# We install Drupal from existing dump, so locale_install() hook
43-
# is never fired. Make sure the translations folder exists.
44-
mkdir -p public/sites/default/files/translations -p
45-
46-
- name: Build project
47-
run: |
48-
composer install --no-interaction
49-
$(drush sql:connect) < latest.sql
50-
drush cim -y && drush updb -y && drush cr
51-
composer update drupal/helfi_* drupal/hdbt* -W --no-interaction
52-
drush cr
53-
54-
# Update translations from localize.drupal.org and helfi-modules
55-
# before running update hooks to reduce clutter in configuration files.
56-
drush locale:check && drush locale:update
57-
drush updb -y
58-
59-
# Update translations from helfi_platform_config. These translations
60-
# consists of overrides for non customised translations and will
61-
# override current translation with a non customised translation.
62-
drush helfi:locale-import helfi_platform_config
63-
drush cex -y
64-
65-
# Update platform
66-
drush helfi:tools:update-platform
67-
68-
- name: Check module versions
69-
id: module-status
70-
run: |
71-
MODE="delete"
72-
drush helfi:tools:check-composer-versions $GITHUB_WORKSPACE/composer.lock --format=markdown_table >> $GITHUB_STEP_SUMMARY && EXIT_CODE=$? || EXIT_CODE=$?
73-
if [ "$EXIT_CODE" -eq 3 ]; then
74-
MODE="upsert"
75-
echo " " >> $GITHUB_STEP_SUMMARY
76-
echo ":warning: Failed to install the latest version of the packages listed above" >> $GITHUB_STEP_SUMMARY
77-
echo " " >> $GITHUB_STEP_SUMMARY
78-
echo "Please run \`composer why-not drupal/package_name package_version\` to see why." >> $GITHUB_STEP_SUMMARY
79-
fi
80-
echo "MODE=$MODE" >> $GITHUB_OUTPUT
81-
cat $GITHUB_STEP_SUMMARY > /tmp/pr-message.txt
82-
83-
- name: Create Pull Request
84-
uses: peter-evans/create-pull-request@v6
85-
with:
86-
commit-message: Update configuration
87-
token: ${{ secrets.AUTOMATIC_UPDATE_TOKEN }}
88-
title: Automatic update
89-
labels: auto-update
90-
body: |
91-
- Updated active configuration.
92-
- Updated platform
93-
branch: update-configuration
94-
95-
- name: Attempt to find PR
96-
env:
97-
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
98-
id: find-pr
99-
run: echo "number=$(gh pr list --base ${BRANCH_NAME} --head update-configuration --json number --jq '.[].number')" >> $GITHUB_OUTPUT
100-
101-
- name: Comment PR
102-
uses: thollander/actions-comment-pull-request@v2
103-
if: ${{ steps.find-pr.outputs.number != '' }}
104-
with:
105-
comment_tag: status
106-
mode: ${{ steps.module-status.outputs.MODE }}
107-
filePath: /tmp/pr-message.txt
108-
pr_number: ${{ steps.find-pr.outputs.number }}
8+
uses: city-of-helsinki/drupal-gh-actions/.github/workflows/update-config.yml@main
9+
secrets:
10+
automatic_update_token: ${{ secrets.AUTOMATIC_UPDATE_TOKEN }}

0 commit comments

Comments
 (0)