Skip to content

Commit face7d9

Browse files
committed
update ci
1 parent bf32d2e commit face7d9

8 files changed

Lines changed: 61 additions & 165 deletions

File tree

.github/workflows/ci.yml

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
name: CI
1+
name: CI/CD Pipeline
22

33
on:
44
push:
5-
branches: [ main, master ]
5+
branches: [ master ]
66
pull_request:
7-
branches: [ main, master ]
7+
branches: [ master ]
88

99
jobs:
1010
test:
11+
name: Run Tests
1112
runs-on: ubuntu-latest
1213
strategy:
1314
matrix:
14-
php: [8.1, 8.2, 8.3]
15+
php: [8.3, 8.4]
1516

1617
steps:
17-
- uses: actions/checkout@v4
18+
- name: Checkout code
19+
uses: actions/checkout@v4
1820

1921
- name: Setup PHP
2022
uses: shivammathur/setup-php@v2
@@ -26,66 +28,88 @@ jobs:
2628
- name: Validate composer.json and composer.lock
2729
run: composer validate --strict
2830

29-
- name: Cache Composer packages
31+
- name: Get composer cache directory
3032
id: composer-cache
31-
uses: actions/cache@v3
33+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
34+
35+
- name: Cache dependencies
36+
uses: actions/cache@v4
3237
with:
33-
path: vendor
34-
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
35-
restore-keys: |
36-
${{ runner.os }}-php-
38+
path: ${{ steps.composer-cache.outputs.dir }}
39+
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
40+
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-composer-
3741

3842
- name: Install dependencies
3943
run: composer install --prefer-dist --no-progress
4044

41-
- name: Run PHPStan
42-
run: composer run phpstan
43-
44-
- name: Run PHP CodeSniffer
45-
run: composer run phpcs
46-
47-
- name: Run tests
48-
run: composer run test
45+
- name: Run quality checks
46+
run: composer run quality
4947

5048
- name: Run tests with coverage
5149
run: composer run test-coverage
5250

5351
- name: Upload coverage to Codecov
54-
uses: codecov/codecov-action@v3
52+
if: matrix.php == '8.4'
53+
uses: codecov/codecov-action@v4
5554
with:
5655
file: ./coverage.xml
5756
flags: unittests
5857
name: codecov-umbrella
5958
fail_ci_if_error: true
6059

6160
security:
61+
name: Security Audit
6262
runs-on: ubuntu-latest
63+
needs: test
64+
6365
steps:
64-
- uses: actions/checkout@v4
66+
- name: Checkout code
67+
uses: actions/checkout@v4
6568

6669
- name: Setup PHP
6770
uses: shivammathur/setup-php@v2
6871
with:
69-
php-version: 8.3
72+
php-version: '8.3'
7073

7174
- name: Install dependencies
7275
run: composer install --prefer-dist --no-progress
7376

7477
- name: Run security audit
7578
run: composer audit
7679

77-
outdated:
80+
release:
81+
name: Create Release
7882
runs-on: ubuntu-latest
83+
needs: [test, security]
84+
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
85+
7986
steps:
80-
- uses: actions/checkout@v4
87+
- name: Checkout code
88+
uses: actions/checkout@v4
89+
with:
90+
fetch-depth: 0
8191

8292
- name: Setup PHP
8393
uses: shivammathur/setup-php@v2
8494
with:
85-
php-version: 8.3
95+
php-version: '8.3'
96+
extensions: mbstring, iconv
8697

8798
- name: Install dependencies
8899
run: composer install --prefer-dist --no-progress
89100

90-
- name: Check for outdated dependencies
91-
run: composer outdated --direct
101+
- name: Generate configuration files
102+
run: composer generate
103+
104+
- name: Create Release
105+
uses: softprops/action-gh-release@v2
106+
with:
107+
generate_release_notes: true
108+
files: |
109+
*.conf
110+
*.vcl
111+
*.caddy*
112+
*.res
113+
web.config
114+
env:
115+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/main.yml

Lines changed: 0 additions & 127 deletions
This file was deleted.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
}
2323
],
2424
"require": {
25-
"php": ">=8.1",
25+
"php": ">=8.3",
2626
"algo26-matthias/idna-convert": "^4.2.1"
2727
},
2828
"require-dev": {

composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/CLI/CommandLineInterface.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
class CommandLineInterface
1111
{
12-
private const VERSION = '2.0.0';
13-
private const SUPPORTED_TYPES = ['apache', 'nginx', 'varnish', 'iis', 'uwsgi', 'caddy', 'caddy2', 'google'];
12+
private const array SUPPORTED_TYPES = ['apache', 'nginx', 'varnish', 'iis', 'uwsgi', 'caddy', 'caddy2', 'google'];
1413

1514
/**
1615
* @param array<int, string> $argv
@@ -147,7 +146,7 @@ private function parseOptions(array $argv): array
147146
*/
148147
private function showHelp(): void
149148
{
150-
echo 'Referrer Spam Blocker Generator v' . self::VERSION . "\n\n";
149+
echo "Referrer Spam Blocker Generator\n\n";
151150
echo "Usage: php run.php [options]\n\n";
152151
echo "Options:\n";
153152
echo " -h, --help Show this help message\n";
@@ -168,7 +167,7 @@ private function showHelp(): void
168167
*/
169168
private function showVersion(): void
170169
{
171-
echo 'Referrer Spam Blocker Generator v' . self::VERSION . "\n";
170+
echo "Referrer Spam Blocker Generator\n";
172171
}
173172

174173
/**

src/Config/AbstractConfigGenerator.php

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

77
abstract class AbstractConfigGenerator implements ConfigGeneratorInterface
88
{
9-
protected const PROJECT_URL = 'https://github.com/Stevie-Ray/referrer-spam-blocker';
9+
protected const string PROJECT_URL = 'https://github.com/Stevie-Ray/referrer-spam-blocker';
1010

1111
/**
1212
* Escape a domain for use in configuration files

src/Config/GoogleAnalyticsConfigGenerator.php

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

77
class GoogleAnalyticsConfigGenerator extends AbstractConfigGenerator implements MultiFileConfigGeneratorInterface
88
{
9-
private const GOOGLE_ANALYTICS_LIMIT = 30000;
9+
private const int GOOGLE_ANALYTICS_LIMIT = 30000;
1010

1111
#[\Override]
1212
public function getFilename(): string

src/Domain/DomainProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
class DomainProcessor
1414
{
15-
private const DEFAULT_DOMAINS_FILE = __DIR__ . '/../domains.txt';
16-
private const IDN_PATTERN = '/[А-Яа-яЁёöɢ]/u';
15+
private const string DEFAULT_DOMAINS_FILE = __DIR__ . '/../domains.txt';
16+
private const string IDN_PATTERN = '/[А-Яа-яЁёöɢ]/u';
1717

1818
private string $domainsFile;
1919

0 commit comments

Comments
 (0)