Skip to content

Commit

Permalink
Introduce Continuous Integration (#20)
Browse files Browse the repository at this point in the history
* WIP CI
* Move few things around in CI pipeline
* remove unneeded CI job
  • Loading branch information
martinssipenko authored and NoelDavies committed Nov 19, 2019
1 parent 5930a03 commit 63966cd
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 31 deletions.
81 changes: 81 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
unit-config: &unit-config
environment:
COMPOSER_PREFER_LOWEST: 0
steps:
- checkout

- run:
name: Install latest composer
command: |
php -r "copy('https://raw.githubusercontent.com/composer/getcomposer.org/master/web/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer
- run:
name: Write COMPOSER_PREFER_LOWEST to file
command: echo "$COMPOSER_PREFER_LOWEST" > ~/COMPOSER_PREFER_LOWEST.txt

# Download and cache dependencies
- restore_cache:
keys:
- v1-composer-cache-{{ checksum "~/COMPOSER_PREFER_LOWEST.txt" }}-{{ checksum "composer.json" }}
# Fall back to using the latest cache if no exact match is found.
- v1-composer-cache-{{ checksum "~/COMPOSER_PREFER_LOWEST.txt" }}

- run:
name: Validate composer files
command: composer validate --strict

- run:
name: Install PHP extensions
command: |
printf '\n' | sudo pecl install redis
sudo docker-php-ext-enable redis
- run:
name: Install composer packages
command: |
if [ $COMPOSER_PREFER_LOWEST -eq "1" ]; then
composer update --no-ansi --no-progress --optimize-autoloader --no-interaction --no-plugins --no-scripts --prefer-dist --prefer-stable --prefer-lowest
else
composer update --no-ansi --no-progress --optimize-autoloader --no-interaction --no-plugins --no-scripts --prefer-dist --prefer-stable
fi
- save_cache:
key: v1-composer-cache-{{ checksum "~/COMPOSER_PREFER_LOWEST.txt" }}-{{ checksum "composer.json" }}
paths:
- ./vendor

- run:
name: Wait for backing services to start
command: dockerize -wait tcp://127.0.0.1:6379 -timeout 30s

- run:
name: Run tests
command: ./vendor/bin/phpunit

version: 2.1
jobs:
php73:
<<: *unit-config
docker:
- image: circleci/php:7.3-cli-node
- image: circleci/redis:5-alpine
environment:
COMPOSER_PREFER_LOWEST: 0

php73-lowest:
<<: *unit-config
docker:
- image: circleci/php:7.3-cli-node
- image: circleci/redis:5-alpine
environment:
COMPOSER_PREFER_LOWEST: 1

workflows:
version: 2
units:
jobs:
- php73
- php73-lowest
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
* text=auto
/.circleci/ export-ignore
/.github/ export-ignore
/examples/ export-ignore
/nginx/ export-ignore
/php-fpm/ export-ignore
/tests/ export-ignore
.gitattributes export-ignore
.gitignore export-ignore
docker-compose.yml export-ignore
phpcs.xml.dist export-ignore
phpunit.xml.dist export-ignore
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

14 changes: 12 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "endclothing/prometheus_client_php",
"version": "1.0.1",
"description": "Prometheus instrumentation library for PHP applications.",
"type": "library",
"license": "Apache-2.0",
"authors": [
{
"name": "Daniel Noel-Davies",
Expand Down Expand Up @@ -33,5 +35,13 @@
"Test\\Prometheus\\": "tests/"
}
},
"license": "Apache-2.0"
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"config": {
"sort-packages": true
},
"prefer-stable": true
}
23 changes: 13 additions & 10 deletions phpunit.xml → phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory>./tests/Test/Prometheus</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/Prometheus</directory>
</whitelist>
</filter>

<testsuites>
<testsuite name="Unit">
<directory>./tests/Test/Prometheus</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/Prometheus</directory>
</whitelist>
</filter>
</phpunit>

0 comments on commit 63966cd

Please sign in to comment.