Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sanmai committed Jun 21, 2023
0 parents commit b43bd23
Show file tree
Hide file tree
Showing 14 changed files with 964 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/ca.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# yamllint disable rule:line-length
# yamllint disable rule:braces

name: Code Analysis

on:
pull_request:
push:
branches:
- main

jobs:
build:
name: Static code analysis with PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- "7.4"

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: none

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: composer-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ matrix.php-version }}-
composer-
- name: Install dependencies
run: |
composer install --prefer-dist --no-progress
- name: Run Psalm
run: |
php vendor/bin/psalm --output-format=github --long-progress --php-version=${{ matrix.php-version }}
65 changes: 65 additions & 0 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# yamllint disable rule:line-length
# yamllint disable rule:braces

name: Code Style

on:
pull_request:
push:
branches:
- main

jobs:
build:
name: Code style with PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- "7.4"

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: none

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: composer-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ matrix.php-version }}-
composer-
- name: Install dependencies
run: |
composer install --prefer-dist --no-progress
- name: Validate composer.json
run: |
composer validate --strict
- name: Normalize composer.json
run: |
composer normalize --dry-run --diff
- name: Restore PHP-CS-Fixer cache
uses: actions/cache@v3
with:
path: build/cache/.php_cs.cache
key: php-cs-fixer-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
restore-keys: |
php-cs-fixer-${{ matrix.php-version }}-
php-cs-fixer-
- name: Run PHP-CS-Fixer
run: |
mkdir -p build/cache/
vendor/bin/php-cs-fixer fix --diff --dry-run --verbose --cache-file=build/cache/.php_cs.cache
50 changes: 50 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# yamllint disable rule:line-length
# yamllint disable rule:braces
name: Tests

on:
pull_request:
push:
branches:
- main

jobs:
tests:
name: Testing with PHP ${{ matrix.php-version }} ${{ matrix.dependencies }}
runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- '7.4'
- '8.0'
- '8.1'
- '8.2'
dependencies: ['']

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: none

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache/composer
key: composer-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ matrix.php-version }}-
composer-
- name: Install dependencies
run: |
composer install --prefer-dist --no-interaction --no-progress ${{ matrix.dependencies }}
- name: Execute tests
run: |
php vendor/bin/phpunit
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/composer.lock
/vendor
/build
*.cache
.?*
72 changes: 72 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php declare(strict_types=1);
/**
* The TimeKeeper.
* Copyright 2023 Automattic, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

$header = <<<'EOF'
The TimeKeeper.
Copyright 2023 Automattic, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
EOF;

$config = new PhpCsFixer\Config();
$config
->setRiskyAllowed(true)
->setRules([
'header_comment' => [
'comment_type' => 'PHPDoc',
'header' => $header,
'separate' => 'bottom',
'location' => 'after_declare_strict',
],
'@PER-CS1.0' => true,
'array_indentation' => true,
'native_function_invocation' => [
'include' => ['@internal'],
'scope' => 'namespaced',
],
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
'declare_equal_normalize' => ['space' => 'none'],
'blank_line_after_opening_tag' => false,
'linebreak_after_opening_tag' => false,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
->append([__FILE__])
)
;

return $config;
Loading

0 comments on commit b43bd23

Please sign in to comment.