Skip to content

Commit b098676

Browse files
authored
Merge pull request #12 from dotkernel/issue-8
Issue #8: Implemented CI
2 parents 5c5d105 + 033c200 commit b098676

12 files changed

Lines changed: 187 additions & 14 deletions

.github/workflows/codecov.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
on:
2+
- push
3+
4+
name: Run Codecov checks
5+
6+
jobs:
7+
code-coverage:
8+
name: Code Coverage
9+
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
matrix:
14+
os:
15+
- ubuntu-latest
16+
17+
php:
18+
- "8.3"
19+
- "8.4"
20+
- "8.5"
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v6
25+
26+
- name: Install PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: "${{ matrix.php }}"
30+
coverage: pcov
31+
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
32+
tools: composer:v2, cs2pr
33+
34+
- name: Determine composer cache directory
35+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
36+
37+
- name: Cache dependencies installed with composer
38+
uses: actions/cache@v5
39+
with:
40+
path: ${{ env.COMPOSER_CACHE_DIR }}
41+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
42+
restore-keys: |
43+
php${{ matrix.php }}-composer-
44+
45+
- name: Install dependencies with composer
46+
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
47+
48+
- name: Collect code coverage with PHPUnit
49+
run: vendor/bin/phpunit --colors=always --coverage-clover clover.xml
50+
51+
- name: Send code coverage report to Codecov.io
52+
uses: codecov/codecov-action@v5
53+
with:
54+
token: ${{ secrets.CODECOV_TOKEN }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: "Continuous Integration"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
tags:
8+
9+
jobs:
10+
ci:
11+
uses: laminas/workflow-continuous-integration/.github/workflows/continuous-integration.yml@1.x
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
on:
2+
- push
3+
4+
name: Run PHPStan checks
5+
6+
jobs:
7+
mutation:
8+
name: PHPStan ${{ matrix.php }}-${{ matrix.os }}
9+
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
matrix:
14+
os:
15+
- ubuntu-latest
16+
17+
php:
18+
- "8.3"
19+
- "8.4"
20+
- "8.5"
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v6
25+
26+
- name: Install PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: "${{ matrix.php }}"
30+
coverage: pcov
31+
ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
32+
tools: composer:v2, cs2pr
33+
34+
- name: Determine composer cache directory
35+
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
36+
37+
- name: Cache dependencies installed with composer
38+
uses: actions/cache@v5
39+
with:
40+
path: ${{ env.COMPOSER_CACHE_DIR }}
41+
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
42+
restore-keys: |
43+
php${{ matrix.php }}-composer-
44+
45+
- name: Install dependencies with composer
46+
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
47+
48+
- name: Run static analysis with PHPStan
49+
run: vendor/bin/phpstan analyse

.laminas-ci.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"backwardCompatibilityCheck": true
3+
}

