Skip to content
This repository was archived by the owner on May 18, 2024. It is now read-only.

Commit 29c6e84

Browse files
authored
Merge pull request #66 from MGatner/tools
Development Tools
2 parents 156fe4b + 178cb75 commit 29c6e84

17 files changed

+6825
-1275
lines changed

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/.github export-ignore
2+
/docs export-ignore
3+
/examples export-ignore
4+
/tests export-ignore
5+
/.editorconfig export-ignore
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/phpstan.neon.dist export-ignore
10+
11+
# Configure diff output for .php and .phar files.
12+
*.php diff=php
13+
*.phar -diff

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: composer
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10
8+
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
interval: daily

.github/workflows/analyze.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# When a PR is opened or a push is made, perform
2+
# a static analysis check on the code using PHPStan.
3+
name: PHPStan
4+
5+
on:
6+
pull_request:
7+
branches:
8+
- 'develop'
9+
paths:
10+
- 'app/**'
11+
- 'tests/**'
12+
- 'composer.**'
13+
- 'phpstan*'
14+
- '.github/workflows/analyze.yml'
15+
push:
16+
branches:
17+
- 'develop'
18+
paths:
19+
- 'app/**'
20+
- 'tests/**'
21+
- 'composer.**'
22+
- 'phpstan*'
23+
- '.github/workflows/analyze.yml'
24+
25+
jobs:
26+
build:
27+
name: PHP ${{ matrix.php-versions }} Static Analysis
28+
runs-on: ubuntu-latest
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
php-versions: ['7.3', '7.4', '8.0']
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v2
36+
37+
- name: Setup PHP
38+
uses: shivammathur/setup-php@v2
39+
with:
40+
php-version: ${{ matrix.php-versions }}
41+
tools: composer, pecl, phpunit
42+
extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3
43+
44+
- name: Get composer cache directory
45+
id: composer-cache
46+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
47+
48+
- name: Create composer cache directory
49+
run: mkdir -p ${{ steps.composer-cache.outputs.dir }}
50+
51+
- name: Cache composer dependencies
52+
uses: actions/cache@v2
53+
with:
54+
path: ${{ steps.composer-cache.outputs.dir }}
55+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
56+
restore-keys: ${{ runner.os }}-composer-
57+
58+
- name: Create PHPStan cache directory
59+
run: mkdir -p build/phpstan
60+
61+
- name: Cache PHPStan results
62+
uses: actions/cache@v2
63+
with:
64+
path: build/phpstan
65+
key: ${{ runner.os }}-phpstan-${{ github.sha }}
66+
restore-keys: ${{ runner.os }}-phpstan-
67+
68+
- name: Install dependencies
69+
run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
70+
env:
71+
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
72+
73+
- name: Run static analysis
74+
run: vendor/bin/phpstan analyze

.github/workflows/test.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: PHPUnit
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
push:
8+
branches:
9+
- develop
10+
11+
jobs:
12+
main:
13+
name: PHP ${{ matrix.php-versions }} Unit Tests
14+
15+
strategy:
16+
matrix:
17+
php-versions: ['7.3', '7.4', '8.0']
18+
19+
runs-on: ubuntu-latest
20+
21+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v2
26+
27+
- name: Setup PHP, with composer and extensions
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
php-version: ${{ matrix.php-versions }}
31+
tools: composer, pecl, phpunit
32+
extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3
33+
coverage: xdebug
34+
35+
- name: Get composer cache directory
36+
id: composer-cache
37+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
38+
39+
- name: Cache composer dependencies
40+
uses: actions/cache@v2
41+
with:
42+
path: ${{ steps.composer-cache.outputs.dir }}
43+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
44+
restore-keys: ${{ runner.os }}-composer-
45+
46+
- name: Install dependencies
47+
run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
48+
env:
49+
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
50+
51+
- name: Enable Tachycardia
52+
run: echo "TACHYCARDIA_MONITOR_GA=enabled" >> $GITHUB_ENV
53+
54+
- name: Test with PHPUnit
55+
run: vendor/bin/phpunit --verbose --coverage-text
56+
env:
57+
TERM: xterm-256color
58+
59+
- if: matrix.php-versions == '8.0'
60+
name: Mutate with Infection
61+
run: |
62+
composer global require infection/infection
63+
git fetch --depth=1 origin $GITHUB_BASE_REF
64+
infection --threads=2 --skip-initial-tests --coverage=build/phpunit --git-diff-base=origin/$GITHUB_BASE_REF --git-diff-filter=AM --logger-github --ignore-msi-with-no-mutations
65+
66+
- if: matrix.php-versions == '8.0'
67+
name: Run Coveralls
68+
run: vendor/bin/php-coveralls --verbose --coverage_clover=build/phpunit/clover.xml --json_path build/phpunit/coveralls-upload.json
69+
env:
70+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
COVERALLS_PARALLEL: true
72+
COVERALLS_FLAG_NAME: PHP ${{ matrix.php-versions }}
73+
74+
coveralls:
75+
needs: [main]
76+
name: Coveralls Finished
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Upload Coveralls results
80+
uses: coverallsapp/github-action@master
81+
with:
82+
github-token: ${{ secrets.GITHUB_TOKEN }}
83+
parallel-finished: true

.gitignore

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ $RECYCLE.BIN/
4141
#-------------------------
4242
# These should never be under version control,
4343
# as it poses a security risk.
44-
.env*
44+
.env
4545
.vagrant
4646
Vagrantfile
4747

