Skip to content

Commit

Permalink
Staging some CI tests as example (#108)
Browse files Browse the repository at this point in the history
* Staging some CI tests as example
  • Loading branch information
rachellawson authored Jan 30, 2024
1 parent 227693c commit 6275833
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/rachelnorfolk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: RachelNorfolk Custom Modules

on: [push]

jobs:
build-test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: gdate, dom, filter, gd, hash, json, pcre, PDO, session, SimpleXML, SPL, tokenizer, xml

- name: Composer Install
run: |
composer --no-interaction --no-progress --optimize-autoloader install
- name: Webserver
run: |
nohup php -S 0.0.0.0:8000 -t web > phpd.log 2>&1 &
sed -i "s/\/localhost/\/localhost:8000/g" phpunit.xml
- name: PHPUnit Tests
run: |
./vendor/bin/phpunit web/modules/custom
- name: Check Drupal Coding Standards
run: |
./vendor/bin/phpcs web/modules/custom
- name: Drupal Rector
run: |
composer require --dev palantirnet/drupal-rector
cp vendor/palantirnet/drupal-rector/rector.php .
./vendor/bin/rector process web/modules/custom --dry-run
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"hostname": "0.0.0.0",
"port": 9003,
"pathMappings": {
"/var/www/html": "${workspaceFolder}"
}
}
]
}
22 changes: 22 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="phpcs">
<description>PHP Code Sniffer configuration</description>
<file>./web/modules/custom</file>
<arg name="extensions"
value="php,
module,
inc,
install,
test,
profile,
theme,
css,
info,
txt,
md,
yml" />
<config name="drupal_core_version"
value="10" />
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal" />
<rule ref="vendor/drupal/coder/coder_sniffer/DrupalPractice"/>
</ruleset>
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Drupal\Tests\dark_mode\Functional;

use Drupal\Tests\BrowserTestBase;

/**
* Check that we are actually putting the css on the page.
*
* @group dark_mode
*/
final class DarkModeEnabledTest extends BrowserTestBase {

/**
* {@inheritdoc}
*/
protected $defaultTheme = 'olivero';

/**
* {@inheritdoc}
*/
protected static $modules = ['dark_mode'];

/**
* Test callback.
*/
public function testLibraryLoaded(): void {
$this->drupalGet('/');
$this->assertSession()->statusCodeEquals(200);

// Should contain the dark mode css but not that for grey pride.
$this->assertSession()->responseContains('dark_mode/css/dark-mode.css');
$this->assertSession()->responseNotContains('dark_mode/css/grey-pride.css');
}

}

0 comments on commit 6275833

Please sign in to comment.