LICENSE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Dotkernel (https://www.dotkernel.com)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
Dotkernel's TOTP authentication.
44

5+
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-totp)
6+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-totp/1.0.0)
7+
8+
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-totp)](https://github.com/dotkernel/dot-totp/issues)
9+
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-totp)](https://github.com/dotkernel/dot-totp/network)
10+
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-totp)](https://github.com/dotkernel/dot-totp/stargazers)
11+
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-totp)](https://github.com/dotkernel/dot-totp/blob/1.0/LICENSE.md)
12+
13+
[![Build Static](https://github.com/dotkernel/dot-totp/actions/workflows/continuous-integration.yml/badge.svg?branch=1.0)](https://github.com/dotkernel/dot-totp/actions/workflows/continuous-integration.yml)
14+
[![codecov](https://codecov.io/gh/dotkernel/dot-totp/graph/badge.svg?token=R5PopWHvRu)](https://codecov.io/gh/dotkernel/dot-totp)
15+
[![PHPStan](https://github.com/dotkernel/dot-totp/actions/workflows/static-analysis.yml/badge.svg?branch=1.0)](https://github.com/dotkernel/dot-totp/actions/workflows/static-analysis.yml)
16+
517
## Install
618

719
You can install dot-totp by running the following command:
@@ -15,7 +27,6 @@ composer require dotkernel/dot-totp
1527
> **Note:** These instructions are written in the style of Mezzio middleware configuration and assume the use of Doctrine ORM.
1628
> They can be adapted to any database layer or configuration style. If you are using a different framework or service container, follow the same logical steps while adjusting the syntax and configuration to match your environment.
1729
18-
1930
Create a new file configuration `config/autoload/totp.global.php`.
2031

2132
```php
@@ -85,6 +96,7 @@ trait TotpTrait
8596
To enable TOTP, generate a temporary secret and encode it into a QR code, which the user scans with an authenticator app (e.g., Google Authenticator, Authy). The user then confirms by providing a one-time code from the app.
8697

8798
**Steps:**
99+
88100
1. Generate a temporary Base32 secret.
89101
2. Build a provisioning URI with a label and issuer.
90102
3. Render the URI as a QR code.

SECURITY.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported | PHP Version |
6+
|---------|--------------------|----------------------------------------------------------------------------------------------------------|
7+
| 1.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-totp/1.0.0) |
8+
9+
## Reporting Potential Security Issues
10+
11+
If you have encountered a potential security vulnerability in this project, please report it to us at <security@dotkernel.com>.
12+
We will work with you to verify the vulnerability and patch it.
13+
14+
When reporting issues, please provide the following information:
15+
16+
- Component(s) affected
17+
- A description indicating how to reproduce the issue
18+
- A summary of the security vulnerability and impact
19+
20+
We request that you contact us via the email address above and give the project contributors a chance to resolve the vulnerability and issue a new release prior to any public exposure;
21+
this helps protect the project's users and provides them with a chance to upgrade and/or update to protect their applications.
22+
23+
## Policy
24+
25+
If we verify a reported security vulnerability, our policy is:
26+
27+
- We will patch the current release branch, as well as the immediate prior minor release branch.
28+
- After patching the release branches, we will immediately issue new security fix releases for each patched release branch.

composer.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
2323
},
2424

2525
"require": {
26-
"php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
27-
"endroid/qr-code": "^6.0.9"
26+
"php": "~8.3.0 || ~8.4.0 || ~8.5.0",
27+
"endroid/qr-code": "^6.0.9",
28+
"psr/container": "^1.1 || ^2.0.0"
2829
},
2930
"require-dev": {
3031
"phpunit/phpunit": "^10.2",
31-
"vimeo/psalm": "^6.14.3",
32+
"phpstan/phpstan": "^2.1.33",
33+
"phpstan/phpstan-phpunit": "^2.0.10",
3234
"laminas/laminas-coding-standard": "^2.5"
3335
},
3436
"autoload": {
@@ -44,12 +46,12 @@
4446
"scripts": {
4547
"check": [
4648
"@cs-check",
47-
"@test"
49+
"@test",
50+
"@static-analysis"
4851
],
4952
"cs-check": "phpcs",
5053
"cs-fix": "phpcbf",
51-
"test": "phpunit --colors=always",
52-
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
53-
"static-analysis": "psalm --shepherd --stats"
54+
"static-analysis": "phpstan analyse --memory-limit 1G",
55+
"test": "phpunit --colors=always"
5456
}
5557
}

phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
includes:
2+
- vendor/phpstan/phpstan-phpunit/extension.neon
3+
parameters:
4+
level: 5
5+
paths:
6+
- src
7+
- test
8+
treatPhpDocTypesAsCertain: false

test/ConfigProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Dot\test;
5+
namespace DotTest\Totp;
66

77
use Dot\Totp\ConfigProvider;
88
use Dot\Totp\Totp;

0 commit comments

Comments
 (0)