@@ -51,6 +51,9 @@ Vagrantfile
5151
writable/cache/*
5252
!writable/cache/index.html
5353

54+
writable/files/*
55+
!writable/files/index.html
56+
5457
writable/logs/*
5558
!writable/logs/index.html
5659

@@ -62,28 +65,27 @@ writable/uploads/*
6265

6366
writable/debugbar/*
6467

65-
php_errors.log
68+
writable/database.db
6669

67-
#-------------------------
68-
# User Guide Temp Files
69-
#-------------------------
70-
user_guide_src/build/*
71-
user_guide_src/cilexer/build/*
72-
user_guide_src/cilexer/dist/*
73-
user_guide_src/cilexer/pycilexer.egg-info/*
70+
php_errors.log
71+
public/error_log
7472

7573
#-------------------------
7674
# Test Files
7775
#-------------------------
7876
tests/coverage*
79-
80-
# Don't save phpunit under version control.
77+
results/
78+
build/
79+
phpunit*.xml
8180
phpunit
81+
.phpunit*.cache
82+
app/Commands/Test.php
8283

8384
#-------------------------
8485
# Composer
8586
#-------------------------
8687
vendor/
88+
public/assets/vendor/
8789

8890
#-------------------------
8991
# IDE / Development Files
@@ -121,5 +123,19 @@ nb-configuration.xml
121123
# Visual Studio Code
122124
.vscode/
123125

124-
/results/
125-
/phpunit*.xml
126+
#-------------------------
127+
# Local & Sensitive Files
128+
#-------------------------
129+
130+
/access
131+
/local
132+
/public/local
133+
134+
#-------------------------
135+
# Supplemental Content
136+
#-------------------------
137+
138+
/public/data/*
139+
/public/userguide
140+
/public/user?guide?/*
141+
!/public/*/readme.rst

app/Controllers/BaseController.php

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
use App\Libraries\GitHubHelper;
66
use CodeIgniter\Controller;
7+
use CodeIgniter\HTTP\Exceptions\HTTPException;
78
use CodeIgniter\HTTP\RequestInterface;
89
use CodeIgniter\HTTP\ResponseInterface;
910
use CodeIgniter\HTTP\Response;
11+
use Config\App;
1012
use Config\Services;
1113
use Psr\Log\LoggerInterface;
1214

@@ -23,9 +25,34 @@
2325

2426
class BaseController extends Controller
2527
{
28+
/**
29+
* @var App
30+
*/
31+
protected $config;
32+
33+
/**
34+
* @var array
35+
*/
36+
protected $errors;
37+
38+
/**
39+
* Parameters for view components
40+
*
41+
* @var array
42+
*/
43+
protected $data = [];
2644

27-
protected $data = []; // parameters for view components
28-
protected $id; // identifier for our content
45+
/**
46+
* Identifier for our content
47+
*
48+
* @var mixed
49+
*/
50+
protected $id;
51+
52+
/**
53+
* @var string|null
54+
*/
55+
protected $realUrl;
2956

3057
/**
3158
* An array of helpers to be loaded automatically upon
@@ -57,13 +84,19 @@ public function __construct()
5784
* Renders this page
5885
*
5986
* @param string $view The view file to render
60-
*
61-
* @return string
6287
*/
6388
protected function render(string $view)
6489
{
6590
// URL without the locale
66-
$this->realUrl = trim('/' . $this->request->uri->getSegment(2) . '/' . $this->request->uri->getSegment(3), '/ ');
91+
try
92+
{
93+
$this->realUrl = trim('/' . $this->request->uri->getSegment(2) . '/' . $this->request->uri->getSegment(3), '/ ');
94+
}
95+
catch (HTTPException $e)
96+
{
97+
$this->realUrl = null;
98+
}
99+
67100
if (empty($this->realUrl))
68101
$this->realUrl = 'home';
69102

@@ -91,7 +124,7 @@ protected function render(string $view)
91124
/**
92125
* Builds the localized top & bottom navbars
93126
*/
94-
private function buildNavbars()
127+
private function buildNavbars(): void
95128
{
96129
// Massage the menubar
97130
$choices = $this->config->menuChoices;

app/Controllers/Home.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function index()
2828
? 'https://github.com/codeigniter4/framework/releases/'
2929
: 'https://github.com/codeigniter4/framework/archive/' . $this->data['v4name'] . '.zip',
3030
'label' => lang('Home.block1Title'),
31-
'text' => lang('Home.block1Desc') . $this->data['v4name'] ?? ''],
31+
'text' => lang('Home.block1Desc') . ($this->data['v4name'] ?? '')],
3232
['icon' => 'book',
3333
'link' => '/user_guide/index.html',
3434
'label' => lang('Home.block2Title'),

app/Libraries/GitHubHelper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ public function fillHeroes(array $data): array
113113
}
114114

115115
/**
116-
* build the hit parade for this group of contributors
116+
* Build the hit parade for this group of contributors.
117117
*
118-
* @param $info
118+
* @param array $info
119119
*
120120
* @return string
121121
*/
122-
protected function hitparade($info)
122+
protected function hitparade(array $info)
123123
{
124124
$heros = [];
125125
if ( ! empty($info))
@@ -142,7 +142,7 @@ protected function hitparade($info)
142142
/**
143143
* determine how many stars a contributor earns
144144
*
145-
* @param $contributions
145+
* @param int $contributions
146146
*
147147
* @return string
148148
*/

0 commit comments

Comments
 (0)