Skip to content

Commit

Permalink
♻️ codeclimate, CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bnomei committed Jul 22, 2024
1 parent c8a402c commit 042346a
Show file tree
Hide file tree
Showing 12 changed files with 231 additions and 127 deletions.
43 changes: 37 additions & 6 deletions .github/workflows/pest-tests.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,58 @@
name: Pest Tests

on: ['push', 'pull_request']
on: [ 'push', 'pull_request' ]

jobs:
test:
runs-on: ubuntu-latest
env:
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, redis, xdebug, mongodb

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.11.0
with:
mongodb-version: latest

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
key: extensions-${{ hashFiles('composer.lock') }}

- name: Cache extensions
uses: actions/cache@v4
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: composer:v2
coverage: xdebug

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}

- name: Install
run: composer install --no-interaction --prefer-dist --optimize-autoloader

- name: Run Tests
run: |
php tests/patch.php
./vendor/bin/pest --group=SetupPagesInSeparatePHPUnitRun
./vendor/bin/pest
- name: Test & publish code coverage
uses: paambaati/codeclimate-action@v8.0.0
with:
coverageCommand: composer coverage
coverageLocations: ${{github.workspace}}/tests/clover.xml:clover
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}

10 changes: 9 additions & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ jobs:
tools: composer:v2
coverage: none

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: composer-${{ hashFiles('composer.lock') }}

- name: Install
run: |
composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
run: |
php tests/patch.php
./vendor/bin/phpstan --error-format=github
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@

/build

/tests/clover.xml
/tests/kirby
/tests/logs
/tests/media
!/tests/content/*
/tests/site/accounts
/tests/site/cache
/tests/site/sessions
/tests/site/plugins/kirby3-sqlite-cachedriver
/tests/site/plugins/kirby3-redis-cachedriver
/tests/site/plugins/kql

# files of Composer dependencies that are not needed for the plugin
/vendor/**/.*
Expand Down
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

![Release](https://flat.badgen.net/packagist/v/bnomei/kirby-mongodb?color=ae81ff)
![Downloads](https://flat.badgen.net/packagist/dt/bnomei/kirby-mongodb?color=272822)
[![Build Status](https://flat.badgen.net/travis/bnomei/kirby-mongodb)](https://travis-ci.com/bnomei/kirby-mongodb)
[![Coverage](https://flat.badgen.net/codeclimate/coverage/bnomei/kirby-mongodb)](https://codeclimate.com/github/bnomei/kirby-mongodb)
[![Maintainability](https://flat.badgen.net/codeclimate/maintainability/bnomei/kirby-mongodb)](https://codeclimate.com/github/bnomei/kirby-mongodb)
[![Twitter](https://flat.badgen.net/badge/twitter/bnomei?color=66d9ef)](https://twitter.com/bnomei)
[![Discord](https://flat.badgen.net/badge/discord/bnomei?color=7289da)](https://discordapp.com/users/bnomei)

Khulan is a cache driver and content cache with NoSQL interface for Kirby using MongoDB.

Expand Down
11 changes: 9 additions & 2 deletions classes/Mongodb.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Bnomei;

use Kirby\Cache\Cache;
use Kirby\Cache\FileCache;
use Kirby\Cache\Value;
use Kirby\Toolkit\A;
use Kirby\Toolkit\Str;
Expand Down Expand Up @@ -151,7 +152,10 @@ public function flush(): bool
return $this->cacheCollection()->deleteMany([])->isAcknowledged();
}

public function benchmark(int $count = 10)
/**
* @codeCoverageIgnore
*/
public function benchmark(int $count = 10): void
{
$prefix = 'mongodb-benchmark-';
$mongodb = $this;
Expand Down Expand Up @@ -188,7 +192,10 @@ public function benchmark(int $count = 10)
*/
public function root(): string
{
return kirby()->cache('bnomei.mongodb')->root();
/** @var FileCache $cache */
$cache = kirby()->cache('bnomei.mongodb');

return $cache->root();
}

public function clean(?int $time = null): ?int
Expand Down
13 changes: 11 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bnomei/kirby-mongodb",
"type": "kirby-plugin",
"version": "1.4.3",
"version": "1.4.4",
"description": "Khulan is a cache driver and content cache with NoSQL interface for Kirby using MongoDB",
"license": "MIT",
"authors": [
Expand Down Expand Up @@ -56,7 +56,11 @@
"scripts": {
"analyze": "./vendor/bin/phpstan",
"fix": "./vendor/bin/pint",
"test": "./vendor/bin/pest --coverage",
"test": "./vendor/bin/pest",
"coverage": [
"php tests/patch.php",
"./vendor/bin/pest --coverage"
],
"dist": [
"composer install --no-dev --optimize-autoloader",
"git rm -rf --cached .; git add .;"
Expand All @@ -71,5 +75,10 @@
},
"extra": {
"kirby-cms-path": "tests/kirby"
},
"suggest": {
"bnomei/kirby-blueprints": "PHP Class-based Blueprints for Kirby CMS for better type safety and code completion.",
"bnomei/kirby3-lapse": "Cache any data until set expiration time (with automatic keys).",
"getkirby/staticache": "Static site performance on demand!"
}
}
Loading

0 comments on commit 042346a

Please sign in to comment.