Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Ignore all test and documentation for archive
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.scrutinizer.yml export-ignore
/.travis.yml export-ignore
/.editorconfig export-ignore
/codecov.yml export-ignore
/.remarkrc export-ignore
/.remarkignore export-ignore
/behat.yml export-ignore
/phpunit.xml.dist export-ignore
/phpcs.xml.dist export-ignore
/CODE_OF_CONDUCT.md export-ignore
/CONTRIBUTING.md export-ignore
/Makefile export-ignore
/tests export-ignore
/features export-ignore
/docs export-ignore
195 changes: 147 additions & 48 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,119 +1,218 @@
name: 'CI'
on: # rebuild any PRs and main branch changes
on: # Build any PRs and main branch changes
workflow_dispatch: # Allows to run the workflow manually from the Actions tab
pull_request:
types:
- opened
- edited
- synchronize
push:
branches: [ master ]
schedule:
- cron: '0 0 1 * *' # Every month

concurrency:
group: "CI-${{ github.head_ref }}"
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}"
cancel-in-progress: true

env:
# Cache params
CACHE_VERSION: 2022031803 # To be able to create a new cache (YYYYMMDDXX)
CI: 'true'
COVERAGE_OUTPUT_STYLE: clover
TEST_OUTPUT_STYLE: 'pretty'
PHPCS_REPORT_STYLE: 'full'
COMPOSER_OPTIONS: '--optimize-autoloader'
TEST_OUTPUT_STYLE: pretty
COMPOSER_OPTIONS: --optimize-autoloader
CODACY_CACHE_PATH: ~/.cache/codacy
CODACY_BIN: ~/.cache/codacy/codacy.sh

jobs:
unit-tests:
name: Unit / PHP ${{ matrix.php-version }}
tests:
name: UTs & FTs - PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest
env:
COVERAGE_TYPE: none
strategy:
fail-fast: true
max-parallel: 4
matrix:
php-version:
- '7.4'
- '8.0'
- '8.1'
include:
# Bare minimum => Lowest versions allowed by composer config
- php-version: '8.0'
composer-flag: --prefer-lowest
# Up to date versions => Latest versions allowed by composer config
- php-version: '8.2'
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Enable coverage
if: ${{ matrix.php-version == '8.2' }}
run: |
echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV
echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV

- name: Setup PHP
- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php-version }}'
tools: composer
coverage: xdebug
coverage: ${{ env.COVERAGE_TYPE }}
env:
# Always use latest available patch for the version
update: true

- name: Setup cache
id: cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.composer
./vendor
${{ env.CODACY_CACHE_PATH }}
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}
key: tests-${{ matrix.php-version }}-${{ matrix.composer-flag }}-${{ hashFiles('composer.json') }}

- name: Download codacy binary
if: steps.cache.outputs.cache-hit != 'true'
run: |
mkdir -p ${{ env.CODACY_CACHE_PATH }} \
&& curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \
&& chmod +x ${{ env.CODACY_BIN }} \
&& ${{ env.CODACY_BIN }} download

- name: Build
run: make build
run: |
make build

- name: Test
run: make test-unit
- name: Tests
run: make test-unit && make test-functional

# Upload to codacy first as codecov action always remove coverage files despite move_coverage_to_trash at false
# And only if it's not a PR from a fork => Can't work as codacy secret is not accessible in that context
- name: Upload coverages to Codacy
if: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/php-jsonrpc-server-doc-sdk') && env.COVERAGE_TYPE == 'xdebug' }}
run: ${{ env.CODACY_BIN }} report -r build/coverage-phpunit/unit.clover -r build/coverage-behat/clover.xml -r build/coverage-phpunit/functional.clover -t ${{ secrets.CODACY_PROJECT_TOKEN }} --partial

