Skip to content

Commit

Permalink
Merge pull request #3 from salsadigitalauorg/feature/gha
Browse files Browse the repository at this point in the history
Feature/gha
  • Loading branch information
ivangrynenko authored Jan 22, 2025
2 parents 6163826 + 0ea0cc9 commit f120199
Show file tree
Hide file tree
Showing 24 changed files with 764 additions and 314 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
/docker-compose.override.default.yml export-ignore
/docker-compose.yml export-ignore
/tmp export-ignore
/phpunit.xml export-ignore
/README.developers.md export-ignore
17 changes: 17 additions & 0 deletions .github/drupal/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Drupal editor configuration normalization
# @see http://editorconfig.org/

# This is the top-most .editorconfig file; do not search in parent directories.
root = true

# All files.
[*]
end_of_line = LF
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[composer.{json,lock}]
indent_size = 4
64 changes: 64 additions & 0 deletions .github/drupal/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Drupal git normalization
# @see https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
# @see https://www.drupal.org/node/1542048

# Normally these settings would be done with macro attributes for improved
# readability and easier maintenance. However macros can only be defined at the
# repository root directory. Drupal avoids making any assumptions about where it
# is installed.

# Define text file attributes.
# - Treat them as text.
# - Ensure no CRLF line-endings, neither on checkout nor on checkin.
# - Detect whitespace errors.
# - Exposed by default in `git diff --color` on the CLI.
# - Validate with `git diff --check`.
# - Deny applying with `git apply --whitespace=error-all`.
# - Fix automatically with `git apply --whitespace=fix`.

*.config text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.css text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.dist text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.engine text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.html text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=html
*.inc text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.install text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.js text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.json text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.lock text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.map text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.md text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.module text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.php text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.po text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.profile text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.script text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.sh text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.sql text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.svg text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.theme text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
*.twig text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.txt text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.xml text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.yml text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2

# PHPStan's baseline uses tabs instead of spaces.
core/.phpstan-baseline.php text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tabwidth=2 diff=php linguist-language=php

# Define binary file attributes.
# - Do not treat them as text.
# - Include binary diff in patches instead of "binary files differ."
*.eot -text diff
*.exe -text diff
*.gif -text diff
*.gz -text diff
*.ico -text diff
*.jpeg -text diff
*.jpg -text diff
*.otf -text diff
*.phar -text diff
*.png -text diff
*.svgz -text diff
*.ttf -text diff
*.woff -text diff
*.woff2 -text diff
22 changes: 22 additions & 0 deletions .github/drupal/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM php:8.3-cli

# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
unzip \
libzip-dev \
&& docker-php-ext-install zip

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Configure environment
ENV COMPOSER_ALLOW_SUPERUSER=1
WORKDIR /app

# Copy only required files for dependency installation
COPY composer.json composer.lock ./
RUN composer install --no-interaction --prefer-dist --no-scripts

# Copy remaining source files
COPY . .
100 changes: 100 additions & 0 deletions .github/drupal/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"name": "drupal/recommended-project",
"description": "Project template for Drupal projects with a relocated document root",
"type": "project",
"license": "GPL-2.0-or-later",
"homepage": "https://www.drupal.org/project/drupal",
"support": {
"docs": "https://www.drupal.org/docs/user_guide/en/index.html",
"chat": "https://www.drupal.org/node/314178"
},
"repositories": [
{
"type": "path",
"url": "/var/www/html",
"options": {
"symlink": true
}
},
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
"require": {
"composer/installers": "^2.0",
"drupal/core-composer-scaffold": "^10.1",
"drupal/core-project-message": "^10.1",
"drupal/core-recommended": "^10.1",
"drush/drush": "^12.4",
"salsadigitalauorg/scaffold-testing": "*"
},
"require-dev": {
"drevops/behat-format-progress-fail": "^1",
"drevops/behat-screenshot": "1.5.0",
"drevops/behat-steps": "^2",
"drupal/core-dev": "^10.1",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.6",
"symfony/phpunit-bridge": "^6.4"
},
"conflict": {
"drupal/drupal": "*"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"drupal/core-composer-scaffold": true,
"drupal/core-project-message": true,
"php-http/discovery": true,
"phpstan/extension-installer": true,
"tbachert/spi": true
},
"sort-packages": true
},
"autoload-dev": {
"psr-4": {
"Salsadigitalauorg\\ScaffoldTesting\\Tests\\": "vendor/salsadigitalauorg/scaffold-testing/tests/",
"Salsadigitalauorg\\ScaffoldTesting\\Tests\\Behat\\": "vendor/salsadigitalauorg/scaffold-testing/tests/behat/bootstrap/"
}
},
"extra": {
"drupal-scaffold": {
"locations": {
"web-root": "web/"
}
},
"installer-paths": {
"web/core": ["type:drupal-core"],
"web/libraries/{$name}": ["type:drupal-library"],
"web/modules/contrib/{$name}": ["type:drupal-module"],
"web/profiles/contrib/{$name}": ["type:drupal-profile"],
"web/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/Commands/contrib/{$name}": ["type:drupal-drush"],
"web/modules/custom/{$name}": ["type:drupal-custom-module"],
"web/profiles/custom/{$name}": ["type:drupal-custom-profile"],
"web/themes/custom/{$name}": ["type:drupal-custom-theme"]
},
"drupal-core-project-message": {
"include-keys": ["homepage", "support"],
"post-create-project-cmd-message": [
"<bg=blue;fg=white> </>",
"<bg=blue;fg=white> Congratulations, you've installed the Drupal codebase </>",
"<bg=blue;fg=white> from the drupal/recommended-project template! </>",
"<bg=blue;fg=white> </>",
"",
"<bg=yellow;fg=black>Next steps</>:",
" * Install the site: https://www.drupal.org/docs/installing-drupal",
" * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
" * Get support: https://www.drupal.org/support",
" * Get involved with the Drupal community:",
" https://www.drupal.org/getting-involved",
" * Remove the plugin that prints this message:",
" composer remove drupal/core-project-message"
]
}
}
}
15 changes: 15 additions & 0 deletions .github/drupal/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap=".github/drupal/tests/bootstrap.php"
colors="true">
<testsuites>
<testsuite name="Installer Tests">
<directory>.github/drupal/tests/Unit/Installer</directory>
</testsuite>
</testsuites>
<php>
<ini name="error_reporting" value="-1"/>
<env name="APP_ENV" value="testing"/>
</php>
</phpunit>
17 changes: 17 additions & 0 deletions .github/drupal/tests/Unit/Installer/InstallerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Salsadigitalauorg\ScaffoldTesting\Tests\Unit\Installer;

