Skip to content

Commit

Permalink
Merge pull request #178 from getopt-php/github-actions
Browse files Browse the repository at this point in the history
use github actions for CI and switch to code climate
  • Loading branch information
tflori authored Mar 24, 2022
2 parents 821d611 + 351ff45 commit c1888c0
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 72 deletions.
17 changes: 17 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "2"

checks:
method-complexity:
config:
threshold: 9

exclude_patterns:
- "docs/"
- "**/test/"
- "**/vendor/"

plugins:
phpcodesniffer:
enabled: true
config:
standard: "PSR2"
81 changes: 81 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
on: [push, pull_request]
jobs:
before:
runs-on: ubuntu-latest
steps:
- name: Prepare CodeClimate
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
wget https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 -qO ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
unit-tests:
needs: [before]
strategy:
matrix:
include:
- image: 'iras/php7-composer:1'
php_version: 7.1
- image: 'iras/php7-composer:2'
php_version: 7.2
- image: 'iras/php7-composer:3'
php_version: 7.3
- image: 'iras/php7-composer:4'
php_version: 7.4
- image: 'iras/php8-composer:0'
php_version: 8.0
name: PHP Unit Tests on PHP ${{ matrix.php_version }}
runs-on: ubuntu-latest
container: ${{ matrix.image }}
steps:
- name: Container Setup
run: |
apk add --no-cache tar openssl
mkdir coverage
wget https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 -qO /usr/bin/cc-test-reporter
chmod +x /usr/bin/cc-test-reporter
- name: Checkout
run: |
git init && git remote add origin https://github.com/${{ github.repository }}.git
git fetch origin ${{ github.sha }} && git reset --hard ${{ github.sha }}
- uses: actions/cache@v2
with:
path: /composer/cache
key: composer-cache-7.${{ matrix.MINOR_VERSION }}
- name: Install dependencies
run: composer install --no-interaction --ansi
- name: Execute tests
run: |
php -dzend_extension=xdebug.so -dxdebug.mode=coverage vendor/bin/phpunit \
-c phpunit.xml \
--coverage-clover=coverage/clover.xml \
--coverage-text \
--color=always
- name: Format Coverage
run: |
cc-test-reporter format-coverage -t clover -o coverage/cc-${{ matrix.php_version }}.json coverage/clover.xml
- name: Store Coverage Result
uses: actions/upload-artifact@v3
with:
name: coverage-results
path: coverage/

after:
needs: [unit-tests]
runs-on: ubuntu-latest
steps:
- name: Restore Coverage Result
uses: actions/download-artifact@v3
with:
name: coverage-results
path: coverage/
- name: Report Coverage
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
wget https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 -qO ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter sum-coverage coverage/cc-*.json -p 5 -o coverage/cc-total.json
./cc-test-reporter upload-coverage -i coverage/cc-total.json
48 changes: 0 additions & 48 deletions .gitlab-ci.yml

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# GetOpt.PHP

[![Build Status](https://gitlab.com/thflori/getopt-php/badges/master/pipeline.svg)](https://gitlab.com/thflori/getopt-php/-/pipelines?ref=master)
[![Coverage Status](https://coveralls.io/repos/github/getopt-php/getopt-php/badge.svg?branch=master)](https://coveralls.io/github/getopt-php/getopt-php?branch=master)
[![.github/workflows/push.yml](https://github.com/getopt-php/getopt-php/actions/workflows/push.yml/badge.svg)](https://github.com/getopt-php/getopt-php/actions/workflows/push.yml)
[![Test Coverage](https://api.codeclimate.com/v1/badges/2f0b9586f3f69d690647/test_coverage)](https://codeclimate.com/github/getopt-php/getopt-php/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/2f0b9586f3f69d690647/maintainability)](https://codeclimate.com/github/getopt-php/getopt-php/maintainability)
[![Latest Stable Version](https://poser.pugx.org/ulrichsg/getopt-php/v/stable.svg)](https://packagist.org/packages/ulrichsg/getopt-php)
[![Total Downloads](https://poser.pugx.org/ulrichsg/getopt-php/downloads.svg)](https://packagist.org/packages/ulrichsg/getopt-php)
[![License](https://poser.pugx.org/ulrichsg/getopt-php/license.svg)](https://packagist.org/packages/ulrichsg/getopt-php)
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
}
],
"require": {
"php": ">=7.1 || ^8.0",
"php": "^7.1 || ^8.0",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "*",
"squizlabs/php_codesniffer": "^3.5.8",
"limedeck/phpunit-detailed-printer": "*"
"tflori/phpunit-printer": "*",
"squizlabs/php_codesniffer": "^3.5.8"
},
"autoload": {
"psr-4": {
Expand Down
33 changes: 14 additions & 19 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
backupGlobals="true"
printerClass="LimeDeck\Testing\Printer"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage pathCoverage="false">
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<text outputFile="php://stdout" showUncoveredFiles="true" showOnlySummary="false"/>
</report>
</coverage>
<phpunit bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
backupGlobals="true"
printerClass="PhpUnitPrinter\TextPrinter">
<testsuites>
<testsuite name="basic">
<directory>test</directory>
</testsuite>
</testsuites>

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

0 comments on commit c1888c0

Please sign in to comment.