From e4c0473e0942bf5e4682aa391d22b8acb3e4660d Mon Sep 17 00:00:00 2001 From: Thoriq Firdaus <2067467+tfirdaus@users.noreply.github.com> Date: Tue, 29 Jul 2025 18:46:10 +0700 Subject: [PATCH 01/10] Move `CODE_OF_CONDUCT.md` to `.github` directory --- .gitattributes | 1 - CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md | 0 2 files changed, 1 deletion(-) rename CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md (100%) diff --git a/.gitattributes b/.gitattributes index 0d97859..07ed1e3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,7 +9,6 @@ /.github export-ignore /.gitignore export-ignore /.vscode export-ignore -/CODE_OF_CONDUCT.md export-ignore /codecov.yml export-ignore /docker-compose.yml export-ignore /docs 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 From 08c6e1e41ec2d3687aed490af990df98f836a987 Mon Sep 17 00:00:00 2001 From: Thoriq Firdaus <2067467+tfirdaus@users.noreply.github.com> Date: Tue, 29 Jul 2025 18:49:43 +0700 Subject: [PATCH 02/10] Update Composer scripts convention. --- .github/workflows/ci.yml | 4 ++-- composer.json | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5dcd33..bb31107 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,10 +58,10 @@ jobs: - name: Run linter if: ${{ matrix.version == '7.4' }} - run: composer phpcs + run: composer lint - name: Run static analysis - run: composer phpstan + run: composer analyze - name: Run test run: vendor/bin/phpunit --coverage-clover coverage.xml diff --git a/composer.json b/composer.json index 7bd3edc..7f48a44 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": { From 57f72897ae1c90dbb0941ff7c7b417cb5aef440b Mon Sep 17 00:00:00 2001 From: Thoriq Firdaus <2067467+tfirdaus@users.noreply.github.com> Date: Wed, 30 Jul 2025 22:43:04 +0700 Subject: [PATCH 03/10] Update labels --- .github/dependabot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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"] From 43d0ea09bf774717c18beb99ad6960c40f4ec680 Mon Sep 17 00:00:00 2001 From: Thoriq Firdaus <2067467+tfirdaus@users.noreply.github.com> Date: Wed, 30 Jul 2025 22:43:32 +0700 Subject: [PATCH 04/10] Update workflows --- .github/workflows/ci.yml | 95 ++++++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb31107..019dfa6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: ci +name: CI on: workflow_dispatch: @@ -13,56 +13,85 @@ 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"] 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 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: composer-${{ matrix.version }}-${{ hashFiles('**/composer.json') }} - restore-keys: php-${{ matrix.version }}-composer- + lint: + runs-on: ubuntu-latest + name: Lint + + 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 dependencies - run: composer update --prefer-dist --no-ansi --no-interaction --no-progress + - name: Install PHP dependencies + uses: ramsey/composer-install@v3 - - name: Run linter - if: ${{ matrix.version == '7.4' }} + - name: Analyze source code run: composer lint - - name: Run static analysis + 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: 7.4 + + - name: Install PHP dependencies + uses: ramsey/composer-install@v3 + + - name: Analyze source code run: composer analyze + 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: Install PHP dependencies + uses: ramsey/composer-install@v3 + - name: Run test run: vendor/bin/phpunit --coverage-clover coverage.xml From 79a2245334a30c73b0c369acf9260bdeab02989c Mon Sep 17 00:00:00 2001 From: Thoriq Firdaus <2067467+tfirdaus@users.noreply.github.com> Date: Wed, 30 Jul 2025 22:44:34 +0700 Subject: [PATCH 05/10] Add `non-feature-branches` --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7f48a44..d517a82 100644 --- a/composer.json +++ b/composer.json @@ -65,5 +65,6 @@ "squizlabs/php_codesniffer": "^3.13", "symfony/var-dumper": ">=5.4.40", "syntatis/coding-standard": "^2.0" - } + }, + "non-feature-branches": ["dependabot/*"] } From dbb2f0eaecc6f245b2b9ea7aa309150c1791b905 Mon Sep 17 00:00:00 2001 From: Thoriq Firdaus <2067467+tfirdaus@users.noreply.github.com> Date: Wed, 30 Jul 2025 22:46:32 +0700 Subject: [PATCH 06/10] Update `.gitattributes` list --- .gitattributes | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 07ed1e3..18a3b5a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10,9 +10,10 @@ /.gitignore export-ignore /.vscode 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 From b6d3f852e0784042d3048b96ecf6fe94e8f25617 Mon Sep 17 00:00:00 2001 From: Thoriq Firdaus <2067467+tfirdaus@users.noreply.github.com> Date: Wed, 30 Jul 2025 22:48:35 +0700 Subject: [PATCH 07/10] Update `.gitignore` list --- .gitignore | 55 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 20 deletions(-) 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 From 868a4423bf9651520532d3b386c11060328321f5 Mon Sep 17 00:00:00 2001 From: Thoriq Firdaus <2067467+tfirdaus@users.noreply.github.com> Date: Wed, 30 Jul 2025 22:54:01 +0700 Subject: [PATCH 08/10] Add `compose.yml` config --- .devcontainer/devcontainer.json | 17 +++++++++-------- compose.yml | 10 ++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 compose.yml 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/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: From cbf4bda4cf829b3945606720ab583ad418be26df Mon Sep 17 00:00:00 2001 From: Thoriq Firdaus <2067467+tfirdaus@users.noreply.github.com> Date: Wed, 30 Jul 2025 22:54:20 +0700 Subject: [PATCH 09/10] Update `.editorconfig` rules --- .editorconfig | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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 From 18309df6b63ca36e6a36e4f079d3e5395e65e7b7 Mon Sep 17 00:00:00 2001 From: Thoriq Firdaus <2067467+tfirdaus@users.noreply.github.com> Date: Wed, 30 Jul 2025 23:01:14 +0700 Subject: [PATCH 10/10] Update name --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 019dfa6..ddc1e94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,8 @@ concurrency: jobs: typo: runs-on: ubuntu-latest + name: Typo + steps: - name: Checkout code uses: actions/checkout@v4