diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0736af1..f7f8f75 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,10 @@ { - "name": "syntatis/php-utils", - "image": "ghcr.io/syntatis/php:7.4-fpm", + "name": "syntatis/utils-php", + "dockerComposeFile": [ + "../compose.yml" + ], + "service": "php", + "workspaceFolder": "/var/www/work", "customizations": { "vscode": { "settings": { @@ -18,13 +22,10 @@ "extensions": [ "bmewburn.vscode-intelephense-client", "christian-kohler.path-intellisense", - "editorconfig.editorconfig", - "kasik96.latte", - "mikestead.dotenv", + "editorConfig.editorConfig", "neilbrayfield.php-docblocker", - "sanderronde.phpstan-vscode", - "wmaurer.change-case", - "dotjoshjohnson.xml" + "SanderRonde.phpstan-vscode", + "valeryanm.vscode-phpsab" ] } } diff --git a/.editorconfig b/.editorconfig index 03c9d82..064471b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,17 +1,22 @@ -# editorconfig.org - root = true [*] charset = utf-8 end_of_line = lf -indent_size = 4 -indent_style = tab insert_final_newline = true trim_trailing_whitespace = true +indent_style = tab +indent_size = 4 -[*.{json,neon,neon.dist,yml,md}] +[*.json] indent_size = 2 -[*.{yml,md,neon,neon.dist}] +[*.{yml,yaml,neon,.neon.dist,json}] indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false + +[{*.txt}] +end_of_line = crlf diff --git a/.gitattributes b/.gitattributes index 0d97859..18a3b5a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,11 +9,11 @@ /.github export-ignore /.gitignore export-ignore /.vscode export-ignore -/CODE_OF_CONDUCT.md export-ignore /codecov.yml export-ignore -/docker-compose.yml export-ignore +/compose.yml export-ignore /docs export-ignore /phpcs.xml.dist export-ignore /phpstan.neon.dist export-ignore /phpunit.xml.dist export-ignore /tests export-ignore +/README.md export-ignore diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to .github/CODE_OF_CONDUCT.md diff --git a/.github/dependabot.yml b/.github/dependabot.yml index adde0f0..0292118 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,7 +6,7 @@ updates: interval: "monthly" labels: - "dependencies" - - "ci-cd" + - "chore" - package-ecosystem: "composer" versioning-strategy: increase @@ -17,7 +17,7 @@ updates: day: "friday" labels: - "dependencies" - - "composer" + - "chore" ignore: - dependency-name: "symfony/*" versions: [">5.0"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5dcd33..ddc1e94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: ci +name: CI on: workflow_dispatch: @@ -13,55 +13,86 @@ on: - "phpcs.xml.dist" - "phpstan.neon.dist" - "phpunit.xml.dist" - push: - branches: - - main - paths: - - ".github/workflows/ci.yml" - - "**.php" - - "composer.json" - - "composer.lock" - - "phpcs.xml.dist" - - "phpstan.neon.dist" - - "phpunit.xml.dist" + types: [ready_for_review, synchronize, opened] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: - test: + typo: runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - version: ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"] + name: Typo + steps: - name: Checkout code uses: actions/checkout@v4 - - name: Get Composer cache directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - name: Check spelling + uses: crate-ci/typos@v1.34.0 - - name: Setup Composer cache - uses: actions/cache@v4 + lint: + runs-on: ubuntu-latest + name: Lint + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 with: - path: ${{ steps.composer-cache.outputs.dir }} - key: composer-${{ matrix.version }}-${{ hashFiles('**/composer.json') }} - restore-keys: php-${{ matrix.version }}-composer- + php-version: 7.4 + + - name: Install PHP dependencies + uses: ramsey/composer-install@v3 + + - name: Analyze source code + run: composer lint + + analyze: + runs-on: ubuntu-latest + name: Analyze + + steps: + - name: Checkout code + uses: actions/checkout@v2 - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.version }} - tools: composer:v2 + php-version: 7.4 + + - name: Install PHP dependencies + uses: ramsey/composer-install@v3 - - name: Install dependencies - run: composer update --prefer-dist --no-ansi --no-interaction --no-progress + - name: Analyze source code + run: composer analyze - - name: Run linter - if: ${{ matrix.version == '7.4' }} - run: composer phpcs + test: + needs: [typo, lint, analyze] + runs-on: ubuntu-latest + name: Test + + strategy: + fail-fast: true + max-parallel: 3 + matrix: + php-version: ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"] + stability: [prefer-lowest, prefer-stable] + machine: [windows-latest, ubuntu-latest] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP for test + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} - - name: Run static analysis - run: composer phpstan + - name: Install PHP dependencies + uses: ramsey/composer-install@v3 - name: Run test run: vendor/bin/phpunit --coverage-clover coverage.xml diff --git a/.gitignore b/.gitignore index 4df777d..977293d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,42 @@ -#OS -.DS_* +# OS generated files # +###################### +.DS_Store +Thumbs.db -# Composer -/vendor -composer.lock -auth.json +# Logs and databases # +###################### +*.sql +*.log -# Log, cache, and tmp files +# Caches # +########## *.cache -*.log -*.meta -tmp/ -# Dotenv -.env.* -!.env +# Compiled source # +################### +*.tar* +*.zip +dist* +build* +@* + +# Dependencies # +################ +vendor* +composer.lock -# Tests # -############# +# Temporary files # +################### +tmp artifacts/ -phpunit.xml -phpstan.neon -phpcs.xml -# Docker -docker-composer.override.yml +# Environment files # +###################### +.env + +# Private Configs # +###################### +phpcs.xml +phpstan.xml +phpunit.xml +*.override.xml diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..f9a7aa9 --- /dev/null +++ b/compose.yml @@ -0,0 +1,10 @@ +services: + php: + image: ghcr.io/syntatis/php:${PHP_VERSION:-7.4}-fpm + restart: on-failure + volumes: + - ./:/var/www/work + - vscode_server_volume:/root/.vscode-server + +volumes: + vscode_server_volume: diff --git a/composer.json b/composer.json index 7bd3edc..d517a82 100644 --- a/composer.json +++ b/composer.json @@ -39,18 +39,13 @@ } }, "scripts": { - "phpcs:fix": "vendor/bin/phpcbf", - "phpcs": "vendor/bin/phpcs", - "phpstan": "vendor/bin/phpstan analyse --xdebug", - "phpunit:coverage": [ + "format": "vendor/bin/phpcbf", + "lint": "vendor/bin/phpcs", + "analyze": "vendor/bin/phpstan analyse --xdebug", + "test": "vendor/bin/phpunit --no-coverage", + "test:coverage": [ "@putenv XDEBUG_MODE=coverage", "vendor/bin/phpunit" - ], - "phpunit": "vendor/bin/phpunit --no-coverage", - "test": [ - "@phpcs", - "@phpstan", - "@phpunit" ] }, "require": { @@ -70,5 +65,6 @@ "squizlabs/php_codesniffer": "^3.13", "symfony/var-dumper": ">=5.4.40", "syntatis/coding-standard": "^2.0" - } + }, + "non-feature-branches": ["dependabot/*"] }