Skip to content

Commit 86e7366

Browse files
author
Greg Bowler
authored
Merge pull request #55 from PhpGt/ci
CI
2 parents 507d46f + c7843c4 commit 86e7366

11 files changed

+1486
-366
lines changed

.github/workflows/ci.yml

+128-9
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,45 @@ on: [push]
55
jobs:
66
composer:
77
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
php: [ 8.1, 8.2 ]
811

912
steps:
10-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1114

1215
- name: Cache Composer dependencies
13-
uses: actions/cache@v2
16+
uses: actions/cache@v3
1417
with:
1518
path: /tmp/composer-cache
1619
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
1720

1821
- name: Composer install
1922
uses: php-actions/composer@v6
2023
with:
21-
php_version: '8.1'
24+
php_version: ${{ matrix.php }}
2225

2326
- name: Archive build
2427
run: mkdir /tmp/github-actions/ && tar -cvf /tmp/github-actions/build.tar ./
2528

2629
- name: Upload build archive for test runners
27-
uses: actions/upload-artifact@v2
30+
uses: actions/upload-artifact@v3
2831
with:
2932
name: build-artifact
3033
path: /tmp/github-actions
3134

3235
phpunit:
3336
runs-on: ubuntu-latest
34-
needs: [composer]
37+
needs: [ composer ]
38+
strategy:
39+
matrix:
40+
php: [ 8.1, 8.2 ]
41+
42+
outputs:
43+
coverage: ${{ steps.store-coverage.outputs.coverage_text }}
3544

3645
steps:
37-
- uses: actions/download-artifact@v2
46+
- uses: actions/download-artifact@v3
3847
with:
3948
name: build-artifact
4049
path: /tmp/github-actions
@@ -44,8 +53,118 @@ jobs:
4453

4554
- name: PHP Unit tests
4655
uses: php-actions/phpunit@v3
56+
env:
57+
XDEBUG_MODE: cover
4758
with:
48-
php_version: '8.1'
59+
php_version: ${{ matrix.php }}
4960
php_extensions: xdebug
50-
configuration: test/phpunit/phpunit.xml
51-
bootstrap: vendor/autoload.php
61+
coverage_text: _coverage/coverage.txt
62+
coverage_clover: _coverage/clover.xml
63+
64+
- name: Store coverage data
65+
uses: actions/upload-artifact@v3
66+
with:
67+
name: code-coverage
68+
path: _coverage
69+
70+
coverage:
71+
runs-on: ubuntu-latest
72+
needs: [ phpunit ]
73+
74+
steps:
75+
- uses: actions/checkout@v3
76+
77+
- uses: actions/download-artifact@v3
78+
with:
79+
name: code-coverage
80+
path: _coverage
81+
82+
- name: Output coverage
83+
run: cat "_coverage/coverage.txt"
84+
85+
- name: Upload to Codecov
86+
uses: codecov/codecov-action@v3
87+
88+
phpstan:
89+
runs-on: ubuntu-latest
90+
needs: [ composer ]
91+
strategy:
92+
matrix:
93+
php: [ 8.1, 8.2 ]
94+
95+
steps:
96+
- uses: actions/download-artifact@v3
97+
with:
98+
name: build-artifact
99+
path: /tmp/github-actions
100+
101+
- name: Extract build archive
102+
run: tar -xvf /tmp/github-actions/build.tar ./
103+
104+
- name: PHP Static Analysis
105+
uses: php-actions/phpstan@v3
106+
with:
107+
php_version: ${{ matrix.php }}
108+
path: src/
109+
110+
phpmd:
111+
runs-on: ubuntu-latest
112+
needs: [ composer ]
113+
strategy:
114+
matrix:
115+
php: [ 8.1, 8.2 ]
116+
117+
steps:
118+
- uses: actions/download-artifact@v3
119+
with:
120+
name: build-artifact
121+
path: /tmp/github-actions
122+
123+
- name: Extract build archive
124+
run: tar -xvf /tmp/github-actions/build.tar ./
125+
126+
- name: PHP Mess Detector
127+
uses: php-actions/phpmd@v1
128+
with:
129+
php_version: ${{ matrix.php }}
130+
path: src/
131+
output: text
132+
ruleset: phpmd.xml
133+
134+
phpcs:
135+
runs-on: ubuntu-latest
136+
needs: [ composer ]
137+
strategy:
138+
matrix:
139+
php: [ 8.1, 8.2 ]
140+
141+
steps:
142+
- uses: actions/download-artifact@v3
143+
with:
144+
name: build-artifact
145+
path: /tmp/github-actions
146+
147+
- name: Extract build archive
148+
run: tar -xvf /tmp/github-actions/build.tar ./
149+
150+
- name: PHP Code Sniffer
151+
uses: php-actions/phpcs@v1
152+
with:
153+
php_version: ${{ matrix.php }}
154+
path: src/
155+
standard: phpcs.xml
156+
157+
remove_old_artifacts:
158+
runs-on: ubuntu-latest
159+
160+
steps:
161+
- name: Remove old artifacts for prior workflow runs on this repository
162+
env:
163+
GH_TOKEN: ${{ github.token }}
164+
run: |
165+
gh api "/repos/${{ github.repository }}/actions/artifacts?name=build-artifact" | jq ".artifacts[] | select(.name == \"build-artifact\") | .id" > artifact-id-list.txt
166+
while read id
167+
do
168+
echo -n "Deleting artifact ID $id ... "
169+
gh api --method DELETE /repos/${{ github.repository }}/actions/artifacts/$id && echo "Done"
170+
done <artifact-id-list.txt

.scrutinizer.yml

-32
This file was deleted.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
Cache data in local files.
22
==========================
33

4-
Short blurb.
4+
Making expensive operations like HTTP calls or database queries can be minimised by caching the result of the operations in local files. This can improve performance, reduce network usage, and avoid rate limiting, to name some common benefits. This library provides a single function to define where to cache, what to cache, and when to cache. A validity of 1 hour is set by default, if the valid time is not specified.
55

66
***
77

88
<a href="https://github.com/PhpGt/FileCache/actions" target="_blank">
99
<img src="https://badge.status.php.gt/filecache-build.svg" alt="Build status" />
1010
</a>
11-
<a href="https://scrutinizer-ci.com/g/PhpGt/FileCache" target="_blank">
11+
<a href="https://app.codacy.com/gh/PhpGt/FileCache" target="_blank">
1212
<img src="https://badge.status.php.gt/filecache-quality.svg" alt="Code quality" />
1313
</a>
14-
<a href="https://scrutinizer-ci.com/g/PhpGt/FileCache" target="_blank">
14+
<a href="https://app.codecov.io/gh/PhpGt/FileCache" target="_blank">
1515
<img src="https://badge.status.php.gt/filecache-coverage.svg" alt="Code coverage" />
1616
</a>
1717
<a href="https://packagist.org/packages/PhpGt/FileCache" target="_blank">

composer.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
"require": {
77
"php": ">=8.1",
8-
"phpgt/typesafegetter": "^v1.3"
8+
"phpgt/typesafegetter": "^v1.2.4"
99
},
1010

1111
"require-dev": {
12-
"phpstan/phpstan": "^v1.8",
13-
"phpunit/phpunit": "^v9.5"
12+
"phpstan/phpstan": "^1.10",
13+
"phpunit/phpunit": "^10.1",
14+
"phpmd/phpmd": "^2.13",
15+
"squizlabs/php_codesniffer": "^3.7"
1416
},
1517

1618
"license": "MIT",

0 commit comments

Comments
 (0)