Skip to content

Commit

Permalink
chore: Started configuring the bundle
Browse files Browse the repository at this point in the history
This commit starts with configuring the bundle, writing the readme,
setting up the code analyzers, writing the first simple test and event
listener.
  • Loading branch information
SanderVerkuil committed Oct 23, 2023
0 parents commit 9cac010
Show file tree
Hide file tree
Showing 50 changed files with 1,741 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; top-most EditorConfig file
root = true

; Unix-style newlines
[*]
charset = utf-8
end_of_line = LF
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.md]
max_line_length = 80

[*.{yml, yaml}]
indent_size = 2

[COMMIT_EDITMSG]
max_line_length = 0
Empty file added .env.test
Empty file.
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tests/ export-ignore
var/ export-ignore
.* export-ignore
Makefile export-ignore
phpunit.xml export-ignore
codecov.yml export-ignore
phpstan.neon export-ignore
phpstan-baseline.neon export-ignore
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 🐞 Bug Report
description: Tell us about something that's not working the way we (probably) intend.
body:
- type: input
id: version
attributes:
label: SDK version
description: Which SDK version do you use?
placeholder: e.g. 3.0.8
validations:
required: true
- type: textarea
id: repro
attributes:
label: Steps to reproduce
description: How can we see what you're seeing? Specific is terrific.
placeholder: |-
1. What
2. you
3. did.
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected result
validations:
required: true
- type: textarea
id: actual
attributes:
label: Actual result
description: Logs? Screenshots? Yes, please.
validations:
required: true
- type: markdown
attributes:
value: |-
## Thanks 🙏
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
blank_issues_enabled: true

25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 💡 Feature Request
description: Create a feature request for this SDK.
labels: 'enhancement'
body:
- type: markdown
attributes:
value: Thanks for taking the time to file a feature request! Please fill out this form as completely as possible.
- type: textarea
id: problem
attributes:
label: Problem Statement
description: A clear and concise description of what you want and what your use case is.
validations:
required: true
- type: textarea
id: expected
attributes:
label: Solution Brainstorm
description: We know you have bright ideas to share ... share away, friend.
validations:
required: true
- type: markdown
attributes:
value: |-
## Thanks 🙏
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Lint PR"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
subjectPattern: ^(?![A-Z]).+$
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character.
64 changes: 64 additions & 0 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Code style and static analysis

on:
pull_request:
push:
branches:
- main
- development
- release/**

jobs:
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

- name: Install dependencies
run: composer update --no-progress --no-interaction --prefer-dist

- name: Run script
run: composer phpcs

phpstan:
name: PHPStan
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

- name: Install dependencies
run: composer update --no-progress --no-interaction --prefer-dist

- name: Run script
run: composer phpstan

psalm:
name: Psalm
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

- name: Install dependencies
run: composer update --no-progress --no-interaction --prefer-dist

- name: Run script
run: composer psalm -- --php-version=8.0
122 changes: 122 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Continuous Integration

on:
pull_request: null
push:
branches:
- main
- development
- release/**

jobs:
tests:
name: Tests
runs-on: ubuntu-latest
env:
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
strategy:
fail-fast: false
matrix:
php:
- '8.0'
- '8.1'
- '8.2'
symfony-version:
- 5.*
- 6.*
dependencies:
- highest
include:
- php: '8.0'
symfony-version: 5.*
dependencies: lowest
- php: '8.0'
symfony-version: 6.*
dependencies: lowest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 2

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

- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Update PHPUnit
run: composer require --dev phpunit/phpunit ^9.3.9 --no-update
if: matrix.php == '8.0' && matrix.dependencies == 'lowest'

- name: Install dependencies
uses: ramsey/composer-install@v1
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: --prefer-dist

- name: Run tests
run: vendor/bin/phpunit --coverage-clover=build/coverage-report.xml

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
file: build/coverage-report.xml
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}


missing-optional-packages-tests:
name: Tests without optional packages
runs-on: ubuntu-latest
env:
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
strategy:
fail-fast: false
matrix:
include:
- php: '8.0'
dependencies: lowest
symfony-version: 5.4.*
- php: '8.1'
dependencies: highest
- php: '8.2'
dependencies: highest

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

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

- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Remove optional packages
run: composer remove doctrine/dbal doctrine/doctrine-bundle symfony/messenger symfony/twig-bundle symfony/cache symfony/http-client --dev --no-update

- name: Install dependencies
uses: ramsey/composer-install@v1
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: --prefer-dist

- name: Run tests
run: vendor/bin/phpunit --coverage-clover=build/coverage-report.xml

- name: Upload code coverage
uses: codecov/codecov-action@v3
with:
file: build/coverage-report.xml
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.lock
package.xml
/vendor
.idea
.php-cs-fixer.cache
.phpunit.result.cache
docs/_build
var
tests/clover.xml
.env
35 changes: 35 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'ordered_imports' => [
'imports_order' => ['class', 'function', 'const'],
],
'declare_strict_types' => true,
'random_api_migration' => true,
'yoda_style' => true,
'self_accessor' => false,
'phpdoc_no_useless_inheritdoc' => false,
'phpdoc_to_comment' => false,
'phpdoc_align' => [
'tags' => ['param', 'return', 'throws', 'type', 'var'],
],
'phpdoc_line_span' => [
'const' => 'multi',
'method' => 'multi',
'property' => 'multi',
],
])
->setFinder(
PhpCsFixer\Finder::create()
->in([__DIR__ . '/src', __DIR__ . '/tests'])
->exclude(['var'])
);
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
http://github.com/sanderverkuil/posthog-symfony/contributors
Empty file added CHANGELOG.md
Empty file.
Loading

0 comments on commit 9cac010

Please sign in to comment.