Skip to content

Commit

Permalink
Merge 1dbb6da into 514cbfb
Browse files Browse the repository at this point in the history
  • Loading branch information
grongor committed Aug 4, 2020
2 parents 514cbfb + 1dbb6da commit bfdf02c
Show file tree
Hide file tree
Showing 69 changed files with 3,366 additions and 1,393 deletions.
149 changes: 149 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: CI
on: [push, pull_request]
jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: [7.3]
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}
extensions: json
tools: cs2pr

- name: Install dependencies
run: |
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php${{ matrix.php-version }}-snmp
- name: Cache dependencies installed with composer
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: php-${{ matrix.php-version }}
restore-keys: php-${{ matrix.php-version }}

- name: Install dependencies with composer
run: COMPOSER_ARGS="--prefer-stable" make

- name: Run a static analysis with phpstan/phpstan
env:
PHPSTAN_ARGS: --error-format=checkstyle
run: make -is static-analysis | cs2pr

coding-standards:
name: Coding Standards
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: [7.3]
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
coverage: none
extensions: snmp
php-version: ${{ matrix.php-version }}
tools: cs2pr

- name: Install dependencies
run: sudo apt install php${{ matrix.php-version }}-snmp

- name: Cache dependencies installed with composer
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: php-${{ matrix.php-version }}
restore-keys: php-${{ matrix.php-version }}

- name: Install dependencies with composer
run: COMPOSER_ARGS="--prefer-stable" make

- name: Run squizlabs/php_codesniffer
env:
PHPCS_ARGS: -q --no-colors --report=checkstyle
run: make -is cs | cs2pr

tests:
name: Tests
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: [7.3, 7.4]
dependencies: ["", --prefer-lowest]

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

- name: Install dependencies
run: |
pecl install snmp
sudo apt install python3-pip snmp
- name: Install snmpsim
run: sudo pip3 install snmpsim

- name: Cache dependencies installed with composer
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: php-${{ matrix.php-version }}-dependencies-${{ matrix.dependencies }}
restore-keys: php-${{ matrix.php-version }}

- name: Install dependencies with composer
run: COMPOSER_ARGS="--prefer-stable ${{ matrix.dependencies }}" make

- name: Run tests
run: make test

coverage:
name: Tests Coverage
runs-on: ubuntu-20.04
strategy:
matrix:
php-version: [7.4]

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

- name: Install dependencies
run: sudo apt install php${{ matrix.php-version }}-snmp python3-pip snmp

- name: Install snmpsim
run: sudo pip3 install snmpsim

- name: Cache dependencies installed with composer
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: php-${{ matrix.php-version }}
restore-keys: php-${{ matrix.php-version }}

- name: Install dependencies with composer
run: COMPOSER_ARGS="--prefer-stable" make

- name: Run tests coverage
run: PHPUNIT_ARGS="--coverage-clover coverage/clover.xml" make test

- name: Report to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_RUN_LOCALLY: 1
run: vendor/bin/php-coveralls --coverage_clover coverage/clover.xml --json_path coverage/coveralls.json
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/coverage/
/vendor/

/.phpcs-cache
/.phpunit.result.cache
/composer.lock
/phpcs.xml
/phpstan.neon
/phpunit.xml
17 changes: 0 additions & 17 deletions .scrutinizer.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
COMPOSER_ARGS += --no-interaction --no-progress --no-suggest

.PHONY: build
build: vendor

.PHONY: vendor
vendor: vendor/lock

vendor/lock: composer.json
composer update $(COMPOSER_ARGS)
touch vendor/lock

.PHONY: test
test:
vendor/bin/phpunit $(PHPUNIT_ARGS)

.PHONY: cs
cs:
vendor/bin/phpcs $(PHPCS_ARGS)

.PHONY: fix
fix:
vendor/bin/phpcbf

.PHONY: static-analysis
static-analysis:
vendor/bin/phpstan analyse $(PHPSTAN_ARGS)

.PHONY: check
check: build cs static-analysis test

.PHONY: clean
clean: clean-vendor

