Skip to content

Commit 0626c77

Browse files
authored
Migrate from Travis to GitHub Actions (#24)
1 parent 39b6c0b commit 0626c77

File tree

9 files changed

+77
-89
lines changed

9 files changed

+77
-89
lines changed

.travis/test-script.sh renamed to .github/workflows/test-script.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
2+
SITE_ROOT="/tmp/site/mysite"
33
SITE_WEB="$SITE_ROOT/web"
44
SITE_APP="$SITE_ROOT/app"
55

@@ -34,6 +34,8 @@ else
3434
echo "${MSG_OK} 'web' folder exists"
3535
fi
3636

37+
cd "$SITE_ROOT"
38+
3739
##
3840
# Check if the stub files exist.
3941
# See \DrupalComposer\DrupalParanoia $frontControllers
@@ -123,12 +125,12 @@ fi
123125
##
124126
# Create a theme image, run the command 'composer drupal:paranoia' and check if the image has been symlinked.
125127
#
126-
touch "$SITE_APP/themes/travis-test-image.jpg"
128+
touch "$SITE_APP/themes/test-image.jpg"
127129

128130
# Rebuild web directory.
129131
composer drupal:paranoia || exit 1
130132

131-
if [ ! -L "$SITE_WEB/themes/travis-test-image.jpg" ]; then
133+
if [ ! -L "$SITE_WEB/themes/test-image.jpg" ]; then
132134
echo "${MSG_ERROR} 'composer drupal:paranoia' command did not re-create the web directory with new symlinks"
133135
exit 1
134136
else

.github/workflows/testing.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: "Testing"
2+
on: push
3+
env:
4+
SITE_NAME: "mysite"
5+
SITE_ROOT: "/tmp/site/mysite"
6+
jobs:
7+
testing:
8+
name: "Automated tests"
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
-
13+
name: "Install Composer"
14+
run: |
15+
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
16+
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
17+
php composer-setup.php
18+
php -r "unlink('composer-setup.php');"
19+
mv composer.phar /usr/local/bin/composer
20+
-
21+
name: "Install a site"
22+
run: |
23+
# Create Drupal project.
24+
composer create-project drupal-composer/drupal-project:9.x-dev --stability dev --no-interaction --no-dev --prefer-dist "$SITE_ROOT" || exit 1
25+
26+
# https://github.com/drupal-composer/drupal-paranoia#configuration
27+
cd "$SITE_ROOT"
28+
mv "$SITE_ROOT/web" "$SITE_ROOT/app"
29+
sed -e "s?web/?app/?g" --in-place "$SITE_ROOT/composer.json"
30+
composer config extra.drupal-paranoia.app-dir app
31+
composer config extra.drupal-paranoia.web-dir web
32+
33+
# Require local drupal-paranoia project.
34+
composer config repositories.local_drupal_paranoia path "$GITHUB_WORKSPACE"
35+
composer require --update-no-dev drupal-composer/drupal-paranoia:"*" || exit 1
36+
-
37+
name: "Sniff code standards"
38+
run: |
39+
COMPOSER_GLOBAL_HOME=$( composer -n config --global home )
40+
PATH="$PATH:$COMPOSER_GLOBAL_HOME/vendor/bin"
41+
composer global require drupal/coder --prefer-dist || exit 1
42+
phpcs --config-set installed_paths "$COMPOSER_GLOBAL_HOME/vendor/drupal/coder/coder_sniffer"
43+
phpcs --config-set ignore_warnings_on_exit 1
44+
phpcs --standard=Drupal --ignore=*.md,*.txt,.github/* --warning-severity=0 -d date.timezone=UTC .
45+
-
46+
name: "Run Test"
47+
run: |
48+
# Run test script.
49+
$GITHUB_WORKSPACE/.github/workflows/test-script.sh

.travis.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![Packagist Downloads](https://img.shields.io/packagist/dt/drupal-composer/drupal-paranoia.svg)](https://packagist.org/packages/drupal-composer/drupal-paranoia)
2-
[![Build Status](https://travis-ci.org/drupal-composer/drupal-paranoia.svg?branch=1.x)](https://travis-ci.org/drupal-composer/drupal-paranoia)
2+
[![Testing](https://github.com/drupal-composer/drupal-paranoia/actions/workflows/testing.yml/badge.svg)](https://github.com/drupal-composer/drupal-paranoia/actions/workflows/testing.yml)
33

44
# Drupal Paranoia
55
Composer plugin for improving the website security for composer-based Drupal websites by moving all __PHP files out of docroot__.

src/AssetFileTypesEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class AssetFileTypesEvent extends Event {
5555
* @param array $flags
5656
* Optional flags to pass data not as argument.
5757
*/
58-
public function __construct(array $assetFileTypes, Composer $composer, IOInterface $io, array $args = array(), array $flags = array()) {
58+
public function __construct(array $assetFileTypes, Composer $composer, IOInterface $io, array $args = [], array $flags = []) {
5959
parent::__construct(self::POST_DRUPAL_SET_ASSET_FILE_TYPES, $args, $flags);
6060

6161
$this->composer = $composer;

src/CommandProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class CommandProvider implements CommandProviderCapability {
1515
* {@inheritdoc}
1616
*/
1717
public function getCommands() {
18-
return array(
18+
return [
1919
new DrupalParanoiaCommand(),
20-
);
20+
];
2121
}
2222

2323
}

src/DrupalParanoiaCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected function configure() {
2121
parent::configure();
2222
$this
2323
->setName('drupal:paranoia')
24-
->setAliases(array('drupal-paranoia'))
24+
->setAliases(['drupal-paranoia'])
2525
->setDescription('Execute the installation of the paranoia mode.');
2626
}
2727

src/Installer.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ class Installer {
4646
*
4747
* @var array
4848
*/
49-
public $frontControllers = array(
49+
public $frontControllers = [
5050
'index.php',
5151
'core/install.php',
5252
'core/rebuild.php',
5353
'core/modules/statistics/statistics.php',
54-
);
54+
];
5555

5656
/**
5757
* Flag indicating whether is to run the paranoia installation or not.
@@ -108,7 +108,7 @@ public function __construct(Composer $composer, IOInterface $io) {
108108

109109
$this->setAssetFileTypes();
110110

111-
$this->excludes = $this->getConfig('excludes', array());
111+
$this->excludes = $this->getConfig('excludes', []);
112112
}
113113

114114
/**
@@ -126,11 +126,11 @@ public function getConfig($name, $default = NULL) {
126126
$extra = $this->composer->getPackage()->getExtra();
127127

128128
// TODO: Backward compatibility for old configs. Remove on stable version.
129-
$legacyConfigs = array(
129+
$legacyConfigs = [
130130
'drupal-app-dir',
131131
'drupal-web-dir',
132132
'drupal-asset-files',
133-
);
133+
];
134134
if (in_array("drupal-$name", $legacyConfigs) && isset($extra["drupal-$name"])) {
135135
return $extra["drupal-$name"];
136136
}
@@ -264,7 +264,7 @@ public function install() {
264264
}
265265

266266
// Ensure that the app and web directories exist.
267-
$fs->mkdir(array($this->appDir, $this->webDir));
267+
$fs->mkdir([$this->appDir, $this->webDir]);
268268

269269
// Create the stub files.
270270
foreach ($this->frontControllers as $fileName) {
@@ -291,7 +291,7 @@ public function getSitesPublicFilesPath() {
291291
$finder->in($this->appDir . '/sites')
292292
->depth(0);
293293

294-
$directories = array();
294+
$directories = [];
295295

296296
/** @var \Symfony\Component\Finder\SplFileInfo $directory */
297297
foreach ($finder->directories() as $directory) {
@@ -403,7 +403,7 @@ public function createStubPhpFile($path) {
403403
* Set the asset file types.
404404
*/
405405
public function setAssetFileTypes() {
406-
$this->assetFileTypes = array(
406+
$this->assetFileTypes = [
407407
'robots.txt',
408408
'.htaccess',
409409
'*.css',
@@ -420,7 +420,7 @@ public function setAssetFileTypes() {
420420
'*.ttf',
421421
'*.woff',
422422
'*.woff2',
423-
);
423+
];
424424

425425
// Allow people to extend the list from a composer extra key.
426426
$extraAssetFiles = $this->getConfig('asset-files');

src/Plugin.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,22 @@ public function uninstall(Composer $composer, IOInterface $io) {}
4545
* {@inheritdoc}
4646
*/
4747
public function getCapabilities() {
48-
return array(
48+
return [
4949
'Composer\Plugin\Capability\CommandProvider' => 'DrupalComposer\DrupalParanoia\CommandProvider',
50-
);
50+
];
5151
}
5252

5353
/**
5454
* {@inheritdoc}
5555
*/
5656
public static function getSubscribedEvents() {
57-
return array(
58-
PackageEvents::POST_PACKAGE_INSTALL => array('postPackage'),
59-
PackageEvents::POST_PACKAGE_UPDATE => array('postPackage'),
60-
PackageEvents::POST_PACKAGE_UNINSTALL => array('postPackage'),
61-
ScriptEvents::POST_INSTALL_CMD => array('postCmd', -1),
62-
ScriptEvents::POST_UPDATE_CMD => array('postCmd', -1),
63-
);
57+
return [
58+
PackageEvents::POST_PACKAGE_INSTALL => ['postPackage'],
59+
PackageEvents::POST_PACKAGE_UPDATE => ['postPackage'],
60+
PackageEvents::POST_PACKAGE_UNINSTALL => ['postPackage'],
61+
ScriptEvents::POST_INSTALL_CMD => ['postCmd', -1],
62+
ScriptEvents::POST_UPDATE_CMD => ['postCmd', -1],
63+
];
6464
}
6565

6666
/**

0 commit comments

Comments
 (0)