Skip to content

Commit

Permalink
Move to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
sidz committed Jan 19, 2021
1 parent adaf9dd commit fb778d3
Show file tree
Hide file tree
Showing 14 changed files with 233 additions and 104 deletions.
16 changes: 16 additions & 0 deletions .gitattributes
@@ -0,0 +1,16 @@
*.php text eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary

# Directories and files we do not want to distribute
/.* export-ignore
/build/ export-ignore
/docs/ export-ignore
/infection.json.dist export-ignore
/tests/ export-ignore
/phpstan-baseline.neon export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml export-ignore
/psalm-baseline.xml export-ignore
65 changes: 65 additions & 0 deletions .github/workflows/ci.yaml
@@ -0,0 +1,65 @@
# yamllint disable rule:line-length
# yamllint disable rule:braces

name: Tests

on:
pull_request:
push:
branches:
- main
- master

jobs:
tests:
runs-on: ubuntu-latest

strategy:
matrix:
operating-system: [ubuntu-latest]
php-version: ['7.3']
coverage-driver: [pcov]

name: CI with PHP ${{ matrix.php-version }}, using ${{ matrix.coverage-driver }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: ${{ matrix.coverage-driver }}
tools: composer:v1

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-
- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist

- name: Run tests and generate coverage
run: make test-unit

- name: Run E2E tests
env:
TERM: xterm-256color
run: make test-e2e

- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: vendor/bin/php-coveralls
55 changes: 55 additions & 0 deletions .github/workflows/cs.yaml
@@ -0,0 +1,55 @@
# yamllint disable rule:line-length
# yamllint disable rule:braces

name: Coding Standards

on:
pull_request:
push:
branches:
- main
- master

jobs:
coding-standards:
runs-on: ubuntu-latest

strategy:
matrix:
operating-system: [ubuntu-latest]
php-version: ['7.3']
check: ['cs', 'static-analyze']

name: Coding Standards on PHP ${{ matrix.php-version }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v1

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-
- name: Install dependencies
run: |
composer install --no-interaction --no-progress --prefer-dist
- name: Run ${{ matrix.check }}
run: make ${{ matrix.check }}
55 changes: 55 additions & 0 deletions .github/workflows/mt.yaml
@@ -0,0 +1,55 @@
# yamllint disable rule:line-length
# yamllint disable rule:braces

name: Mutation Testing

on:
pull_request:
push:
branches:
- main
- master

jobs:
mutation-testing:
runs-on: ubuntu-latest

strategy:
matrix:
operating-system: [ubuntu-latest]
php-version: ['7.3']
coverage-driver: [pcov]

name: Mutation testing with PHP ${{ matrix.php-version }}, using ${{ matrix.coverage-driver }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: ${{ matrix.coverage-driver }}
tools: composer:v1

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-${{ matrix.dependencies }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-
- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist

- name: Run Infection
run: make infection
4 changes: 2 additions & 2 deletions .gitignore
Expand Up @@ -2,6 +2,6 @@
/.composer/
/.idea
/.php_cs.cache
/vendor/
/infection.log
/build/
/infection.log
/vendor/
5 changes: 0 additions & 5 deletions .prettyci.composer.json

This file was deleted.

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

This file was deleted.

77 changes: 31 additions & 46 deletions Makefile
Expand Up @@ -2,17 +2,13 @@

# Use any most recent PHP version
PHP=$(shell which php)
PHPDBG=php

# Default parallelism
JOBS=$(shell nproc)

# Default silencer if installed
SILENT=$(shell which chronic)

# PHP CS Fixer
PHP_CS_FIXER=vendor/bin/php-cs-fixer
PHP_CS_FIXER_ARGS=--cache-file=build/cache/.php_cs.cache --verbose
PHP_CS_FIXER_ARGS=--diff --diff-format=udiff --verbose
export PHP_CS_FIXER_IGNORE_ENV=1

# PHPUnit
Expand All @@ -33,39 +29,32 @@ COMPOSER=$(PHP) $(shell which composer)

# Infection
INFECTION=vendor/bin/infection
MIN_MSI=76
MIN_COVERED_MSI=98
INFECTION_ARGS=--min-msi=$(MIN_MSI) --min-covered-msi=$(MIN_COVERED_MSI) --threads=$(JOBS) --log-verbosity=default --show-mutations
MIN_MSI=52.212389380531
MIN_COVERED_MSI=95
INFECTION_ARGS=--min-msi=$(MIN_MSI) --min-covered-msi=$(MIN_COVERED_MSI) --threads=$(JOBS) --log-verbosity=none --no-interaction --no-progress

all: test

##############################################################
# Continuous Integration #
##############################################################

ci-test: SILENT=
ci-test: prerequisites
$(SILENT) $(PHPDBG) $(PHPUNIT) $(PHPUNIT_COVERAGE_CLOVER)
tests/e2e_tests
cs:
$(PHP_CS_FIXER) fix $(PHP_CS_FIXER_ARGS) --dry-run
LC_ALL=C sort -c -u .gitignore

ci-analyze: SILENT=
ci-analyze: prerequisites ci-cs ci-infection ci-phpstan ci-psalm
phpstan:
$(PHPSTAN) $(PHPSTAN_ARGS) --no-progress

ci-phpunit: ci-cs
$(SILENT) $(PHPDBG) $(PHPUNIT) $(PHPUNIT_ARGS)
cp build/logs/junit.xml build/logs/phpunit.junit.xml
psalm:
$(PSALM) $(PSALM_ARGS) --no-cache --shepherd

ci-infection:
$(SILENT) $(PHP) $(INFECTION) $(INFECTION_ARGS)
static-analyze: phpstan psalm

ci-phpstan: ci-cs
$(SILENT) $(PHP) $(PHPSTAN) $(PHPSTAN_ARGS) --no-progress
test-unit:
$(PHPUNIT) $(PHPUNIT_ARGS)

ci-psalm: ci-cs
$(SILENT) $(PHP) $(PSALM) $(PSALM_ARGS) --no-cache --shepherd
test-e2e:
tests/e2e_tests

ci-cs: prerequisites
$(SILENT) $(PHP) $(PHP_CS_FIXER) $(PHP_CS_FIXER_ARGS) --dry-run --stop-on-violation fix
infection:
$(INFECTION) $(INFECTION_ARGS)

##############################################################
# Development Workflow #
Expand All @@ -75,21 +64,21 @@ test: phpunit analyze composer-validate

.PHONY: composer-validate
composer-validate: test-prerequisites
$(SILENT) $(COMPOSER) validate --strict
$(COMPOSER) validate --strict

test-prerequisites: prerequisites composer.lock

phpunit: cs
$(SILENT) $(PHP) $(PHPUNIT) $(PHPUNIT_ARGS) --verbose
phpunit: cs-fix
$(PHPUNIT) $(PHPUNIT_ARGS) --verbose
cp build/logs/junit.xml build/logs/phpunit.junit.xml
$(SILENT) $(PHP) $(INFECTION) $(INFECTION_ARGS)
$(PHP) $(INFECTION) $(INFECTION_ARGS)

analyze: cs
$(SILENT) $(PHP) $(PHPSTAN) $(PHPSTAN_ARGS)
$(SILENT) $(PHP) $(PSALM) $(PSALM_ARGS)
analyze: cs-fix
$(PHPSTAN) $(PHPSTAN_ARGS)
$(PSALM) $(PSALM_ARGS)

cs: test-prerequisites
$(SILENT) $(PHP) $(PHP_CS_FIXER) $(PHP_CS_FIXER_ARGS) --diff fix
cs-fix: test-prerequisites
$(PHP_CS_FIXER) fix $(PHP_CS_FIXER_ARGS)
LC_ALL=C sort -u .gitignore -o .gitignore

##############################################################
Expand All @@ -98,21 +87,17 @@ cs: test-prerequisites

# We need both vendor/autoload.php and composer.lock being up to date
.PHONY: prerequisites
prerequisites: report-php-version build/cache vendor/autoload.php composer.lock infection.json.dist .phpstan.neon
prerequisites: build/cache vendor/autoload.php composer.lock infection.json.dist .phpstan.neon

# Do install if there's no 'vendor'
vendor/autoload.php:
$(SILENT) $(COMPOSER) install --prefer-dist
test -d vendor/infection/infection/src/StreamWrapper/ && rm -fr vendor/infection/infection/src/StreamWrapper/ && $(SILENT) $(COMPOSER) dump-autoload || true
$(COMPOSER) install --prefer-dist
test -d vendor/infection/infection/src/StreamWrapper/ && rm -fr vendor/infection/infection/src/StreamWrapper/ && $(COMPOSER) dump-autoload || true

# If composer.lock is older than `composer.json`, do update,
# and touch composer.lock because composer not always does that
composer.lock: composer.json
$(SILENT) $(COMPOSER) update && touch composer.lock
$(COMPOSER) update && touch composer.lock

build/cache:
mkdir -p build/cache

.PHONY: report-php-version
report-php-version:
# Using $(PHP)
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/infection/codeception-adapter.svg?branch=master)](https://travis-ci.org/infection/codeception-adapter)
[![Continuous Integration](https://github.com/infection/codeception-adapter/workflows/Continuous%20Integration/badge.svg)](https://github.com/infection/codeception-adapter)
[![Coverage Status](https://coveralls.io/repos/github/infection/codeception-adapter/badge.svg?branch=master)](https://coveralls.io/github/infection/codeception-adapter?branch=master)

# Codeception Test Framework Adapter for Infection
Expand Down

0 comments on commit fb778d3

Please sign in to comment.