use PHPUnit\Framework\TestCase;
use Salsadigitalauorg\ScaffoldTesting\Installer\Installer;

class InstallerTest extends TestCase
{
public function testGhaIntegration(): void
{
$this->assertTrue(class_exists(Installer::class),
'Installer class should be available in GHA environment');
}
}
71 changes: 71 additions & 0 deletions .github/drupal/tests/Unit/InstallerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

declare(strict_types=1);

namespace Salsadigitalauorg\ScaffoldTesting\Tests;

use PHPUnit\Framework\TestCase;
use Salsadigitalauorg\ScaffoldTesting\Installer\Installer;
use Composer\Composer;
use Composer\Config;
use Composer\IO\IOInterface;
use Composer\Package\RootPackage;
use Composer\Script\Event;
use Composer\Util\Filesystem;

class InstallerTest extends TestCase
{
protected IOInterface $io;
protected RootPackage $package;
protected Config $config;
protected Composer $composer;
protected Event $event;

protected function setUp(): void
{
$this->io = $this->createMock(IOInterface::class);
$this->package = $this->createMock(RootPackage::class);
$this->config = $this->createMock(Config::class);
$this->composer = $this->createMock(Composer::class);

$this->composer->method('getConfig')
->willReturn($this->config);

$this->config->method('get')
->with('vendor-dir')
->willReturn('/var/www/html/vendor');

$this->package->method('getExtra')
->willReturn([
'scaffold-testing' => [
'target-dir' => 'tests/behat/',
'override' => false
]
]);

$this->composer->method('getPackage')
->willReturn($this->package);

$this->event = $this->createMock(Event::class);
$this->event->method('getIO')
->willReturn($this->io);
$this->event->method('getComposer')
->willReturn($this->composer);
}

public function testFeatures(): void
{
$this->io->expects(self::atLeastOnce())
->method('write')
->with('[scaffold-testing] Installer::features method called');

Installer::features($this->event);
}

protected function tearDown(): void
{
// Cleanup test files using absolute paths
@unlink('/var/www/html/tests/behat/features/login.feature');
@unlink('/var/www/html/tests/behat/features/search.feature');
}
}
2 changes: 2 additions & 0 deletions .github/drupal/tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
require __DIR__.'/../../../../vendor/autoload.php';
24 changes: 18 additions & 6 deletions .github/workflows/renovate.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
name: Renovate
on:
schedule:
- cron: '1 9 * * 1'
- cron: '1 9 * * 1' # Run every Monday at 9:01 AM
workflow_dispatch: # Allow manual triggering
push:
branches:
- main
paths:
- 'composer.json'
- 'composer.lock'
- 'renovate-gh.json'
- '.github/workflows/renovate.yml'

jobs:
renovate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- uses: suzuki-shunsuke/[email protected]

- name: Validate Renovate config
uses: suzuki-shunsuke/[email protected]

- name: Self-hosted Renovate
uses: renovatebot/[email protected]
env:
# Update the value of RENOVATE_GIT_AUTHOR with your own.
RENOVATE_GIT_AUTHOR: 'Renovate Self Hosted <[email protected]>'
RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by GitHub Actions'
RENOVATE_GIT_AUTHOR: 'salsadeploy <[email protected]>'
RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard'
RENOVATE_DEPENDENCY_DASHBOARD: true
RENOVATE_REPOSITORIES: ${{ github.repository }}
RENOVATE_PLATFORM: 'github'
RENOVATE_AUTODISCOVER: false
RENOVATE_DRY_RUN: true
LOG_LEVEL: debug
with:
configurationFile: renovate-gh.json
token: ${{ secrets.RENOVATE_TOKEN }}
Loading

0 comments on commit f120199

Please sign in to comment.