Skip to content

Commit f120199

Browse files
authored
Merge pull request #3 from salsadigitalauorg/feature/gha
Feature/gha
2 parents 6163826 + 0ea0cc9 commit f120199

24 files changed

+764
-314
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
/docker-compose.override.default.yml export-ignore
1414
/docker-compose.yml export-ignore
1515
/tmp export-ignore
16+
/phpunit.xml export-ignore
1617
/README.developers.md export-ignore

.github/drupal/.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Drupal editor configuration normalization
2+
# @see http://editorconfig.org/
3+
4+
# This is the top-most .editorconfig file; do not search in parent directories.
5+
root = true
6+
7+
# All files.
8+
[*]
9+
end_of_line = LF
10+
indent_style = space
11+
indent_size = 2
12+
charset = utf-8
13+
trim_trailing_whitespace = true
14+
insert_final_newline = true
15+
16+
[composer.{json,lock}]
17+
indent_size = 4

.github/drupal/.gitattributes

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Drupal git normalization
2+
# @see https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
# @see https://www.drupal.org/node/1542048
4+
5+
# Normally these settings would be done with macro attributes for improved
6+
# readability and easier maintenance. However macros can only be defined at the
7+
# repository root directory. Drupal avoids making any assumptions about where it
8+
# is installed.
9+
10+
# Define text file attributes.
11+
# - Treat them as text.
12+
# - Ensure no CRLF line-endings, neither on checkout nor on checkin.
13+
# - Detect whitespace errors.
14+
# - Exposed by default in `git diff --color` on the CLI.
15+
# - Validate with `git diff --check`.
16+
# - Deny applying with `git apply --whitespace=error-all`.
17+
# - Fix automatically with `git apply --whitespace=fix`.
18+
19+
*.config text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
20+
*.css text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
21+
*.dist text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
22+
*.engine text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
23+
*.html text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=html
24+
*.inc text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
25+
*.install text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
26+
*.js text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
27+
*.json text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
28+
*.lock text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
29+
*.map text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
30+
*.md text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
31+
*.module text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
32+
*.php text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
33+
*.po text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
34+
*.profile text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
35+
*.script text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
36+
*.sh text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
37+
*.sql text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
38+
*.svg text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
39+
*.theme text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
40+
*.twig text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
41+
*.txt text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
42+
*.xml text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
43+
*.yml text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
44+
45+
# PHPStan's baseline uses tabs instead of spaces.
46+
core/.phpstan-baseline.php text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tabwidth=2 diff=php linguist-language=php
47+
48+
# Define binary file attributes.
49+
# - Do not treat them as text.
50+
# - Include binary diff in patches instead of "binary files differ."
51+
*.eot -text diff
52+
*.exe -text diff
53+
*.gif -text diff
54+
*.gz -text diff
55+
*.ico -text diff
56+
*.jpeg -text diff
57+
*.jpg -text diff
58+
*.otf -text diff
59+
*.phar -text diff
60+
*.png -text diff
61+
*.svgz -text diff
62+
*.ttf -text diff
63+
*.woff -text diff
64+
*.woff2 -text diff

.github/drupal/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM php:8.3-cli
2+
3+
# Install system dependencies
4+
RUN apt-get update && apt-get install -y \
5+
git \
6+
unzip \
7+
libzip-dev \
8+
&& docker-php-ext-install zip
9+
10+
# Install Composer
11+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
12+
13+
# Configure environment
14+
ENV COMPOSER_ALLOW_SUPERUSER=1
15+
WORKDIR /app
16+
17+
# Copy only required files for dependency installation
18+
COPY composer.json composer.lock ./
19+
RUN composer install --no-interaction --prefer-dist --no-scripts
20+
21+
# Copy remaining source files
22+
COPY . .