.PHONY: clean-vendor
clean-vendor:
rm -rf vendor composer.lock
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PHP SNMP Client
===============

[![Build Status](https://github.com/simPod/PHP-SNMP/workflows/CI/badge.svg?branch=master)](https://github.com/simPod/PHP-SNMP/actions)
[![Packagist](https://poser.pugx.org/simpod/php-snmp/v/stable.svg)](https://packagist.org/packages/simpod/php-snmp)
[![Coverage Status](https://coveralls.io/repos/github/simPod/PHP-SNMP/badge.svg?branch=master)](https://coveralls.io/github/simPod/PHP-SNMP?branch=master)
40 changes: 28 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
{
"name": "simpod/php-snmp",
"description": "PHP Simple Network Management",
"description": "PHP library for connecting to the SNMP agents using various transports; includes small collection of OIDs",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Simon Podlipsky",
"email": "simon@podlipsky.net"
}
],
"keywords": [
"php",
"snmp"
Expand All @@ -17,14 +11,36 @@
"sort-packages": true
},
"require": {
"php": "^7.2",
"ext-snmp": "*",
"consistence/consistence": "^1.0|^2.0"
"php": "^7.3 || ^8.0",
"psr/log": "^1.1",
"roave/you-are-using-it-wrong": "^1.4"
},
"suggest": {
"ext-json": "Required for SNMP transport \"Api\"",
"psr/http-client": "Required for SNMP transport \"Api\"",
"psr/http-factory": "Required for SNMP transport \"Api\"",
"symfony/process": "Required for default implementation of SNMP transport \"Cli\"",
"ext-snmp": "Required for SNMP transport \"Extension\""
},
"require-dev": {
"ext-json": "*",
"ext-snmp": "*",
"cdn77/coding-standard": "^3.0",
"phpstan/phpstan": "^0.11.5",
"phpstan/phpstan-strict-rules": "^0.11.0"
"nyholm/psr7": "^1.3",
"php-http/curl-client": "^2.1",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12.25",
"phpstan/phpstan-deprecation-rules": "^0.12.3",
"phpstan/phpstan-phpunit": "^0.12.8",
"phpstan/phpstan-strict-rules": "^0.12.2",
"phpunit/phpunit": "^9.1",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"simpod/php-coveralls-mirror": "^3.0",
"squizlabs/php_codesniffer": "^3.5",
"symfony/process": "^4.3",
"thecodingmachine/phpstan-safe-rule": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down
10 changes: 4 additions & 6 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
parameters:
memory-limit: -1
level: max
paths:
- %currentWorkingDirectory%/src
- %currentWorkingDirectory%/tests

includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
ignoreErrors:
# extension is badly designed, we know these types won't ever be here
- '~Parameter #1 \$output of method SimPod\\PhpSnmp\\Transport\\ExtensionSnmpClient::processOutput\(\) expects array<string, string>, array\|string\|false given\.~'
- '~Parameter #1 \$output of method SimPod\\PhpSnmp\\Transport\\ExtensionSnmpClient::processOutput\(\) expects array<string, string>, array\|false given\.~'
17 changes: 3 additions & 14 deletions phpunit.xml → phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.0/phpunit.xsd"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
executionOrder="random"
colors="true"
bootstrap="tests/bootstrap.php"
>
Expand All @@ -15,18 +14,8 @@
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<logging>
<log
showOnlySummary="true"
showUncoveredFiles="true"
target="php://stdout"
type="coverage-text"
/>
<log type="coverage-clover" target="temp/clover.xml"/>
<log type="coverage-html" target="temp/coverage-html"/>
</logging>
</phpunit>
16 changes: 16 additions & 0 deletions src/Exception/CannotParseUnknownValueType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace SimPod\PhpSnmp\Exception;

use RuntimeException;
use function Safe\sprintf;

final class CannotParseUnknownValueType extends RuntimeException implements SnmpException
{
public static function new(string $type) : self
{
return new self(sprintf('Encountered unknown value type "%s"', $type));
}
}

0 comments on commit bfdf02c

Please sign in to comment.