# See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk
- name: Upload coverage to codecov
uses: codecov/codecov-action@v2
# See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-server-doc-sdk
- name: Upload unit tests coverage to codecov
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
uses: codecov/codecov-action@v3
with:
file: "build/coverage-phpunit/unit.clover"
name: "unit-tests-${{ matrix.php-version }}"
flags: "unit-tests,php-${{ matrix.php-version }}"
fail_ci_if_error: true
move_coverage_to_trash: false
verbose: ${{ runner.debug == '1' }}

- name: Upload functional tests coverage to codecov
if: ${{ env.COVERAGE_TYPE == 'xdebug' }}
uses: codecov/codecov-action@v3
with:
files: "build/coverage-behat/clover.xml,build/coverage-phpunit/functional.clover"
name: "functional-tests-${{ matrix.php-version }}"
flags: "functional-tests,php-${{ matrix.php-version }}"
fail_ci_if_error: true
move_coverage_to_trash: false
verbose: ${{ runner.debug == '1' }}

static-checks:
name: Static checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup PHP 8.2
uses: shivammathur/setup-php@v2
with:
php-version: 8.2 # Latest supported
tools: composer
coverage: none
env:
# Always use latest available patch for the version
update: true

- name: Setup cache
id: cache
uses: actions/cache@v3
with:
path: |
~/.composer
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
key: tests-${{ env.PHP_VERSION }}-${{ hashFiles('composer.json') }}

- name: Build
run: make build

- name: ComposerRequireChecker
uses: docker://webfactory/composer-require-checker:4.5.0

functional-tests:
name: Functional / PHP ${{ matrix.php-version }}
needs: [unit-tests]
- name: Dependencies check
if: ${{ github.event_name == 'pull_request' }}
uses: actions/dependency-review-action@v1

finalize-codacy-coverage-report:
runs-on: ubuntu-latest
name: Finalize Codacy coverage report
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'yoanm/php-jsonrpc-server-doc-sdk' }}
needs: [ tests ]
steps:
- name: Setup cache
id: cache
uses: actions/cache@v3
with:
path: |
${{ env.CODACY_CACHE_PATH }}
key: codacy-final

- name: Download codacy binary
if: steps.cache.outputs.cache-hit != 'true'
run: |
mkdir -p ${{ env.CODACY_CACHE_PATH }} \
&& curl -LN https://coverage.codacy.com/get.sh -o ${{ env.CODACY_BIN }} \
&& chmod +x ${{ env.CODACY_BIN }} \
&& ${{ env.CODACY_BIN }} download

- name: Finalize reporting
run: ${{ env.CODACY_BIN }} final -t ${{ secrets.CODACY_PROJECT_TOKEN }}

nightly-tests:
name: Nightly - PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest
env:
COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+'
continue-on-error: true
needs: [ static-checks, tests ]
strategy:
fail-fast: true
fail-fast: false
max-parallel: 4
matrix:
php-version:
- '7.4'
- '8.0'
- '8.1'
- '8.3' # Current php dev version

steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup PHP
- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php-version }}'
tools: composer
coverage: xdebug
coverage: none
env:
# Always use latest available patch for the version
update: true

- name: Setup cache
id: cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.composer
./vendor
# Clear the cache if composer json (as composer.lock is in the repo) has been updated
key: ${{ env.CACHE_VERSION }}-tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}
key: tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }}

- name: Build
run: make build
run: |
make build

- name: Test
run: make test-functional

# See the reports at https://codecov.io/gh/yoanm/php-jsonrpc-doc-sdk
- name: Upload coverage to codecov
uses: codecov/codecov-action@v2
with:
name: "functional-tests-${{ matrix.php-version }}"
flags: "functional-tests,php-${{ matrix.php-version }}"
fail_ci_if_error: true
run: make test-unit && make test-functional
1 change: 1 addition & 0 deletions .remarkignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor
6 changes: 6 additions & 0 deletions .remarkrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugins": [
"remark-preset-lint-consistent",
"remark-preset-lint-recommended"
]
}
Loading