.github/drupal/composer.json

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"name": "drupal/recommended-project",
3+
"description": "Project template for Drupal projects with a relocated document root",
4+
"type": "project",
5+
"license": "GPL-2.0-or-later",
6+
"homepage": "https://www.drupal.org/project/drupal",
7+
"support": {
8+
"docs": "https://www.drupal.org/docs/user_guide/en/index.html",
9+
"chat": "https://www.drupal.org/node/314178"
10+
},
11+
"repositories": [
12+
{
13+
"type": "path",
14+
"url": "/var/www/html",
15+
"options": {
16+
"symlink": true
17+
}
18+
},
19+
{
20+
"type": "composer",
21+
"url": "https://packages.drupal.org/8"
22+
}
23+
],
24+
"require": {
25+
"composer/installers": "^2.0",
26+
"drupal/core-composer-scaffold": "^10.1",
27+
"drupal/core-project-message": "^10.1",
28+
"drupal/core-recommended": "^10.1",
29+
"drush/drush": "^12.4",
30+
"salsadigitalauorg/scaffold-testing": "*"
31+
},
32+
"require-dev": {
33+
"drevops/behat-format-progress-fail": "^1",
34+
"drevops/behat-screenshot": "1.5.0",
35+
"drevops/behat-steps": "^2",
36+
"drupal/core-dev": "^10.1",
37+
"phpspec/prophecy-phpunit": "^2.0",
38+
"phpunit/phpunit": "^9.6",
39+
"symfony/phpunit-bridge": "^6.4"
40+
},
41+
"conflict": {
42+
"drupal/drupal": "*"
43+
},
44+
"minimum-stability": "dev",
45+
"prefer-stable": true,
46+
"config": {
47+
"allow-plugins": {
48+
"composer/installers": true,
49+
"dealerdirect/phpcodesniffer-composer-installer": true,
50+
"drupal/core-composer-scaffold": true,
51+
"drupal/core-project-message": true,
52+
"php-http/discovery": true,
53+
"phpstan/extension-installer": true,
54+
"tbachert/spi": true
55+
},
56+
"sort-packages": true
57+
},
58+
"autoload-dev": {
59+
"psr-4": {
60+
"Salsadigitalauorg\\ScaffoldTesting\\Tests\\": "vendor/salsadigitalauorg/scaffold-testing/tests/",
61+
"Salsadigitalauorg\\ScaffoldTesting\\Tests\\Behat\\": "vendor/salsadigitalauorg/scaffold-testing/tests/behat/bootstrap/"
62+
}
63+
},
64+
"extra": {
65+
"drupal-scaffold": {
66+
"locations": {
67+
"web-root": "web/"
68+
}
69+
},
70+
"installer-paths": {
71+
"web/core": ["type:drupal-core"],
72+
"web/libraries/{$name}": ["type:drupal-library"],
73+
"web/modules/contrib/{$name}": ["type:drupal-module"],
74+
"web/profiles/contrib/{$name}": ["type:drupal-profile"],
75+
"web/themes/contrib/{$name}": ["type:drupal-theme"],
76+
"drush/Commands/contrib/{$name}": ["type:drupal-drush"],
77+
"web/modules/custom/{$name}": ["type:drupal-custom-module"],
78+
"web/profiles/custom/{$name}": ["type:drupal-custom-profile"],
79+
"web/themes/custom/{$name}": ["type:drupal-custom-theme"]
80+
},
81+
"drupal-core-project-message": {
82+
"include-keys": ["homepage", "support"],
83+
"post-create-project-cmd-message": [
84+
"<bg=blue;fg=white> </>",
85+
"<bg=blue;fg=white> Congratulations, you've installed the Drupal codebase </>",
86+
"<bg=blue;fg=white> from the drupal/recommended-project template! </>",
87+
"<bg=blue;fg=white> </>",
88+
"",
89+
"<bg=yellow;fg=black>Next steps</>:",
90+
" * Install the site: https://www.drupal.org/docs/installing-drupal",
91+
" * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
92+
" * Get support: https://www.drupal.org/support",
93+
" * Get involved with the Drupal community:",
94+
" https://www.drupal.org/getting-involved",
95+
" * Remove the plugin that prints this message:",
96+
" composer remove drupal/core-project-message"
97+
]
98+
}
99+
}
100+
}

