Skip to content

Commit

Permalink
added CI layer
Browse files Browse the repository at this point in the history
  • Loading branch information
uestla committed Oct 11, 2024
1 parent 88a6eab commit b99e607
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Tests"

on: [push, pull_request]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: [8.2, 8.3]

fail-fast: false

name: PHP ${{matrix.php}}

steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- run: make ci
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/bin
/vendor
/composer.lock
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.DEFAULT_GOAL := help

help:
@printf "\033[33mUsage:\033[0m\n make [target] [arg=\"val\"...]\n\n\033[33mTargets:\033[0m\n"
@grep -E '^[-a-zA-Z0-9_\.\/]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-15s\033[0m %s\n", $$1, $$2}'

.PHONY: install
install: install-composer vendor ## Installs all project dependencies

.PHONY: install-composer
install-composer:
@[ -f bin/composer ] \
|| (echo '> Installing composer...' \
&& php -r 'copy("https://getcomposer.org/installer", "composer-setup.php");' \
&& php -r 'if (hash_file("sha384", "composer-setup.php") === file_get_contents("https://composer.github.io/installer.sig")) { echo "Installer verified"; } else { echo "Installer corrupt"; unlink("composer-setup.php"); } echo PHP_EOL;' \
&& mkdir -p bin \
&& php composer-setup.php --install-dir=bin --filename=composer --2 \
&& rm composer-setup.php)

vendor: composer.json $(wildcard composer.lock)
@echo '> composer install...' \
&& bin/composer install \
&& echo ''

.PHONY: ci
ci: phplint phpstan tester ## Runs complete CI suite

.PHONY: phplint
phplint: install
@echo '> PHP linter ...'
@php vendor/bin/parallel-lint Simplex/ tests/ --colors --no-progress
@echo ''

.PHONY: phpstan
phpstan: install
@echo '> PHPStan ...'
@php vendor/bin/phpstan analyse --no-progress

.PHONY: tester
tester: install
@echo '> tester ...'
@php vendor/bin/tester tests/ -C --colors
15 changes: 15 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,22 @@
"ext-bcmath": "*",
"php": ">=8.2"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.3",
"php-parallel-lint/php-console-highlighter": "^1.0",
"phpstan/phpstan": "^1.10",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5",
"phpstan/phpstan-deprecation-rules": "^1.1",
"nette/tester": "^2.5",
"tracy/tracy": "^2.10"
},
"autoload": {
"files": ["Simplex/simplex.php"]
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
}
}
}
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
level: max
paths:
- Simplex/
- tests/
11 changes: 11 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Simplex\Tests;

use Tester\Environment;


require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../Simplex/simplex.php';

Environment::setup();

0 comments on commit b99e607

Please sign in to comment.