Skip to content

Commit

Permalink
Apply CI4 dev toolkit
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed Oct 23, 2020
1 parent bd5a813 commit 8aeb14d
Show file tree
Hide file tree
Showing 9 changed files with 465 additions and 29 deletions.
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/.github export-ignore
/docs export-ignore
/examples export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml.dist export-ignore
/phpstan.neon.dist export-ignore

# Configure diff output for .php and .phar files.
*.php diff=php
*.phar -diff
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
68 changes: 68 additions & 0 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# When a PR is opened or a push is made, perform
# a static analysis check on the code using PHPStan.
name: PHPStan

on:
pull_request:
branches:
- 'develop'
paths:
- 'app/**'
- 'tests/**'
- 'phpstan*'
- '.github/workflows/analyze.yml'
push:
branches:
- 'develop'
paths:
- 'app/**'
- 'tests/**'
- 'phpstan*'
- '.github/workflows/analyze.yml'

jobs:
build:
name: Analyze code
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: latest
tools: composer, pecl, phpunit
extensions: intl, json, mbstring, mysqlnd, xdebug, xml, sqlite3

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

- name: Create composer cache directory
run: mkdir -p ${{ steps.composer-cache.outputs.dir }}

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

- name: Create PHPStan cache directory
run: mkdir -p build/phpstan

- name: Cache PHPStan results
uses: actions/cache@v2
with:
path: build/phpstan
key: ${{ runner.os }}-phpstan-${{ github.sha }}
restore-keys: ${{ runner.os }}-phpstan-

- name: Install dependencies
run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
# env:
# COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}

- name: Run static analysis
run: vendor/bin/phpstan analyze
17 changes: 10 additions & 7 deletions .github/workflows/phpunit.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: PHPUnit

on:
pull_request:
branches:
branches:
- develop
push:
branches:
- develop

jobs:
Expand All @@ -22,7 +25,7 @@ jobs:
uses: actions/checkout@v2

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@master
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer, pecl, phpunit
Expand All @@ -34,18 +37,18 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

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

- name: Install dependencies
run: composer install --no-progress --no-suggest --no-interaction --prefer-dist --optimize-autoloader
run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
# To prevent rate limiting you may need to supply an OAuth token in Settings > Secrets
# env:
# https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens
# COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}

- name: Test with phpunit
run: vendor/bin/phpunit --coverage-text
- name: Test with PHPUnit
run: vendor/bin/phpunit --verbose --coverage-text
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,5 @@ nb-configuration.xml

/results/
/phpunit*.xml
/.phpunit.*.cache
/*.cache

16 changes: 9 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "codeigniter4/appstarter",
"name": "codeigniter4projects/website",
"type": "project",
"description": "CodeIgniter4 starter app",
"description": "CodeIgniter Website",
"homepage": "https://codeigniter.com",
"license": "MIT",
"require": {
Expand All @@ -11,19 +11,21 @@
"league/commonmark": "^1.5"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
"phpstan/phpstan": "^0.12",
"fzaninotto/faker": "^1.9@dev",
"mikey179/vfsstream": "1.6.*",
"phpunit/phpunit": "^8.5"
"mikey179/vfsstream": "^1.6",
"codeigniter4/codeigniter4-standard": "^1.0",
"squizlabs/php_codesniffer": "^3.5"
},
"autoload-dev": {
"psr-4": {
"Tests\\Support\\": "tests/_support"
}
},
"scripts": {
"post-update-cmd": [
"@composer dump-autoload"
],
"analyze": "phpstan analyze",
"style": "phpcbf --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 src/ tests/",
"test": "phpunit"
},
"support": {
Expand Down
Loading

0 comments on commit 8aeb14d

Please sign in to comment.