.github/drupal/phpunit.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
4+
bootstrap=".github/drupal/tests/bootstrap.php"
5+
colors="true">
6+
<testsuites>
7+
<testsuite name="Installer Tests">
8+
<directory>.github/drupal/tests/Unit/Installer</directory>
9+
</testsuite>
10+
</testsuites>
11+
<php>
12+
<ini name="error_reporting" value="-1"/>
13+
<env name="APP_ENV" value="testing"/>
14+
</php>
15+
</phpunit>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Salsadigitalauorg\ScaffoldTesting\Tests\Unit\Installer;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Salsadigitalauorg\ScaffoldTesting\Installer\Installer;
9+
10+
class InstallerTest extends TestCase
11+
{
12+
public function testGhaIntegration(): void
13+
{
14+
$this->assertTrue(class_exists(Installer::class),
15+
'Installer class should be available in GHA environment');
16+
}
17+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Salsadigitalauorg\ScaffoldTesting\Tests;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Salsadigitalauorg\ScaffoldTesting\Installer\Installer;
9+
use Composer\Composer;
10+
use Composer\Config;
11+
use Composer\IO\IOInterface;
12+
use Composer\Package\RootPackage;
13+
use Composer\Script\Event;
14+
use Composer\Util\Filesystem;
15+
16+
class InstallerTest extends TestCase
17+
{
18+
protected IOInterface $io;
19+
protected RootPackage $package;
20+
protected Config $config;
21+
protected Composer $composer;
22+
protected Event $event;
23+
24+
protected function setUp(): void
25+
{
26+
$this->io = $this->createMock(IOInterface::class);
27+
$this->package = $this->createMock(RootPackage::class);
28+
$this->config = $this->createMock(Config::class);
29+
$this->composer = $this->createMock(Composer::class);
30+
31+
$this->composer->method('getConfig')
32+
->willReturn($this->config);
33+
34+
$this->config->method('get')
35+
->with('vendor-dir')
36+
->willReturn('/var/www/html/vendor');
37+
38+
$this->package->method('getExtra')
39+
->willReturn([
40+
'scaffold-testing' => [
41+
'target-dir' => 'tests/behat/',
42+
'override' => false
43+
]
44+
]);
45+
46+
$this->composer->method('getPackage')
47+
->willReturn($this->package);
48+
49+
$this->event = $this->createMock(Event::class);
50+
$this->event->method('getIO')
51+
->willReturn($this->io);
52+
$this->event->method('getComposer')
53+
->willReturn($this->composer);
54+
}
55+
56+
public function testFeatures(): void
57+
{
58+
$this->io->expects(self::atLeastOnce())
59+
->method('write')
60+
->with('[scaffold-testing] Installer::features method called');
61+
62+
Installer::features($this->event);
63+
}
64+
65+
protected function tearDown(): void
66+
{
67+
// Cleanup test files using absolute paths
68+
@unlink('/var/www/html/tests/behat/features/login.feature');
69+
@unlink('/var/www/html/tests/behat/features/search.feature');
70+
}
71+
}

.github/drupal/tests/bootstrap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
require __DIR__.'/../../../../vendor/autoload.php';

.github/workflows/renovate.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
11
name: Renovate
22
on:
33
schedule:
4-
- cron: '1 9 * * 1'
4+
- cron: '1 9 * * 1' # Run every Monday at 9:01 AM
5+
workflow_dispatch: # Allow manual triggering
6+
push:
7+
branches:
8+
- main
9+
paths:
10+
- 'composer.json'
11+
- 'composer.lock'
12+
- 'renovate-gh.json'
13+
- '.github/workflows/renovate.yml'
14+
515
jobs:
616
renovate:
717
runs-on: ubuntu-latest
818
steps:
919
- name: Checkout
1020
uses: actions/checkout@v4.1.7
11-
- uses: suzuki-shunsuke/github-action-renovate-config-validator@v1.0.1
21+
22+
- name: Validate Renovate config
23+
uses: suzuki-shunsuke/github-action-renovate-config-validator@v1.0.1
24+
1225
- name: Self-hosted Renovate
1326
uses: renovatebot/github-action@v40.2.3
1427
env:
15-
# Update the value of RENOVATE_GIT_AUTHOR with your own.
16-
RENOVATE_GIT_AUTHOR: 'Renovate Self Hosted <servicedesk.team+renovatebot@salsa.digital>'
17-
RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by GitHub Actions'
28+
RENOVATE_GIT_AUTHOR: 'salsadeploy <deployer@salsa.digital>'
29+
RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard'
1830
RENOVATE_DEPENDENCY_DASHBOARD: true
1931
RENOVATE_REPOSITORIES: ${{ github.repository }}
2032
RENOVATE_PLATFORM: 'github'
2133
RENOVATE_AUTODISCOVER: false
22-
RENOVATE_DRY_RUN: true
34+
LOG_LEVEL: debug
2335
with:
2436
configurationFile: renovate-gh.json
2537
token: ${{ secrets.RENOVATE_TOKEN }}

0 commit comments

Comments
 (0)