Skip to content

Commit

Permalink
Merge pull request #132 from alps-asd/github
Browse files Browse the repository at this point in the history
Add GH template and update CI
  • Loading branch information
koriym committed Nov 25, 2021
2 parents 599f57c + f02c4f6 commit 6fd3014
Show file tree
Hide file tree
Showing 14 changed files with 282 additions and 197 deletions.
34 changes: 34 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# CONTRIBUTING

## Code Contributions

## Installation

Install project dependencies and test tools by running the following commands.

```bash
$ composer install
```

## Running tests

```bash
$ composer test
```
```bash
$ composer coverage // xdebug
$ composer pcov // pcov
```

Add tests for your new code ensuring that you have 100% code coverage.
In rare cases, code may be excluded from test coverage using `@codeCoverageIgnore`.

## Sending a pull request

To ensure your PHP code changes pass the CI checks, make sure to run all the same checks before submitting a PR.

```bash
$ composer tests
```

When you make a pull request, the tests will automatically be run again by GH action on multiple php versions.
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Bug Report
about: Create a bug report
labels: Bug
---

### Bug Report

<!-- Provide a summary describing the problem you are experiencing. -->

### How to reproduce

<!--- Describe exactly how to reproduce the problem, using a minimal test-case or working code sample. -->

7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: Feature
about: Suggest a new feature or enhancement
labels: Feature
---

<!-- Write your suggestion here. -->
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: Question
about: Ask a question regarding software usage
labels: Support
---

<!-- Write your question here. -->
6 changes: 6 additions & 0 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Reporting a vulnerability

If you have found any issues that might have security implications,
please send a report privately to akihito.koriyama@gmail.com

Do not report security reports publicly.
43 changes: 20 additions & 23 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@
name: "Coding Standards"
name: Coding Standards

on:
["pull_request", "push", "workflow_dispatch"]
push:
pull_request:
workflow_dispatch:

jobs:
coding-standards:
name: "Coding Standards"
name: Coding Standards
runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- "7.4"

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

- name: "Setup PHP ${{ matrix.php-version }}"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: phpcs, cs2pr
php-version: 8.0
tools: cs2pr
coverage: none

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

- name: "Cache composer dependencies"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: "${{ steps.composer-cache.outputs.dir }}"
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: "Install dependencies with Composer"
run: |
composer install --no-interaction --no-progress --prefer-dist
composer global require --dev doctrine/coding-standard ^8.1
- name: Install dependencies
run: composer install --no-interaction --no-progress --prefer-dist

- name: Validate composer.json
run: composer validate --strict

- name: "Run PHP_CodeSniffer"
run: "phpcs --standard=./phpcs.xml --report=checkstyle -q src tests | cs2pr"
- name: Run PHP_CodeSniffer
run: ./vendor/bin/phpcs -q --no-colors --report=checkstyle src tests | cs2pr
73 changes: 40 additions & 33 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,66 @@
name: "Continuous Integration"
name: Continuous Integration

on:
["pull_request", "push", "workflow_dispatch"]
push:
pull_request:
workflow_dispatch:

jobs:
phpunit:
name: "PHPUnit"
name: PHPUnit
runs-on: ubuntu-latest

strategy:
matrix:
operating-system:
- ubuntu-latest
php-version:
- "7.3"
- "7.4"
- "8.0"
- "8.1"
deps:
- "normal"
include:
- deps: "low"
php-version: "7.4"

- '7.3'
- '7.4'
- '8.0'
- '8.1'
dependencies:
- lowest
- highest
steps:
- name: "Checkout"
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v1

- name: "Setup PHP ${{ matrix.php-version }}"
- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}
coverage: pcov
ini-values: zend.assertions=1

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

- name: "Cache composer dependencies"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: "${{ steps.composer-cache.outputs.dir }}"
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: "Install dependencies with Composer"
run: "composer install --no-interaction --no-progress --prefer-dist"
- name: Install lowest dependencies
if: ${{ matrix.dependencies == 'lowest' }}
run: composer update --prefer-lowest --no-interaction --no-progress

- name: "Update lowest dependencies with Composer"
run: "composer update --prefer-dist --prefer-lowest"
if: "${{ matrix.deps == 'low' }}"
- name: Install highest dependencies
if: ${{ matrix.dependencies == 'highest' }}
run: composer update --no-interaction --no-progress

- name: "Run PHPUnit"
run: "./vendor/bin/phpunit"
- name: Run test suite
run: ./vendor/bin/phpunit --coverage-clover=coverage.xml

- name: Upload coverage report
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml

- name: "Run demo (JSON)"
run: "bin/asd docs/blog/profile.json && bin/asd docs/todomvc/profile.json && bin/asd --and-tag=a,b --or-tag=c --color=red docs/blog/profile.json"
- name: Run demo (JSON)
run: bin/asd docs/blog/profile.json && bin/asd docs/todomvc/profile.json && bin/asd --and-tag=a,b --or-tag=c --color=red docs/blog/profile.json

- name: "Run demo (XML)"
run: "bin/asd docs/blog/profile.xml"
- name: Run demo (XML)
run: bin/asd docs/blog/profile.xml
Loading

0 comments on commit 6fd3014

Please sign in to comment.