Skip to content

Commit

Permalink
Merge pull request #5 from stevegrunwell/feature/config-files
Browse files Browse the repository at this point in the history
Automatically create runkit.ini files
  • Loading branch information
stevegrunwell authored Jun 27, 2018
2 parents 2c1cf67 + 045b276 commit 72592f9
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 6 deletions.
11 changes: 6 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# PHP PSR-2 Coding Standards
# http://www.php-fig.org/psr/psr-2/

root = true

[*.php]
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
indent_size = 4

[*.yml]
indent_style = space
indent_size = 2
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sudo: false
sudo: true
dist: trusty
language: php

Expand All @@ -13,5 +13,9 @@ php:
install:
- composer install --prefer-dist

before_script:
- sudo mkdir -p "/etc/php/${TRAVIS_PHP_VERSION}/mods-available"

script:
- ./vendor/bin/phpunit
- shellcheck bin/*.sh
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

* Attempt to automatically create `runkit.ini` files upon installation ([#1]).
* Add a `name` attribute to the `<testsuite>` node, fixing some Travis build errors ([#2]).
* Document that root access might be necessary to run the installer ([#3]).
* Include [Shellcheck](https://www.shellcheck.net/) as part of the continuous integration process.

## [1.0.0] - 2018-03-29

* Initial public release.

[Unreleased]: https://github.com/stevegrunwell/runkit7-installer/compare/master...develop
[1.0.0]: https://github.com/stevegrunwell/runkit7-installer/releases/tag/v1.0.0
[#1]: https://github.com/stevegrunwell/runkit7-installer/issues/1
[#2]: https://github.com/stevegrunwell/runkit7-installer/issues/2
[#3]: https://github.com/stevegrunwell/runkit7-installer/issues/3
14 changes: 14 additions & 0 deletions bin/install-runkit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,17 @@ echo "\\033[0;33mInstalling Runkit7...\\033[0;m"
download "https://github.com/runkit7/runkit7/releases/download/${RUNKIT_VERSION}/runkit-${RUNKIT_VERSION}.tgz" "$DOWNLOAD_FILENAME" \
&& pecl install "$DOWNLOAD_FILENAME" \
&& rm "$DOWNLOAD_FILENAME"

# Create runkit.ini files for each version of PHP.
MODS=$(find /etc/php/ -name "mods-available" -type d)
for DIR in $MODS; do
if [ ! -f "$DIR/runkit.ini" ]; then
echo "extension=runkit.so" | sudo tee "$DIR/runkit.ini" > /dev/null \
&& echo "Created ${DIR}/runkit.ini"
fi
done

# Attempt to enable the Runkit PHP module.
if [ "$(command -v phpenmod)" ]; then
sudo phpenmod runkit && echo "\\033[0;32mRunkit7 has been installed and activated!\\033[0;0m"
fi
6 changes: 6 additions & 0 deletions tests/InstallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ public function testInstallsRunkit()
'Expected the Runkit extension to not yet be loaded.'
);

$version = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION;

exec(dirname(__DIR__) . '/bin/install-runkit.sh', $output, $exitCode);

$this->assertEquals(0, $exitCode, 'Expected an exit code of 0:' . $this->quoteShellOutput($output));
$this->assertTrue(
(bool) preg_match('/^runkit\s/m', shell_exec('pecl list')),
'The Runkit extension should have been loaded.'
);
$this->assertTrue(
file_exists('/etc/php/' . $version . '/mods-available/runkit.ini'),
'Expected a runkit.ini file to be created for PHP ' . $version . '.'
);
}

/**
Expand Down

0 comments on commit 72592f9

Please sign in to comment.