From 2258e90a8a793d41af79d190bb5d235de3c58e5f Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 00:50:44 +0200 Subject: [PATCH 01/48] fix: .editorconfig --- .editorconfig | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.editorconfig b/.editorconfig index f02a64bf..558bf795 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,10 +11,8 @@ trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false -[*.yml] -indent_style = space +[*.{yml,yaml}] indent_size = 2 -[*.json] -indent_style = space -indent_size = 4 +[Makefile] +indent_style = tab From c8c6e5777fa64e38490564ba3c00b6f4db0c1c47 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 00:51:43 +0200 Subject: [PATCH 02/48] feat: add .env file for local development and testing --- .env.example | 21 +++++++++++++++++++++ .gitignore | 1 + 2 files changed, 22 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..4838c716 --- /dev/null +++ b/.env.example @@ -0,0 +1,21 @@ +# https://docs.docker.com/compose/reference/envvars/#compose_project_name +# With custom namespace provided, it will be used to prefix all services +# in Docker network for current project +COMPOSE_PROJECT_NAME=cycle-database +APP_ENV=production + +DB_CONNECTION=pgsql +DB_HOST=pgsql +DB_PORT=5432 + +DB_DATABASE=default +DB_USERNAME=root +DB_PASSWORD=password + +DB_SQLSERVER_FORWARD_PORT=11433 +DB_MYSQL_FORWARD_PORT=13333 +DB_PGSQL_FORWARD_PORT=15333 + +XDEBUG_MODE=coverage + +GITHUB_TOKEN=ghp_ diff --git a/.gitignore b/.gitignore index d89a76d9..82f964ed 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ clover.xml clover.json .php_cs.cache .phpunit.result.cache +.env From 35218e4be5ffbe30539b9fb36ab40d00e20b10b0 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 00:52:55 +0200 Subject: [PATCH 03/48] fix: production release should not contain development files --- .gitattributes | 20 +++++++++++++++----- .gitignore | 1 - 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.gitattributes b/.gitattributes index 3f6e40b1..df9f0f9a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,15 @@ -/.github export-ignore -/.editorconfig export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore -/tests export-ignore +/.build export-ignore +/.github export-ignore +/tests export-ignore +.editorconfig export-ignore +.env.example export-ignore +.gitattributes export-ignore +.gitignore export-ignore +.php-cs-fixer.dist.php export-ignore +.scrutinizer.yml export-ignore +.styleci.yml export-ignore +docker-compose.yaml export-ignore +infection.json.dist export-ignore +Makefile export-ignore +phpunit.xml export-ignore +psalm.xml export-ignore diff --git a/.gitignore b/.gitignore index 82f964ed..edbcea6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .idea/ -.env .coveralls.yml composer.lock vendor/ From e963a399945c9aa652aee7fd11ba5ad099b29a4e Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 00:57:36 +0200 Subject: [PATCH 04/48] feat: add pre-commit config file --- .pre-commit-config.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..de88b0f5 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,23 @@ +--- + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: check-json + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-added-large-files + args: ['--maxkb=600'] + - id: fix-encoding-pragma + + - repo: https://github.com/commitizen-tools/commitizen + rev: v3.20.0 + hooks: + - id: commitizen + stages: + - commit-msg + +... From fa6292300396c70fe1c36bbd46a000b53adfca7b Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 00:59:14 +0200 Subject: [PATCH 05/48] feat: add self-documenting Makefile and docker-compose for local dev dokerization --- Makefile | 203 ++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yaml | 77 +++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 Makefile create mode 100644 docker-compose.yaml diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..e83bf4e9 --- /dev/null +++ b/Makefile @@ -0,0 +1,203 @@ +-include .env + +# BuildKit enables higher performance docker builds and caching possibility +# to decrease build times and increase productivity for free. +# https://docs.docker.com/compose/environment-variables/envvars/ +export DOCKER_BUILDKIT ?= 1 + +# Binary to use, when executing docker-compose tasks +DOCKER_COMPOSE ?= docker compose + +# Support image with all needed binaries, like envsubst, mkcert, wait4x +SUPPORT_IMAGE ?= wayofdev/build-deps:alpine-latest + +APP_RUNNER ?= $(DOCKER_COMPOSE) run --rm --no-deps app +APP_COMPOSER ?= $(APP_RUNNER) composer + +BUILDER_PARAMS ?= docker run --rm -i \ + --env-file ./.env \ + --env COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \ + --env COMPOSER_AUTH="$(COMPOSER_AUTH)" + +BUILDER ?= $(BUILDER_PARAMS) $(SUPPORT_IMAGE) +BUILDER_WIRED ?= $(BUILDER_PARAMS) --network project.$(COMPOSE_PROJECT_NAME) $(SUPPORT_IMAGE) + +# Shorthand envsubst command, executed through build-deps +ENVSUBST ?= $(BUILDER) envsubst + +EXPORT_VARS = '\ + $${COMPOSE_PROJECT_NAME} \ + $${COMPOSER_AUTH}' + +# Self documenting Makefile code +# ------------------------------------------------------------------------------------ +ifneq ($(TERM),) + BLACK := $(shell tput setaf 0) + RED := $(shell tput setaf 1) + GREEN := $(shell tput setaf 2) + YELLOW := $(shell tput setaf 3) + LIGHTPURPLE := $(shell tput setaf 4) + PURPLE := $(shell tput setaf 5) + BLUE := $(shell tput setaf 6) + WHITE := $(shell tput setaf 7) + RST := $(shell tput sgr0) +else + BLACK := "" + RED := "" + GREEN := "" + YELLOW := "" + LIGHTPURPLE := "" + PURPLE := "" + BLUE := "" + WHITE := "" + RST := "" +endif +MAKE_LOGFILE = /tmp/cycle-database.log +MAKE_CMD_COLOR := $(BLUE) + +default: all + +help: + @echo 'Management commands for package:' + @echo 'Usage:' + @echo ' ${MAKE_CMD_COLOR}make${RST} Setups dependencies for fresh-project, like composer install, git hooks and others...' + @grep -E '^[a-zA-Z_0-9%-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf " ${MAKE_CMD_COLOR}make %-21s${RST} %s\n", $$1, $$2}' + @echo + @echo ' ๐Ÿ“‘ Logs are stored in $(MAKE_LOGFILE)' + @echo + @echo ' ๐Ÿ“ฆ Package database (https://github.com/cycle/database)' + @echo ' ๐Ÿค  Author Andrij Orlenko (https://github.com/lotyp)' + @echo ' ๐Ÿข ${YELLOW}Org cycle (https://github.com/cycle)${RST}' +.PHONY: help + +.EXPORT_ALL_VARIABLES: + + +# Default action +# Defines default command when `make` is executed without additional parameters +# ------------------------------------------------------------------------------------ +all: env prepare install hooks up +.PHONY: all + + +# System Actions +# ------------------------------------------------------------------------------------ +env: ## Generate .env file from example, use `make env force=true`, to force re-create file +ifeq ($(FORCE),true) + @echo "${YELLOW}Force re-creating .env file from example...${RST}" + $(ENVSUBST) $(EXPORT_VARS) < ./.env.example > ./.env +else ifneq ("$(wildcard ./.env)","") + @echo "" + @echo "${YELLOW}The .env file already exists! Use FORCE=true to re-create.${RST}" +else + @echo "Creating .env file from example" + $(ENVSUBST) $(EXPORT_VARS) < ./.env.example > ./.env +endif +.PHONY: env + +prepare: + mkdir -p .build/php-cs-fixer +.PHONY: prepare + + +# Docker Actions +# ------------------------------------------------------------------------------------ +up: # Creates and starts containers, defined in docker-compose and override file + $(DOCKER_COMPOSE) up --remove-orphans -d +.PHONY: up + +down: # Stops and removes containers of this project + $(DOCKER_COMPOSE) down --remove-orphans --volumes +.PHONY: down + +restart: down up ## Runs down and up commands +.PHONY: restart + +clean: ## Stops containers if required and removes from system + $(DOCKER_COMPOSE) rm --force --stop +.PHONY: clean + +ps: ## List running project containers + $(DOCKER_COMPOSE) ps +.PHONY: ps + +logs: ## Show project docker logs with follow up mode enabled + $(DOCKER_COMPOSE) logs -f +.PHONY: logs + +pull: ## Pull and update docker images in this project + $(DOCKER_COMPOSE) pull +.PHONY: pull + +ssh: ## Login inside running docker container + $(APP_RUNNER) sh +.PHONY: ssh + + +# Composer +# ------------------------------------------------------------------------------------ +install: ## Installs composer dependencies + $(APP_COMPOSER) install +.PHONY: install + +update: ## Updates composer dependencies by running composer update command + $(APP_COMPOSER) update +.PHONY: update + + +# Code Quality, Git, Linting, Testing +# ------------------------------------------------------------------------------------ +hooks: ## Install git hooks from pre-commit-config + pre-commit install + pre-commit autoupdate +.PHONY: hooks + +lint: lint-yaml lint-php lint-psalm ## Runs all linting commands +.PHONY: lint + +lint-yaml: ## Lints yaml files inside project + yamllint . +.PHONY: lint-yaml + +lint-php: prepare ## Fixes code to follow coding standards using php-cs-fixer + $(APP_COMPOSER) cs:fix +.PHONY: lint-php + +lint-diff: prepare ## Runs php-cs-fixer in dry-run mode and shows diff which will by applied + $(APP_COMPOSER) cs:diff +.PHONY: lint-diff + +lint-psalm: ## Runs psalm โ€“ static analysis tool + $(APP_COMPOSER) psalm +.PHONY: lint-psalm + +lint-psalm-ci: + $(APP_COMPOSER) psalm:ci +.PHONY: lint-psalm-ci + +test: ## Run project php-unit tests + $(APP_COMPOSER) test +.PHONY: test + +test-cc: ## Run project php-unit tests in coverage mode and build report + $(APP_COMPOSER) test:cc +.PHONY: test-cc + +test-sqlite: ## Run project php-unit tests with sqlite database + $(APP_COMPOSER) test:sqlite +.PHONY: test-sqlite + +# Release +# ------------------------------------------------------------------------------------ +commit: + cz commit +.PHONY: commit + +release: ## Create a new release + release-please release-pr \ + --token=$(GITHUB_TOKEN) \ + --repo-url=cycle/database \ + --target-branch=feat/dx \ + --config-file=.github/.release-please-config.json \ + --manifest-file=.github/.release-please-manifest.json +.PHONE: release diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..6f970381 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,77 @@ +--- + +version: '3.9' + +services: + app: + image: wayofdev/php-dev:8.2-cli-alpine-latest + container_name: ${COMPOSE_PROJECT_NAME}-app + restart: on-failure + networks: + - default + volumes: + - ./:/app:rw + - ~/.composer:/.composer + env_file: + - .env + + sqlserver: + image: mcr.microsoft.com/mssql/server:2022-latest + platform: linux/amd64 + container_name: ${COMPOSE_PROJECT_NAME}-sqlserver + restart: on-failure + networks: + - default + ports: + - '${DB_SQLSERVER_FORWARD_PORT:-11433}:1433' + environment: + SA_PASSWORD: ${DB_PASSWORD} + ACCEPT_EULA: 'Y' + + mysql: + image: mysql:latest + container_name: ${COMPOSE_PROJECT_NAME}-mysql + restart: on-failure + networks: + - default + ports: + - '${DB_MYSQL_FORWARD_PORT:-13306}:3306' + env_file: + - .env + environment: + MYSQL_ROOT_HOST: '%' + MYSQL_USER: ${DB_USERNAME} + MYSQL_ROOT_PASSWORD: ${DB_PASSWORD} + MYSQL_DATABASE: ${DB_DATABASE} + volumes: + - mysql-data:/var/lib/mysql:cached + command: --default-authentication-plugin=mysql_native_password + + pgsql: + image: wayofdev/postgres:15-alpine-latest + container_name: ${COMPOSE_PROJECT_NAME}-pgsql + restart: on-failure + networks: + - default + ports: + - '${DB_PGSQL_FORWARD_PORT:-15432}:5432' + env_file: + - .env + environment: + POSTGRES_USER: ${DB_USERNAME} + POSTGRES_PASSWORD: ${DB_PASSWORD} + POSTGRES_DB: ${DB_DATABASE} + volumes: + - pgsql-data:/var/lib/postgresql/data:cached + +volumes: + pgsql-data: + name: ${COMPOSE_PROJECT_NAME}-pgsql-data + mysql-data: + name: ${COMPOSE_PROJECT_NAME}-mysql-data + +networks: + default: + name: project.${COMPOSE_PROJECT_NAME} + +... From cedd95e94594cdd072e6c5e736727a7271351f22 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 01:01:26 +0200 Subject: [PATCH 06/48] docs: mention make commands in CONTRIBUTING.md --- CONTRIBUTING.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 251b148a..ec0fc57b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,5 @@ # Contributing + Feel free to contribute to the development of the Cycle DBAL. Please make sure that the following requirements are satisfied before submitting your pull request: @@ -13,20 +14,27 @@ Please make sure that the following requirements are satisfied before submitting To test Cycle DBAL locally, download the `cycle/database` repository and start docker containers inside the tests folder: ```bash -$ cd tests/ -$ docker-composer up +## to set up the environment with one command +make + +## or, manually +make env +make prepare +make install +make hooks +make up ``` To run full test suite: ```bash -$ ./vendor/bin/phpunit +make test ``` To run quick test suite: ```bash -$ ./vendor/bin/phpunit --group driver-sqlite +make test-sqlite ``` ## Help Needed In From c3bdc701dfba6892a0fe6bc421d5869ce320dc2a Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 01:04:31 +0200 Subject: [PATCH 07/48] feat!: bump minimal php version from 8.0 to 8.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0385c29b..1ad4de8c 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ } ], "require": { - "php": ">=8.0", + "php": ">=8.1", "ext-pdo": "*", "psr/log": "1 - 3", "spiral/core": "^2.8 || ^3.0", From 43b6b87ed55462f53d09d477aa82118b9171c3e9 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 01:12:03 +0200 Subject: [PATCH 08/48] feat: add wayofdev/php-cs-fixer and roave/security-advisories --- .php-cs-fixer.dist.php | 20 ++++++++++++++++++++ composer.json | 24 ++++++++++++++---------- 2 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 .php-cs-fixer.dist.php diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 00000000..2e9ca19f --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,20 @@ + false])) + ->inDir(__DIR__ . '/resources') + ->inDir(__DIR__ . '/src') + ->inDir(__DIR__ . '/tests') + ->addFiles([__FILE__]) + ->getConfig() +; + +$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/php-cs-fixer.cache'); + +return $config; diff --git a/composer.json b/composer.json index 1ad4de8c..6eb3cfa1 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "psr/log": "1 - 3", "spiral/core": "^2.8 || ^3.0", "spiral/pagination": "^2.8 || ^3.0", - "symfony/polyfill-php83": "^1.28" + "symfony/polyfill-php83": "^1.29" }, "autoload": { "files": [ @@ -56,11 +56,13 @@ } }, "require-dev": { - "infection/infection": "^0.26.10", - "mockery/mockery": "^1.5", - "phpunit/phpunit": "^9.5", + "infection/infection": "^0.26", + "mockery/mockery": "^1.6", + "phpunit/phpunit": "^9.6", "spiral/tokenizer": "^2.14 | ^3.0", - "vimeo/psalm": "^5.18" + "vimeo/psalm": "^5.23", + "roave/security-advisories": "dev-latest", + "wayofdev/cs-fixer-config": "^1.2" }, "autoload-dev": { "psr-4": { @@ -68,11 +70,13 @@ } }, "scripts": { - "test": [ - "phpcs --standard=phpcs.xml", - "psalm --no-cache", - "phpunit" - ] + "cs:fix": "php vendor/bin/php-cs-fixer fix -v", + "cs:diff": "php vendor/bin/php-cs-fixer fix --dry-run -v --diff", + "test": "php vendor/bin/phpunit --colors=always", + "test:cc": "php vendor/bin/phpunit --colors=always --coverage", + "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite", + "psalm": "php vendor/bin/psalm --no-cache", + "psalm:ci": "php vendor/bin/psalm --no-cache --error-format=github" }, "config": { "sort-packages": true, From 6e6a07c83a9365bcaf723a2863890539ab1d63d7 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 01:12:47 +0200 Subject: [PATCH 09/48] feat: remove style-ci dependency --- .styleci.yml | 76 ---------------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 .styleci.yml diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index ec5db6e8..00000000 --- a/.styleci.yml +++ /dev/null @@ -1,76 +0,0 @@ -preset: psr12 -risky: true - -version: 8 - -enabled: - - alpha_ordered_traits - - array_indentation - - array_push - - combine_consecutive_issets - - combine_consecutive_unsets - - combine_nested_dirname - - declare_strict_types - - dir_constant - - fully_qualified_strict_types - - function_to_constant - - hash_to_slash_comment - - is_null - - magic_constant_casing - - magic_method_casing - - method_separation - - modernize_types_casting - - native_function_casing - - native_function_type_declaration_casing - - no_alias_functions - - no_empty_comment - - no_empty_phpdoc - - no_empty_statement - - no_extra_block_blank_lines - - no_short_bool_cast - - no_superfluous_elseif - - no_unneeded_control_parentheses - - no_unneeded_curly_braces - - no_unneeded_final_method - - no_unset_cast - - no_unused_imports - - no_unused_lambda_imports - - no_useless_else - - no_useless_return - - normalize_index_brace - - php_unit_dedicate_assert - - php_unit_dedicate_assert_internal_type - - php_unit_expectation - - php_unit_mock - - php_unit_mock_short_will_return - - php_unit_namespaced - - php_unit_no_expectation_annotation - - phpdoc_no_empty_return - - phpdoc_no_useless_inheritdoc - - phpdoc_order - - phpdoc_property - - phpdoc_scalar - - phpdoc_separation - - phpdoc_singular_inheritdoc - - phpdoc_trim - - phpdoc_trim_consecutive_blank_line_separation - - phpdoc_type_to_var - - phpdoc_types - - phpdoc_types_order - - print_to_echo - - regular_callable_call - - return_assignment - - self_accessor - - self_static_accessor - - set_type_to_cast - - short_array_syntax - - short_list_syntax - - simplified_if_return - - single_quote - - standardize_not_equals - - ternary_to_null_coalescing - - trailing_comma_in_multiline_array - - unalign_equals -finder: - exclude: - - "tests/Database/Unit/Stub" From 1a01cfb025b28e89995a9c97be45e6706941b5dd Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 01:13:20 +0200 Subject: [PATCH 10/48] chore: move CODE_OF_CONDUCT --- CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md (100%) 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 397b07a180de3be5c844111c4f27d0d38ac0cb64 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 01:14:05 +0200 Subject: [PATCH 11/48] feat: add yamllint --- .yamllint.yaml | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .yamllint.yaml diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 00000000..7cb7cbbc --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,56 @@ +--- + +extends: default + +ignore: | + .build/ + vendor/ + +# Overwrite above default rules +rules: + braces: + # Defaults + # min-spaces-inside: 0 + # max-spaces-inside: 0 + + # Keep 0 min-spaces to not error on empty {} collection definitions + min-spaces-inside: 0 + + # Allow one space inside braces to improve code readability + max-spaces-inside: 1 + + brackets: + # Defaults + # min-spaces-inside: 0 + # max-spaces-inside: 0 + + # Keep 0 min-spaces to not error on empty [] collection definitions + min-spaces-inside: 0 + + # Allow one space inside braces to improve code readability + max-spaces-inside: 1 + + colons: + # Defaults + # min-spaces-before: 0 + # max-spaces-after: 1 + + # Allow multiple spaces after a colon to allow indentation of YAML + # dictionary values + max-spaces-after: -1 + + commas: + # Defaults + # max-spaces-after: 1 + + # Allow multiple spaces after a comma to allow indentation of YAML + # dictionary values + max-spaces-after: -1 + + comments: + require-starting-space: true + min-spaces-from-content: 1 + + line-length: disable + +... From 8a7014f683d56da2cdfbf29bfac9cabafa27c26b Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 01:22:48 +0200 Subject: [PATCH 12/48] chore: return back .styleci, as it bloats commits --- .styleci.yml | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .styleci.yml diff --git a/.styleci.yml b/.styleci.yml new file mode 100644 index 00000000..ec5db6e8 --- /dev/null +++ b/.styleci.yml @@ -0,0 +1,76 @@ +preset: psr12 +risky: true + +version: 8 + +enabled: + - alpha_ordered_traits + - array_indentation + - array_push + - combine_consecutive_issets + - combine_consecutive_unsets + - combine_nested_dirname + - declare_strict_types + - dir_constant + - fully_qualified_strict_types + - function_to_constant + - hash_to_slash_comment + - is_null + - magic_constant_casing + - magic_method_casing + - method_separation + - modernize_types_casting + - native_function_casing + - native_function_type_declaration_casing + - no_alias_functions + - no_empty_comment + - no_empty_phpdoc + - no_empty_statement + - no_extra_block_blank_lines + - no_short_bool_cast + - no_superfluous_elseif + - no_unneeded_control_parentheses + - no_unneeded_curly_braces + - no_unneeded_final_method + - no_unset_cast + - no_unused_imports + - no_unused_lambda_imports + - no_useless_else + - no_useless_return + - normalize_index_brace + - php_unit_dedicate_assert + - php_unit_dedicate_assert_internal_type + - php_unit_expectation + - php_unit_mock + - php_unit_mock_short_will_return + - php_unit_namespaced + - php_unit_no_expectation_annotation + - phpdoc_no_empty_return + - phpdoc_no_useless_inheritdoc + - phpdoc_order + - phpdoc_property + - phpdoc_scalar + - phpdoc_separation + - phpdoc_singular_inheritdoc + - phpdoc_trim + - phpdoc_trim_consecutive_blank_line_separation + - phpdoc_type_to_var + - phpdoc_types + - phpdoc_types_order + - print_to_echo + - regular_callable_call + - return_assignment + - self_accessor + - self_static_accessor + - set_type_to_cast + - short_array_syntax + - short_list_syntax + - simplified_if_return + - single_quote + - standardize_not_equals + - ternary_to_null_coalescing + - trailing_comma_in_multiline_array + - unalign_equals +finder: + exclude: + - "tests/Database/Unit/Stub" From 2cbbff84dc5e14e0badd32b00e095860738002fe Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 01:25:58 +0200 Subject: [PATCH 13/48] feat: add googleapis/release-please auto changelog generator configs --- .github/.release-please-config.json | 72 +++++++++++++++++++++++++++ .github/.release-please-manifest.json | 3 ++ 2 files changed, 75 insertions(+) create mode 100644 .github/.release-please-config.json create mode 100644 .github/.release-please-manifest.json diff --git a/.github/.release-please-config.json b/.github/.release-please-config.json new file mode 100644 index 00000000..19b22198 --- /dev/null +++ b/.github/.release-please-config.json @@ -0,0 +1,72 @@ +{ + "release-type": "node", + "packages": { + ".": { + "package-name": "database", + "changelog-path": "/CHANGELOG.md" + } + }, + "include-component-in-tag": false, + "changelog-sections": [ + { + "type": "feat", + "section": "Features", + "hidden": false + }, + { + "type": "fix", + "section": "Bug Fixes", + "hidden": false + }, + { + "type": "perf", + "section": "Performance Improvements", + "hidden": false + }, + { + "type": "docs", + "section": "Documentation", + "hidden": false + }, + { + "type": "chore", + "section": "Miscellaneous", + "hidden": false + }, + { + "type": "style", + "section": "Styles", + "hidden": true + }, + { + "type": "revert", + "section": "Reverts", + "hidden": true + }, + { + "type": "deps", + "section": "Dependencies", + "hidden": false + }, + { + "type": "refactor", + "section": "Code Refactoring", + "hidden": false + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System", + "hidden": true + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ] +} diff --git a/.github/.release-please-manifest.json b/.github/.release-please-manifest.json new file mode 100644 index 00000000..6bb50d96 --- /dev/null +++ b/.github/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "2.9.0" +} From d8ae4ac8f8b10151e078c0962aa7656cb1600cd8 Mon Sep 17 00:00:00 2001 From: Andrij Orlenko <94047334+lotyp@users.noreply.github.com> Date: Thu, 28 Mar 2024 01:27:12 +0200 Subject: [PATCH 14/48] chore(feat/infra-dx-v2): release 3.0.0 --- .github/.release-please-manifest.json | 2 +- CHANGELOG.md | 39 ++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/.github/.release-please-manifest.json b/.github/.release-please-manifest.json index 6bb50d96..bc7a84b6 100644 --- a/.github/.release-please-manifest.json +++ b/.github/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.9.0" + ".": "3.0.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index c1f1c575..b9cbebf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,41 @@ -# CHANGELOG +# Changelog + +## [3.0.0](https://github.com/cycle/database/compare/2.9.0...v3.0.0) (2024-03-27) + + +### โš  BREAKING CHANGES + +* bump minimal php version from 8.0 to 8.1 + +### Features + +* add .env file for local development and testing ([c8c6e57](https://github.com/cycle/database/commit/c8c6e5777fa64e38490564ba3c00b6f4db0c1c47)) +* add googleapis/release-please auto changelog generator configs ([2cbbff8](https://github.com/cycle/database/commit/2cbbff84dc5e14e0badd32b00e095860738002fe)) +* add pre-commit config file ([e963a39](https://github.com/cycle/database/commit/e963a399945c9aa652aee7fd11ba5ad099b29a4e)) +* add self-documenting Makefile and docker-compose for local dev dokerization ([fa62923](https://github.com/cycle/database/commit/fa6292300396c70fe1c36bbd46a000b53adfca7b)) +* add wayofdev/php-cs-fixer and roave/security-advisories ([43b6b87](https://github.com/cycle/database/commit/43b6b87ed55462f53d09d477aa82118b9171c3e9)) +* add yamllint ([397b07a](https://github.com/cycle/database/commit/397b07a180de3be5c844111c4f27d0d38ac0cb64)) +* bump minimal php version from 8.0 to 8.1 ([c3bdc70](https://github.com/cycle/database/commit/c3bdc701dfba6892a0fe6bc421d5869ce320dc2a)) +* remove style-ci dependency ([6e6a07c](https://github.com/cycle/database/commit/6e6a07c83a9365bcaf723a2863890539ab1d63d7)) + + +### Bug Fixes + +* .editorconfig ([2258e90](https://github.com/cycle/database/commit/2258e90a8a793d41af79d190bb5d235de3c58e5f)) +* production release should not contain development files ([35218e4](https://github.com/cycle/database/commit/35218e4be5ffbe30539b9fb36ab40d00e20b10b0)) + + +### Documentation + +* mention make commands in CONTRIBUTING.md ([cedd95e](https://github.com/cycle/database/commit/cedd95e94594cdd072e6c5e736727a7271351f22)) + + +### Miscellaneous + +* move CODE_OF_CONDUCT ([1a01cfb](https://github.com/cycle/database/commit/1a01cfb025b28e89995a9c97be45e6706941b5dd)) +* return back .styleci, as it bloats commits ([8a7014f](https://github.com/cycle/database/commit/8a7014f683d56da2cdfbf29bfac9cabafa27c26b)) + +## CHANGELOG v2.9.0 (27.03.2024) ------------------- From 985650820f7301e51dcfa1925a9da412d2918b87 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 01:41:54 +0200 Subject: [PATCH 15/48] docs: convert CHANGELOG.md to follow release-please format --- CHANGELOG.md | 205 ++++++++++++++++++++++++++++++--------------------- Makefile | 2 +- 2 files changed, 123 insertions(+), 84 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9cbebf8..06c28017 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,88 +35,107 @@ * move CODE_OF_CONDUCT ([1a01cfb](https://github.com/cycle/database/commit/1a01cfb025b28e89995a9c97be45e6706941b5dd)) * return back .styleci, as it bloats commits ([8a7014f](https://github.com/cycle/database/commit/8a7014f683d56da2cdfbf29bfac9cabafa27c26b)) -## CHANGELOG - -v2.9.0 (27.03.2024) -------------------- -- Added `logInterpolatedQueries` for detailed query logging and refined `logQueryParameters` to accurately log query parameters as arrays, enhancing ORM debugging and monitoring. @lotyp (#165) -- Improved logging with enriched context in Driver.php, including driver details and query parameters. @lotyp (#165) -- Improved `orderBy` method to accept a null direction parameter, providing more flexibility when constructing queries by @butschster (#167) -- Added support for PostgreSQL-specific directions **NULLS FIRST** and **NULLS LAST** for more control over null value ordering in result sets by @butschster (#167) - -v2.8.1 (08.02.2024) -------------------- -- Fix compiling of Fragment with parameters in the returning() definition by @msmakouz (#161) -- Fix comparison of Fragment in Column default value by @msmakouz (#162) - -v2.8.0 (08.02.2024) -------------------- -- The `withDatetimeMicroseconds` option now affects the interpolator by @msmakouz (#155) -- Postgres: support for multiple returning columns by @roxblnfk and @msmakouz (#157) -- MSSQL: support for multiple returning columns by @msmakouz (#160) - -v2.7.1 (22.12.2023) -------------------- -- Fix setting `precision` and `scale` through attributes by @msmakouz (#148) -- Fix quoting with an underscore at the beginning by @msmakouz (#151) -- Fix behavior of the `Column::type()` method by adding default size to column type mappings by @msmakouz (#150) - -v2.7.0 (04.12.2023) -------------------- -- Add `varbinary` support in MySQL; optimize `size` attribute by @msmakouz (#146) -- Add the ability to use WHERE IN and WHERE NOT IN with array values - The value sequence may contain `FragmentInterface` objets by @msmakouz and @roxblnfk (#147) - -v2.6.0 (02.11.2023) -------------------- -- Fix incorrect parameters processing for JOIN subqueries by @smelesh (#133) +## [2.9.0](https://github.com/cycle/database/compare/2.8.1...v2.9.0) (2024-03-27) + +### Features +* Added `logInterpolatedQueries` for detailed query logging and refined `logQueryParameters` to accurately log query parameters as arrays, enhancing ORM debugging and monitoring. @lotyp (#165) +* Improved logging with enriched context in Driver.php, including driver details and query parameters. @lotyp (#165) +* Improved `orderBy` method to accept a null direction parameter, providing more flexibility when constructing queries by @butschster (#167) +* Added support for PostgreSQL-specific directions **NULLS FIRST** and **NULLS LAST** for more control over null value ordering in result sets by @butschster (#167) + +## [2.8.1](https://github.com/cycle/database/compare/2.8.0...v2.8.1) (2024-02-08) + +### Bug Fixes +* Fix compiling of Fragment with parameters in the returning() definition by @msmakouz (#161) +* Fix comparison of Fragment in Column default value by @msmakouz (#162) + +## [2.8.0](https://github.com/cycle/database/compare/2.7.1...v2.8.0) (2024-02-08) + +### Features +* The `withDatetimeMicroseconds` option now affects the interpolator by @msmakouz (#155) +* Postgres: support for multiple returning columns by @roxblnfk and @msmakouz (#157) +* MSSQL: support for multiple returning columns by @msmakouz (#160) + +## [2.7.1](https://github.com/cycle/database/compare/2.7.0...v2.7.1) (2023-12-22) + +### Bug Fixes +* Fix setting `precision` and `scale` through attributes by @msmakouz (#148) +* Fix quoting with an underscore at the beginning by @msmakouz (#151) +* Fix behavior of the `Column::type()` method by adding default size to column type mappings by @msmakouz (#150) + +## [2.7.0](https://github.com/cycle/database/compare/2.6.0...v2.7.0) (2023-12-04) + +### Features +* Add `varbinary` support in MySQL; optimize `size` attribute by @msmakouz (#146) +* Add the ability to use WHERE IN and WHERE NOT IN with array values. The value sequence may contain `FragmentInterface` objets by @msmakouz and @roxblnfk (#147) + +## [2.6.0](https://github.com/cycle/database/compare/2.5.2...v2.6.0) (2023-11-02) + +### Features - MySQL driver: - - Add the type `smallInteger` by @gam6itko (#128) - - Change mapping of the JSON type from `text` to `json` by @romanpravda (#121) + - Add the type `smallInteger` by @gam6itko (#128) + - Change mapping of the JSON type from `text` to `json` by @romanpravda (#121) - Postgres driver: - - Add the `restartIdentity` parameter to the `eraseTable` method by @msmakouz (#132) - - Change mapping of the JSON type from `text` to `json` by @msmakouz (#134) -- All the drivers: - - Add `enableForeignKeyConstraints` and `disableForeignKeyConstraints` methods in Driver Handlers by @msmakouz (#130) - - Add an ability to disable the query cache before query using `withoutCache()` by @msmakouz and @roxblnfk (#137) + - Add the `restartIdentity` parameter to the `eraseTable` method by @msmakouz (#132) + - Change mapping of the JSON type from `text` to `json` by @msmakouz (#134) +- All the drivers: + - Add `enableForeignKeyConstraints` and `disableForeignKeyConstraints` methods in Driver Handlers by @msmakouz (#130) + - Add an ability to disable the query cache before query using `withoutCache()` by @msmakouz and @roxblnfk (#137) - JSON support: - - Add methods to work with JSON columns by @msmakouz and @roxblnfk (#135) - - Add an ability to set JSON default value as an array by @msmakouz and @roxblnfk (#138) + - Add methods to work with JSON columns by @msmakouz and @roxblnfk (#135) + - Add an ability to set JSON default value as an array by @msmakouz and @roxblnfk (#138) -v2.5.2 (03.07.2023) -------------------- +### Bug Fixes +- Fix incorrect parameters processing for JOIN subqueries by @smelesh (#133) + +## [2.5.2](https://github.com/cycle/database/compare/2.5.1...v2.5.2) (2023-07-03) + +### Bug Fixes - Fix Postgres schema restoring after reconnect by @msmakouz in (#126) -v2.5.1 (09.06.2023) -------------------- +## [2.5.1](https://github.com/cycle/database/compare/2.5.0...v2.5.1) (2023-06-09) + +### Bug Fixes - Fix drastic increase of insert statements on pg driver with complex primary keys by @wolfy-j (#122) -v2.5.0 (12.05.2023) -------------------- +## [2.5.0](https://github.com/cycle/database/compare/2.4.1...v2.5.0) (2023-05-12) + +### Features - Add ability to use non-primary serial column by @msmakouz (#106) - Add ability to configure DB port passing a string by @msmakouz (#109) - Add ability to define a custom type column by @msmakouz (#104) - Add the ability to define `readonlySchema` for columns by @msmakouz (#116) - Add `AbstractForeignKey::$index` property to enable/disable index creation by @msmakouz (#119) + +### Bug Fixes - Fix inserting an array of rowsets without calling the columns method by @msmakouz (#120) + +### Miscellaneous - Improve types for `TableInterface` and `ColumnInterface` by @vjik (#108) - Fix typos by @arogachev (#110, #111) -v2.4.1 (08.03.2023) -------------------- +## [2.4.1](https://github.com/cycle/database/compare/2.4.0...v2.4.1) (2023-03-08) + +### Bug Fixes - Fix: add schema to Postgres dependency table names by @msmakouz (#102) - Fix: don't add a table prefix when a column is quoting by @msmakouz (#103) -v2.4.0 (01.02.2023) -------------------- -- Add option `logQueryParameters` in the driver `options` to enable interpolation in SQL query logs. - Since **v2.4.0**, interpolation in logs is **disabled** by default by @msmakouz (#95) +## [2.4.0](https://github.com/cycle/database/compare/2.3.0...v2.4.0) (2023-02-01) + +### โš  BREAKING CHANGES +* Since **v2.4.0**, interpolation in logs is **disabled** by default + +### Features +- Add option `logQueryParameters` in the driver `options` to enable interpolation in SQL query logs by @msmakouz (#95) - Add PostgreSQL specific data types by @msmakouz (#93) - Add MySQL `SET` type support by @msmakouz (#92) + +### Bug Fixes - Fix Interpolator performance by @msmakouz (#94) thx @hustlahusky -v2.3.0 (27.12.2022) -------------------- +## [2.3.0](https://github.com/cycle/database/compare/2.2.2...v2.3.0) (2022-12-27) + +### Features - Add support for array values in the `IN` and `NOT IN` operators by @roxblnfk (#69, #70, #71) - Add `PdoInterface` as a possible return type for the `Driver::getPDO()` method by @roxblnfk (#76) - Add the `options` array parameter to all driver configs to pass additional driver options. @@ -125,53 +144,73 @@ v2.3.0 (27.12.2022) - Add the ability to define the `size` of a `datetime` column by @msmakouz (#86) - Add support for the unsigned and zerofill properties in MySQL Integer types by @roxblnfk (#88) -v2.2.2 (27.09.2022) -------------------- +## [2.2.2](https://github.com/cycle/database/compare/2.2.1...v2.2.2) (2022-09-27) + +### Bug Fixes - Fix transaction level changing on disconnect when transaction is starting by @roxblnfk (#76) -v2.2.1 (02.07.2022) -------------------- +## [2.2.1](https://github.com/cycle/database/compare/2.2.0...v2.2.1) (2022-07-02) + +### Bug Fixes - Hotfix: make the `$config` parameter of the `DatabaseConfig` constructor optional again by @roxblnfk -v2.2.0 (23.06.2022) -------------------- +## [2.2.0](https://github.com/cycle/database/compare/2.1.3...v2.2.0) (2022-06-23) + +### Features - Add supporting for PHP 8.1 Enumerations by @roxblnfk (#67) - Add supporting for smallint column type by @gam6itko (#58) + +### Bug Fixes - Fix typo in the `\Cycle\Database\Schema\State::forgerForeignKey` method by @BeMySlaveDarlin (#53) -- Fix compatibility with Spiral Framework 3 packages: - - Remove overriding of the `$config` property in the `DatabaseConfig` class by @roxblnfk (#64) - - Update `composer.json` dependencies -v2.1.3 (20.05.2022) -------------------- +### Miscellaneous +- Remove overriding of the `$config` property in the `DatabaseConfig` class by @roxblnfk (#64) +- Update `composer.json` dependencies + +## [2.1.3](https://github.com/cycle/database/compare/2.1.2...v2.1.3) (2022-05-20) + +### Bug Fixes - Fix query interpolation by @roxblnfk (#60) -v2.1.2 (20.01.2022) -------------------- +## [2.1.2](https://github.com/cycle/database/compare/2.1.1...v2.1.2) (2022-01-20) + +### Bug Fixes - Fix wrong bind parameter order in a select query with join by @roxblnfk (#48) - Fix access to unitialized driver property on `ActiveQuery::__debugInfo()` call by @roxblnfk (#46) -v2.1.1 (12.01.2022) -------------------- +## [2.1.1](https://github.com/cycle/database/compare/2.1.0...v2.1.1) (2022-01-12) + +### Miscellaneous - Fix phpdoc for the `SelectQuery::orderBy` method by @butschster (#45) - Fix problem with driver cloning by @butschster (#44) -v2.1.0 (31.12.2021) -------------------- -- Add `psr/log` dependency by @thgs (#35) +## [2.1.0](https://github.com/cycle/database/compare/2.0.0...v2.1.0) (2021-12-31) + +### Features +- Added `psr/log` dependency by @thgs (#35) - Add ability to get/set driver name by @butschster (#38) - Optimize fetching indexes and primary keys in Postgres driver by @hustlahusky (#37) + +### Bug Fixes - Fix type casting for column size value in the PG Column class by @rauanmayemir (#34) + +### Miscellaneous +- Add `psr/log` dependency by @thgs (#35) - Downgrade spiral dependencies to stable by @roxblnfk (#40) -v2.0.0 (22.12.2021) -------------------- -- The package moved from `spiral/database` to `cycle/database` +## [2.0.0](https://github.com/cycle/database/compare/1.0.0...v2.0.0) (2021-12-22) + +### โš  BREAKING CHANGES - Namespace `Spiral\Database` replaced with `Cycle\Database` @butschster (#1) -- Minimal PHP version is 8.0 (#26, #31) +- Minimal PHP version is 8.0 + +### Features - Added supporting for postgres schemas @butschster (#2) -- Added DTO configs @SerafimArts, @msmakouz (#10, #14) -- Improvements to `join` methods @butschster -- Tests have been restructured @butschster (#21) +- Added DTO configs @SerafimArts, @msmakouz (#10, #14) - Added method to get transaction level @msmakouz (#23) - Added `ColumnReturnableInterface` for database drivers @butschster (#25) + +### Miscellaneous +- The package moved from `spiral/database` to `cycle/database` +- Improvements to `join` methods @butschster +- Tests have been restructured @butschster (#21) diff --git a/Makefile b/Makefile index e83bf4e9..fb795709 100644 --- a/Makefile +++ b/Makefile @@ -197,7 +197,7 @@ release: ## Create a new release release-please release-pr \ --token=$(GITHUB_TOKEN) \ --repo-url=cycle/database \ - --target-branch=feat/dx \ + --target-branch=feat/infra-dx-v2 \ --config-file=.github/.release-please-config.json \ --manifest-file=.github/.release-please-manifest.json .PHONE: release From ef9f758e76d0ac551348f39685dde9e7d83ee517 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 01:47:55 +0200 Subject: [PATCH 16/48] feat: introduce .build directory to move various tool cache into one place --- .build/.gitignore | 2 ++ phpunit.xml | 1 + 2 files changed, 3 insertions(+) create mode 100644 .build/.gitignore diff --git a/.build/.gitignore b/.build/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/.build/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/phpunit.xml b/phpunit.xml index fe94c277..215148fd 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,6 @@ Date: Thu, 28 Mar 2024 02:00:21 +0200 Subject: [PATCH 17/48] ci: add release-please github action --- .github/workflows/create-release.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/create-release.yml diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 00000000..0766379a --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,26 @@ +--- + +# https://github.com/wayofdev/gh-actions/blob/master/.github/workflows/create-release.yml +# https://github.com/google-github-actions/release-please-action#release-types-supported + +on: # yamllint disable-line rule:truthy + push: + branches: + - master + +name: ๐Ÿ“ฆ Create release + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: ๐ŸŽ‰ Create release + uses: google-github-actions/release-please-action@v4 + id: release + with: + token: ${{ secrets.GITHUB_TOKEN }} + config-file: .github/.release-please-config.json + manifest-file: .github/.release-please-manifest.json + target-branch: 2.x + +... From b7b65c5fc0b39836069048254da3968566cf0998 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 02:43:09 +0200 Subject: [PATCH 18/48] ci: refactoring github actions --- .github/labeler.yml | 14 ++++ .github/workflows/apply-labels.yml | 23 +++++++ .github/workflows/ci-mssql.yml | 88 ------------------------ .github/workflows/ci-mysql.yml | 98 --------------------------- .github/workflows/ci-pgsql.yml | 99 --------------------------- .github/workflows/ci.yml | 70 +++++++++++++++++++ .github/workflows/main.yml | 104 ----------------------------- 7 files changed, 107 insertions(+), 389 deletions(-) create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/apply-labels.yml delete mode 100644 .github/workflows/ci-mssql.yml delete mode 100644 .github/workflows/ci-mysql.yml delete mode 100644 .github/workflows/ci-pgsql.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/main.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000..7b296400 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,14 @@ +--- + +# this file is for the labeler workflow job +# Documentation https://github.com/marketplace/actions/labeler + +"type: documentation": + - changed-files: + - any-glob-to-any-file: [resources/*, .github/*, ./*.md] + +"type: maintenance": + - changed-files: + - any-glob-to-any-file: [tests/**/*, .github/workflows/*] + +... diff --git a/.github/workflows/apply-labels.yml b/.github/workflows/apply-labels.yml new file mode 100644 index 00000000..c9b1196b --- /dev/null +++ b/.github/workflows/apply-labels.yml @@ -0,0 +1,23 @@ +--- + +# This workflow will triage pull requests and apply a label based on the +# paths that are modified in the pull request. +# +# To use this workflow, you will need to set up a .github/labeler.yml +# file with configuration. For more information, see: +# https://github.com/actions/labeler/blob/master/README.md + +on: # yamllint disable-line rule:truthy + pull_request: + +name: ๐Ÿท๏ธ Add labels + +jobs: + label: + uses: wayofdev/gh-actions/.github/workflows/apply-labels.yml@master + with: + os: ubuntu-latest + secrets: + token: ${{ secrets.GITHUB_TOKEN }} + +... diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml deleted file mode 100644 index 4eec0818..00000000 --- a/.github/workflows/ci-mssql.yml +++ /dev/null @@ -1,88 +0,0 @@ -on: - push: - branches: - - master - - '*.*' - - '*.*.*' - pull_request: null - -name: ci-mssql - -jobs: - tests: - name: PHP ${{ matrix.php }}-mssql-${{ matrix.mssql }} - - env: - key: cache - - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - include: - - php: '8.0' - extensions: pdo, pdo_sqlsrv - mssql: 'server:2017-latest' - - php: '8.0' - extensions: pdo, pdo_sqlsrv - mssql: 'server:2019-latest' - - php: '8.1' - extensions: pdo, pdo_sqlsrv - mssql: 'server:2019-latest' - - php: '8.2' - extensions: pdo, pdo_sqlsrv - mssql: 'server:2019-latest' - - php: '8.3' - extensions: pdo, pdo_sqlsrv - mssql: 'server:2019-latest' - - services: - mssql: - image: mcr.microsoft.com/mssql/${{ matrix.mssql }} - env: - SA_PASSWORD: SSpaSS__1 - ACCEPT_EULA: Y - MSSQL_PID: Developer - ports: - - 11433:1433 - options: --name=mssql --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'SSpaSS__1' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3 - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install PHP with extensions - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: ${{ matrix.extensions }} - ini-values: date.timezone='UTC' - tools: composer:v2, pecl - - - name: Determine composer cache directory on Linux - run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV - - - name: Cache dependencies installed with composer - uses: actions/cache@v2 - with: - path: ${{ env.COMPOSER_CACHE_DIR }} - key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: | - php${{ matrix.php }}-composer- - - - name: Update composer - run: composer self-update - - - name: Install dependencies with composer - if: matrix.php != '8.3' - run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Install dependencies with composer php 8.3 - if: matrix.php == '8.3' - run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Run tests with phpunit without coverage - env: - DB: sqlserver - run: vendor/bin/phpunit --group driver-sqlserver --colors=always diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml deleted file mode 100644 index 68493a65..00000000 --- a/.github/workflows/ci-mysql.yml +++ /dev/null @@ -1,98 +0,0 @@ -on: - push: - branches: - - master - - '*.*' - - '*.*.*' - pull_request: null - -name: ci-mysql - -jobs: - tests: - name: PHP ${{ matrix.php-version }}-mysql-${{ matrix.mysql-version }} - env: - extensions: curl, intl, pdo, pdo_mysql - key: cache-v1 - - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - - php-version: - - "8.0" - - "8.1" - - "8.2" - - "8.3" - - mysql-version: - - "5.7" - - "8.0" - - services: - mysql: - image: mysql:${{ matrix.mysql-version }} - env: - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: spiral - MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password - ports: - - 13306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup cache environment - id: cache-env - uses: shivammathur/cache-extensions@v1 - with: - php-version: ${{ matrix.php-version }} - extensions: ${{ env.extensions }} - key: ${{ env.key }} - - - name: Cache extensions - uses: actions/cache@v2 - with: - path: ${{ steps.cache-env.outputs.dir }} - key: ${{ steps.cache-env.outputs.key }} - restore-keys: ${{ steps.cache-env.outputs.key }} - - - name: Install PHP with extensions - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - extensions: ${{ env.extensions }} - ini-values: date.timezone='UTC' - coverage: pcov - - - name: Determine composer cache directory - if: matrix.os == 'ubuntu-latest' - run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV - - - name: Cache dependencies installed with composer - uses: actions/cache@v2 - with: - path: ${{ env.COMPOSER_CACHE_DIR }} - key: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }} - restore-keys: | - php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- - - - name: Install dependencies with composer - if: matrix.php-version != '8.3' - run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Install dependencies with composer php 8.3 - if: matrix.php-version == '8.3' - run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Run mysql tests with phpunit - env: - DB: mysql - MYSQL: ${{ matrix.mysql-version }} - run: vendor/bin/phpunit --group driver-mysql --colors=always diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml deleted file mode 100644 index 2e18020b..00000000 --- a/.github/workflows/ci-pgsql.yml +++ /dev/null @@ -1,99 +0,0 @@ -on: - push: - branches: - - master - - '*.*' - - '*.*.*' - pull_request: null - -name: ci-pgsql - -jobs: - tests: - name: PHP ${{ matrix.php-version }}-pgsql-${{ matrix.pgsql-version }} - env: - extensions: curl, intl, pdo, pdo_pgsql - key: cache-v1 - - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - php-version: - - "8.0" - - "8.1" - - "8.2" - - "8.3" - - pgsql-version: - - "10" - - "11" - - "12" - - "13" - - services: - postgres: - image: postgres:${{ matrix.pgsql-version }} - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: spiral - ports: - - 15432:5432 - options: --name=postgres --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3 - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup cache environment - id: cache-env - uses: shivammathur/cache-extensions@v1 - with: - php-version: ${{ matrix.php-version }} - extensions: ${{ env.extensions }} - key: ${{ env.key }} - - - name: Cache extensions - uses: actions/cache@v2 - with: - path: ${{ steps.cache-env.outputs.dir }} - key: ${{ steps.cache-env.outputs.key }} - restore-keys: ${{ steps.cache-env.outputs.key }} - - - name: Install PHP with extensions - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - extensions: ${{ env.extensions }} - ini-values: date.timezone='UTC' - coverage: pcov - - - name: Determine composer cache directory - if: matrix.os == 'ubuntu-latest' - run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV - - - name: Cache dependencies installed with composer - uses: actions/cache@v2 - with: - path: ${{ env.COMPOSER_CACHE_DIR }} - key: php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.json') }} - restore-keys: | - php${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- - - - name: Install dependencies with composer - if: matrix.php-version != '8.3' - run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Install dependencies with composer php 8.3 - if: matrix.php-version == '8.3' - run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Run pgsql tests with phpunit - env: - DB: postgres - POSTGRES: ${{ matrix.pgsql-version }} - run: vendor/bin/phpunit --group driver-postgres --colors=always diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..b3c1ca17 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,70 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - master + +name: ๐Ÿ” Integration + +jobs: + code-coverage: + name: ๐Ÿ“Š Code coverage + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: + - "ubuntu-latest" + php-version: + - "8.1" + - "8.2" + - "8.3" + dependencies: + - "locked" + + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, pdo, pdo_sqlite, pdo_pgsql, pdo_sqlsrv, pdo_mysql + ini-values: error_reporting=E_ALL + tools: composer:v2, pecl + coverage: xdebug + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Determine composer cache directory + run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir --working-dir=.)" >> $GITHUB_ENV + shell: bash + + - name: โ™ป๏ธ Cache dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + run: composer install --ansi --no-interaction --no-progress --working-dir="." + + - name: ๐Ÿšœ Collect code coverage with Xdebug and phpunit/phpunit + env: + XDEBUG_MODE: coverage + run: vendor/bin/phpunit --colors=always --configuration=phpunit.xml --coverage-clover=.build/phpunit/logs/clover.xml + + - name: ๐Ÿ“ค Upload code coverage report to Codecov + uses: codecov/codecov-action@v4.1.1 + with: + files: .build/phpunit/logs/clover.xml + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index f8281536..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: build - -on: - push: - branches: - - master - - '*.*' - - '*.*.*' - pull_request: null - -jobs: - test: - name: Test PHP ${{ matrix.php-versions }} with Code Coverage - runs-on: ubuntu-latest - strategy: - matrix: - php-versions: ['8.0', '8.1', '8.2', '8.3'] - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup DB services - run: | - cd tests - docker-compose up -d - cd .. - - name: Setup PHP ${{ matrix.php-versions }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - coverage: pcov - tools: pecl - extensions: mbstring, pdo, pdo_sqlite, pdo_pgsql, pdo_sqlsrv, pdo_mysql - - name: Get Composer Cache Directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Restore Composer Cache - uses: actions/cache@v2 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install dependencies with composer - if: matrix.php-versions != '8.3' - run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Install dependencies with composer php 8.3 - if: matrix.php-versions == '8.3' - run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Execute Tests - run: | - vendor/bin/phpunit --coverage-clover=coverage.clover - - name: Upload coverage to Codecov - continue-on-error: true # if is fork - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: ./coverage.clover - - name: Upload coverage to Scrutinizer - continue-on-error: true # if is fork - uses: sudo-bot/action-scrutinizer@latest - with: - cli-args: "--format=php-clover coverage.clover" - - sqlite: - name: SQLite PHP ${{ matrix.php-versions }} - runs-on: ubuntu-latest - strategy: - matrix: - php-versions: ['8.0', '8.1', '8.2', '8.3'] - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup PHP ${{ matrix.php-versions }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - coverage: pcov - tools: pecl - extensions: mbstring, pdo, pdo_sqlite - - name: Get Composer Cache Directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Restore Composer Cache - uses: actions/cache@v2 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install dependencies with composer - if: matrix.php-versions != '8.3' - run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Install dependencies with composer php 8.3 - if: matrix.php-versions == '8.3' - run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi - - - name: Execute Tests - env: - DB: sqlite - run: | - vendor/bin/phpunit --group driver-sqlite --colors=always From 17aac80d4fc04252691f3d84e5335c2543f49f32 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 02:47:02 +0200 Subject: [PATCH 19/48] style: lint composer.json using `composer normalize` command --- composer.json | 98 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 40 deletions(-) diff --git a/composer.json b/composer.json index 6eb3cfa1..c412317a 100644 --- a/composer.json +++ b/composer.json @@ -1,24 +1,18 @@ { "name": "cycle/database", - "type": "library", "description": "DBAL, schema introspection, migration and pagination", - "keywords": ["dbal", "database", "mysql", "mssql", "sqlite", "postgresql", "orm", "sql", "query-builder"], "license": "MIT", - "conflict": { - "spiral/database": "*" - }, - "homepage": "https://cycle-orm.dev", - "support": { - "issues": "https://github.com/cycle/database/issues", - "source": "https://github.com/cycle/database", - "docs": "https://cycle-orm.dev/docs", - "chat": "https://discord.gg/spiralphp" - }, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/cycle" - } + "type": "library", + "keywords": [ + "dbal", + "database", + "mysql", + "mssql", + "sqlite", + "postgresql", + "orm", + "sql", + "query-builder" ], "authors": [ { @@ -38,6 +32,19 @@ "email": "pavel.buchnev@spiralscout.com" } ], + "homepage": "https://cycle-orm.dev", + "support": { + "issues": "https://github.com/cycle/database/issues", + "chat": "https://discord.gg/spiralphp", + "source": "https://github.com/cycle/database", + "docs": "https://cycle-orm.dev/docs" + }, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/cycle" + } + ], "require": { "php": ">=8.1", "ext-pdo": "*", @@ -46,44 +53,55 @@ "spiral/pagination": "^2.8 || ^3.0", "symfony/polyfill-php83": "^1.29" }, - "autoload": { - "files": [ - "src/polyfill.php", - "src/functions_polyfill.php" - ], - "psr-4": { - "Cycle\\Database\\": "src" - } - }, "require-dev": { + "ergebnis/composer-normalize": "^2.42", "infection/infection": "^0.26", "mockery/mockery": "^1.6", "phpunit/phpunit": "^9.6", - "spiral/tokenizer": "^2.14 | ^3.0", - "vimeo/psalm": "^5.23", "roave/security-advisories": "dev-latest", + "spiral/tokenizer": "^2.14 || ^3.0", + "vimeo/psalm": "^5.23", "wayofdev/cs-fixer-config": "^1.2" }, + "conflict": { + "spiral/database": "*" + }, + "minimum-stability": "dev", + "prefer-stable": true, + "autoload": { + "psr-4": { + "Cycle\\Database\\": "src" + }, + "files": [ + "src/polyfill.php", + "src/functions_polyfill.php" + ] + }, "autoload-dev": { "psr-4": { "Cycle\\Database\\Tests\\": "tests/Database" } }, - "scripts": { - "cs:fix": "php vendor/bin/php-cs-fixer fix -v", - "cs:diff": "php vendor/bin/php-cs-fixer fix --dry-run -v --diff", - "test": "php vendor/bin/phpunit --colors=always", - "test:cc": "php vendor/bin/phpunit --colors=always --coverage", - "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite", - "psalm": "php vendor/bin/psalm --no-cache", - "psalm:ci": "php vendor/bin/psalm --no-cache --error-format=github" - }, "config": { - "sort-packages": true, "allow-plugins": { + "ergebnis/composer-normalize": true, "infection/extension-installer": true + }, + "sort-packages": true + }, + "extra": { + "composer-normalize": { + "indent-size": 4, + "indent-style": "space" } }, - "minimum-stability": "dev", - "prefer-stable": true + "scripts": { + "cs:diff": "php vendor/bin/php-cs-fixer fix --dry-run -v --diff", + "cs:fix": "php vendor/bin/php-cs-fixer fix -v", + "psalm": "php vendor/bin/psalm --no-cache", + "psalm:ci": "php vendor/bin/psalm --no-cache --error-format=github", + "test": "php vendor/bin/phpunit --colors=always", + "test:cc": "php vendor/bin/phpunit --colors=always --coverage", + "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite" + } } From d686f42bbf3c34b7714f6ca5a83ef75e3788a211 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 02:48:28 +0200 Subject: [PATCH 20/48] ci: fix target branch for new CI actions --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b3c1ca17..580594ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ on: # yamllint disable-line rule:truthy pull_request: branches: - - master + - 2.x name: ๐Ÿ” Integration From 66a618baccf052165000fabcd5941dc2eb250b9d Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 02:54:41 +0200 Subject: [PATCH 21/48] ci: run coverage against sqlite --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 580594ba..16cd35df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: - name: ๐Ÿšœ Collect code coverage with Xdebug and phpunit/phpunit env: XDEBUG_MODE: coverage - run: vendor/bin/phpunit --colors=always --configuration=phpunit.xml --coverage-clover=.build/phpunit/logs/clover.xml + run: vendor/bin/phpunit --group=driver-sqlite --colors=always --configuration=phpunit.xml --coverage-clover=.build/phpunit/logs/clover.xml - name: ๐Ÿ“ค Upload code coverage report to Codecov uses: codecov/codecov-action@v4.1.1 From 5ff4a406508d9779b261441bccbd04b673cf39c8 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 02:56:40 +0200 Subject: [PATCH 22/48] chore: trigger actions to check if composer cache works --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16cd35df..04694641 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ name: ๐Ÿ” Integration jobs: code-coverage: - name: ๐Ÿ“Š Code coverage + name: ๐Ÿ“Š Coverage runs-on: ${{ matrix.os }} strategy: fail-fast: true From 99ca6a5fa1a086598e61f915ddce40e7bc9800d7 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 03:24:00 +0200 Subject: [PATCH 23/48] ci: add coding-standards job --- .github/workflows/ci.yml | 73 +++++++++++++++++++++++++++++++++++++--- composer.json | 2 +- 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04694641..a6f8c6a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,9 +17,7 @@ jobs: os: - "ubuntu-latest" php-version: - - "8.1" - "8.2" - - "8.3" dependencies: - "locked" @@ -31,7 +29,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} - extensions: mbstring, pdo, pdo_sqlite, pdo_pgsql, pdo_sqlsrv, pdo_mysql + extensions: mbstring, pdo, pdo_sqlite ini-values: error_reporting=E_ALL tools: composer:v2, pecl coverage: xdebug @@ -48,7 +46,7 @@ jobs: run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir --working-dir=.)" >> $GITHUB_ENV shell: bash - - name: โ™ป๏ธ Cache dependencies installed with composer + - name: โ™ป๏ธ Restore cached dependencies installed with composer uses: actions/cache@v4.0.2 with: path: ${{ env.COMPOSER_CACHE_DIR }} @@ -58,7 +56,7 @@ jobs: - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies run: composer install --ansi --no-interaction --no-progress --working-dir="." - - name: ๐Ÿšœ Collect code coverage with Xdebug and phpunit/phpunit + - name: ๐Ÿงช Collect code coverage with Xdebug and phpunit/phpunit env: XDEBUG_MODE: coverage run: vendor/bin/phpunit --group=driver-sqlite --colors=always --configuration=phpunit.xml --coverage-clover=.build/phpunit/logs/clover.xml @@ -68,3 +66,68 @@ jobs: with: files: .build/phpunit/logs/clover.xml token: ${{ secrets.CODECOV_TOKEN }} + + coding-standards: + name: ๐Ÿ“ Coding Standards + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: + - "ubuntu-latest" + php-version: + - "8.2" + dependencies: + - "locked" + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, pdo, pdo_sqlite + ini-values: error_reporting=E_ALL + tools: composer:v2, pecl + coverage: xdebug + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Determine composer cache directory + run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir --working-dir=.)" >> $GITHUB_ENV + shell: bash + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + run: composer install --ansi --no-interaction --no-progress --working-dir="." + + - name: ๐Ÿ› ๏ธ Prepare environment + run: | + mkdir -p ./.build/php-cs-fixer + + - name: โ™ป๏ธ Restore php-cs-fixer cache + uses: actions/cache@v4 + with: + path: .build/php-cs-fixer + key: php-${{ matrix.php-version }}-php-cs-fixer-${{ github.ref_name }} + restore-keys: | + php-${{ matrix.php-version }}-php-cs-fixer-master + php-${{ matrix.php-version }}-php-cs-fixer- + + - name: ๐Ÿšจ Run coding standards task + run: composer cs:diff + env: + PHP_CS_FIXER_IGNORE_ENV: true diff --git a/composer.json b/composer.json index c412317a..a803b9cc 100644 --- a/composer.json +++ b/composer.json @@ -96,7 +96,7 @@ } }, "scripts": { - "cs:diff": "php vendor/bin/php-cs-fixer fix --dry-run -v --diff", + "cs:diff": "php vendor/bin/php-cs-fixer fix --dry-run --verbose --diff --show-progress=dots", "cs:fix": "php vendor/bin/php-cs-fixer fix -v", "psalm": "php vendor/bin/psalm --no-cache", "psalm:ci": "php vendor/bin/psalm --no-cache --error-format=github", From ef18b288b5b5f89292604007f3d4bd3b8ad99352 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 03:33:45 +0200 Subject: [PATCH 24/48] ci: add static-analysis job --- .github/workflows/ci.yml | 59 ++++++++++++++++++++++++++++++++++++++++ composer.json | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6f8c6a8..25601d90 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,9 @@ jobs: code-coverage: name: ๐Ÿ“Š Coverage runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} strategy: fail-fast: true matrix: @@ -70,6 +73,9 @@ jobs: coding-standards: name: ๐Ÿ“ Coding Standards runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} strategy: fail-fast: true matrix: @@ -131,3 +137,56 @@ jobs: run: composer cs:diff env: PHP_CS_FIXER_IGNORE_ENV: true + + static-analysis: + name: ๐Ÿงช Static Analysis + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + strategy: + fail-fast: true + matrix: + os: + - "ubuntu-latest" + php-version: + - "8.2" + dependencies: + - "locked" + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, pdo, pdo_sqlite + ini-values: error_reporting=E_ALL + tools: composer:v2, pecl + coverage: xdebug + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Determine composer cache directory + run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir --working-dir=.)" >> $GITHUB_ENV + shell: bash + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + run: composer install --ansi --no-interaction --no-progress --working-dir="." + + - name: ๐Ÿ” Run static analysis using psalm + run: composer psalm:ci diff --git a/composer.json b/composer.json index a803b9cc..9c78f246 100644 --- a/composer.json +++ b/composer.json @@ -99,7 +99,7 @@ "cs:diff": "php vendor/bin/php-cs-fixer fix --dry-run --verbose --diff --show-progress=dots", "cs:fix": "php vendor/bin/php-cs-fixer fix -v", "psalm": "php vendor/bin/psalm --no-cache", - "psalm:ci": "php vendor/bin/psalm --no-cache --error-format=github", + "psalm:ci": "php vendor/bin/psalm --no-cache --output-format=compact", "test": "php vendor/bin/phpunit --colors=always", "test:cc": "php vendor/bin/phpunit --colors=always --coverage", "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite" From 014fe004e23cd9a10231afc4908c92fd03914925 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 03:49:07 +0200 Subject: [PATCH 25/48] ci: fix concurrency, set psalm format to github output --- .github/workflows/ci.yml | 6 +++--- composer.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25601d90..b2742812 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true - group: ${{ github.workflow }}-${{ github.ref }} + group: coverage-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} strategy: fail-fast: true matrix: @@ -75,7 +75,7 @@ jobs: runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true - group: ${{ github.workflow }}-${{ github.ref }} + group: coding-standards-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} strategy: fail-fast: true matrix: @@ -143,7 +143,7 @@ jobs: runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true - group: ${{ github.workflow }}-${{ github.ref }} + group: static-analysis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} strategy: fail-fast: true matrix: diff --git a/composer.json b/composer.json index 9c78f246..61345706 100644 --- a/composer.json +++ b/composer.json @@ -98,8 +98,8 @@ "scripts": { "cs:diff": "php vendor/bin/php-cs-fixer fix --dry-run --verbose --diff --show-progress=dots", "cs:fix": "php vendor/bin/php-cs-fixer fix -v", - "psalm": "php vendor/bin/psalm --no-cache", - "psalm:ci": "php vendor/bin/psalm --no-cache --output-format=compact", + "psalm": "php vendor/bin/psalm --output-format=compact", + "psalm:ci": "php vendor/bin/psalm --output-format=github --shepherd --show-info=false --stats --threads=4", "test": "php vendor/bin/phpunit --colors=always", "test:cc": "php vendor/bin/phpunit --colors=always --coverage", "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite" From d4f889b660639cc5553282131050c82852b1382f Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 03:53:06 +0200 Subject: [PATCH 26/48] deps(composer): add psalm/plugin-phpunit dependency --- composer.json | 1 + psalm.xml | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 61345706..ef4e4791 100644 --- a/composer.json +++ b/composer.json @@ -58,6 +58,7 @@ "infection/infection": "^0.26", "mockery/mockery": "^1.6", "phpunit/phpunit": "^9.6", + "psalm/plugin-phpunit": "^0.19.0", "roave/security-advisories": "dev-latest", "spiral/tokenizer": "^2.14 || ^3.0", "vimeo/psalm": "^5.23", diff --git a/psalm.xml b/psalm.xml index cee9b773..1246a88b 100644 --- a/psalm.xml +++ b/psalm.xml @@ -14,14 +14,17 @@ addParamDefaultToDocblockType="true" > - - - + + + - + - + + + + From 3a70d7cb23fe0ecbdfa0e65f1ed916131fc19ae4 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 04:11:03 +0200 Subject: [PATCH 27/48] ci: add mutation-testing job --- .github/workflows/ci.yml | 51 ++++++++++++++++++++++++++++++++++++++++ Makefile | 8 +++++++ composer.json | 4 +++- 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2742812..57acd0cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -190,3 +190,54 @@ jobs: - name: ๐Ÿ” Run static analysis using psalm run: composer psalm:ci + + mutation-testing: + name: ๐Ÿงช Mutation Testing + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: mutation-testing-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - "ubuntu-latest" + php-version: + - "8.2" + dependencies: + - "locked" + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, pdo, pdo_sqlite + ini-values: error_reporting=E_ALL + tools: composer:v2, pecl + coverage: xdebug + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Determine composer cache directory + run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir --working-dir=.)" >> $GITHUB_ENV + shell: bash + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + run: composer install --ansi --no-interaction --no-progress --working-dir="." + + - name: ๐Ÿงช Run mutation testing using Xdebug and infection/infection + run: composer infection:ci diff --git a/Makefile b/Makefile index fb795709..edd556b2 100644 --- a/Makefile +++ b/Makefile @@ -175,6 +175,14 @@ lint-psalm-ci: $(APP_COMPOSER) psalm:ci .PHONY: lint-psalm-ci +lint-infect: ## Runs infection โ€“ mutation testing framework + $(APP_COMPOSER) infection +.PHONY: lint-infect + +lint-infect-ci: ## Runs infection โ€“ mutation testing framework + $(APP_COMPOSER) infection:ci +.PHONY: lint-infect-ci + test: ## Run project php-unit tests $(APP_COMPOSER) test .PHONY: test diff --git a/composer.json b/composer.json index ef4e4791..9539c3ca 100644 --- a/composer.json +++ b/composer.json @@ -103,6 +103,8 @@ "psalm:ci": "php vendor/bin/psalm --output-format=github --shepherd --show-info=false --stats --threads=4", "test": "php vendor/bin/phpunit --colors=always", "test:cc": "php vendor/bin/phpunit --colors=always --coverage", - "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite" + "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite", + "infection": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github", + "infection:ci": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github" } } From 831fb04c57a72ed9103b8168f28b5ce82e3523f5 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 13:36:35 +0200 Subject: [PATCH 28/48] ci: add action to test against pgsql --- .github/workflows/ci-pgsql.yml | 74 ++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 70 +++++++++++++++++--------------- composer.json | 12 ++++-- 3 files changed, 120 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/ci-pgsql.yml diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml new file mode 100644 index 00000000..c14c07a7 --- /dev/null +++ b/.github/workflows/ci-pgsql.yml @@ -0,0 +1,74 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - 2.x + +name: ๐Ÿ” Integration with PostgreSQL + +jobs: + test-pgsql: + name: ๐Ÿงช Integration testing with PostgreSQL + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: + - 'ubuntu-latest' + php-version: + - '8.1' + - '8.2' + - '8.3' + dependencies: + - lowest + - locked + - highest + pgsql-version: + - 13 + + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.1 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@v2.30.1 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, pdo, pdo_sqlite, json + ini-values: error_reporting=E_ALL + tools: composer:v2, pecl + coverage: none + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ—‘๏ธ Remove PHP platform configuration + if: "matrix.dependencies != 'locked'" + run: composer config platform.php --ansi --unset + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + uses: wayofdev/gh-actions/actions/composer/install@master + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿงช Run unit tests with phpunit + run: php vendor/bin/phpunit --colors=always -testsuite=Unit + + - name: ๐Ÿงช Run integration tests with phpunit + run: php vendor/bin/phpunit --colors=always --testsuite=Cycle DBAL diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57acd0cf..29c5233e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,18 +18,18 @@ jobs: fail-fast: true matrix: os: - - "ubuntu-latest" + - ubuntu-latest php-version: - - "8.2" + - '8.1' dependencies: - - "locked" + - locked steps: - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v4 + uses: actions/checkout@v4.1.1 - name: ๐Ÿ› ๏ธ Setup PHP - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@v2.30.1 with: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite @@ -45,9 +45,8 @@ jobs: - name: ๐Ÿค– Validate composer.json and composer.lock run: composer validate --ansi --strict - - name: ๐Ÿ” Determine composer cache directory - run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir --working-dir=.)" >> $GITHUB_ENV - shell: bash + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master - name: โ™ป๏ธ Restore cached dependencies installed with composer uses: actions/cache@v4.0.2 @@ -57,7 +56,9 @@ jobs: restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies - run: composer install --ansi --no-interaction --no-progress --working-dir="." + uses: wayofdev/gh-actions/actions/composer/install@master + with: + dependencies: ${{ matrix.dependencies }} - name: ๐Ÿงช Collect code coverage with Xdebug and phpunit/phpunit env: @@ -82,15 +83,15 @@ jobs: os: - "ubuntu-latest" php-version: - - "8.2" + - "8.1" dependencies: - "locked" steps: - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v4 + uses: actions/checkout@v4.1.1 - name: ๐Ÿ› ๏ธ Setup PHP - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@v2.30.1 with: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite @@ -106,19 +107,20 @@ jobs: - name: ๐Ÿค– Validate composer.json and composer.lock run: composer validate --ansi --strict - - name: ๐Ÿ” Determine composer cache directory - run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir --working-dir=.)" >> $GITHUB_ENV - shell: bash + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master - name: โ™ป๏ธ Restore cached dependencies installed with composer - uses: actions/cache@v4 + uses: actions/cache@v4.0.2 with: path: ${{ env.COMPOSER_CACHE_DIR }} key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies - run: composer install --ansi --no-interaction --no-progress --working-dir="." + uses: wayofdev/gh-actions/actions/composer/install@master + with: + dependencies: ${{ matrix.dependencies }} - name: ๐Ÿ› ๏ธ Prepare environment run: | @@ -150,15 +152,15 @@ jobs: os: - "ubuntu-latest" php-version: - - "8.2" + - "8.1" dependencies: - "locked" steps: - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v4 + uses: actions/checkout@v4.1.1 - name: ๐Ÿ› ๏ธ Setup PHP - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@v2.30.1 with: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite @@ -174,19 +176,20 @@ jobs: - name: ๐Ÿค– Validate composer.json and composer.lock run: composer validate --ansi --strict - - name: ๐Ÿ” Determine composer cache directory - run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir --working-dir=.)" >> $GITHUB_ENV - shell: bash + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master - name: โ™ป๏ธ Restore cached dependencies installed with composer - uses: actions/cache@v4 + uses: actions/cache@v4.0.2 with: path: ${{ env.COMPOSER_CACHE_DIR }} key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies - run: composer install --ansi --no-interaction --no-progress --working-dir="." + uses: wayofdev/gh-actions/actions/composer/install@master + with: + dependencies: ${{ matrix.dependencies }} - name: ๐Ÿ” Run static analysis using psalm run: composer psalm:ci @@ -203,15 +206,15 @@ jobs: os: - "ubuntu-latest" php-version: - - "8.2" + - "8.1" dependencies: - "locked" steps: - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v4 + uses: actions/checkout@v4.1.1 - name: ๐Ÿ› ๏ธ Setup PHP - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@v2.30.1 with: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite @@ -225,19 +228,20 @@ jobs: - name: ๐Ÿค– Validate composer.json and composer.lock run: composer validate --ansi --strict - - name: ๐Ÿ” Determine composer cache directory - run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir --working-dir=.)" >> $GITHUB_ENV - shell: bash + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master - name: โ™ป๏ธ Restore cached dependencies installed with composer - uses: actions/cache@v4 + uses: actions/cache@v4.0.2 with: path: ${{ env.COMPOSER_CACHE_DIR }} key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies - run: composer install --ansi --no-interaction --no-progress --working-dir="." + uses: wayofdev/gh-actions/actions/composer/install@master + with: + dependencies: ${{ matrix.dependencies }} - name: ๐Ÿงช Run mutation testing using Xdebug and infection/infection run: composer infection:ci diff --git a/composer.json b/composer.json index 9539c3ca..7d18fa81 100644 --- a/composer.json +++ b/composer.json @@ -88,6 +88,12 @@ "ergebnis/composer-normalize": true, "infection/extension-installer": true }, + "audit": { + "abandoned": "report" + }, + "platform": { + "php": "8.1.26" + }, "sort-packages": true }, "extra": { @@ -99,12 +105,12 @@ "scripts": { "cs:diff": "php vendor/bin/php-cs-fixer fix --dry-run --verbose --diff --show-progress=dots", "cs:fix": "php vendor/bin/php-cs-fixer fix -v", + "infection": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github", + "infection:ci": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github", "psalm": "php vendor/bin/psalm --output-format=compact", "psalm:ci": "php vendor/bin/psalm --output-format=github --shepherd --show-info=false --stats --threads=4", "test": "php vendor/bin/phpunit --colors=always", "test:cc": "php vendor/bin/phpunit --colors=always --coverage", - "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite", - "infection": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github", - "infection:ci": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github" + "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite" } } From fa3c4d0b919297ff7b94639432470c9d3f2db0cd Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 13:45:56 +0200 Subject: [PATCH 29/48] ci: fix version for php setup action --- .github/workflows/ci-pgsql.yml | 3 +-- .github/workflows/ci.yml | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index c14c07a7..ccfc1201 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -9,7 +9,6 @@ name: ๐Ÿ” Integration with PostgreSQL jobs: test-pgsql: - name: ๐Ÿงช Integration testing with PostgreSQL runs-on: ${{ matrix.os }} strategy: fail-fast: true @@ -32,7 +31,7 @@ jobs: uses: actions/checkout@v4.1.1 - name: ๐Ÿ› ๏ธ Setup PHP - uses: shivammathur/setup-php@v2.30.1 + uses: shivammathur/setup-php@2.30.1 with: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite, json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29c5233e..15b26d35 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,6 @@ name: ๐Ÿ” Integration jobs: code-coverage: - name: ๐Ÿ“Š Coverage runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true @@ -29,7 +28,7 @@ jobs: uses: actions/checkout@v4.1.1 - name: ๐Ÿ› ๏ธ Setup PHP - uses: shivammathur/setup-php@v2.30.1 + uses: shivammathur/setup-php@2.30.1 with: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite @@ -72,7 +71,6 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} coding-standards: - name: ๐Ÿ“ Coding Standards runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true @@ -91,7 +89,7 @@ jobs: uses: actions/checkout@v4.1.1 - name: ๐Ÿ› ๏ธ Setup PHP - uses: shivammathur/setup-php@v2.30.1 + uses: shivammathur/setup-php@2.30.1 with: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite @@ -141,7 +139,6 @@ jobs: PHP_CS_FIXER_IGNORE_ENV: true static-analysis: - name: ๐Ÿงช Static Analysis runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true @@ -160,7 +157,7 @@ jobs: uses: actions/checkout@v4.1.1 - name: ๐Ÿ› ๏ธ Setup PHP - uses: shivammathur/setup-php@v2.30.1 + uses: shivammathur/setup-php@2.30.1 with: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite @@ -195,7 +192,6 @@ jobs: run: composer psalm:ci mutation-testing: - name: ๐Ÿงช Mutation Testing runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true @@ -214,7 +210,7 @@ jobs: uses: actions/checkout@v4.1.1 - name: ๐Ÿ› ๏ธ Setup PHP - uses: shivammathur/setup-php@v2.30.1 + uses: shivammathur/setup-php@2.30.1 with: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite From 522cdcaa5e1eca2b12ecc5e90b1ac0e6d2fb014c Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 13:50:50 +0200 Subject: [PATCH 30/48] fix: typo in gh-actions --- .github/workflows/ci-pgsql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index ccfc1201..5b64c6e1 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -67,7 +67,7 @@ jobs: dependencies: ${{ matrix.dependencies }} - name: ๐Ÿงช Run unit tests with phpunit - run: php vendor/bin/phpunit --colors=always -testsuite=Unit + run: php vendor/bin/phpunit --colors=always --testsuite=Unit - name: ๐Ÿงช Run integration tests with phpunit run: php vendor/bin/phpunit --colors=always --testsuite=Cycle DBAL From 7b555e8a0c853d0cedc6afa711c4cabfbbc6b6fe Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 14:07:15 +0200 Subject: [PATCH 31/48] ci: add postgres service as depdendency --- .github/workflows/ci-pgsql.yml | 19 +++++++++++++++++-- phpunit.xml | 10 ++-------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index 5b64c6e1..02ee7a1f 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -24,7 +24,22 @@ jobs: - locked - highest pgsql-version: - - 13 + - '13-alpine' + + services: + pgsql: + image: postgres:${{ matrix.pgsql-version }} + env: + POSTGRES_DB: spiral + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 15432:5432 steps: - name: ๐Ÿ“ฆ Check out the codebase @@ -70,4 +85,4 @@ jobs: run: php vendor/bin/phpunit --colors=always --testsuite=Unit - name: ๐Ÿงช Run integration tests with phpunit - run: php vendor/bin/phpunit --colors=always --testsuite=Cycle DBAL + run: php vendor/bin/phpunit --colors=always --testsuite=DBAL diff --git a/phpunit.xml b/phpunit.xml index 215148fd..406ea314 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -3,13 +3,7 @@ cacheResultFile=".build/phpunit/result.cache" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" bootstrap="tests/bootstrap.php" - backupGlobals="false" - backupStaticAttributes="false" - colors="true" verbose="false" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" - processIsolation="false" + colors="true" stopOnFailure="true" stopOnError="true" > @@ -19,7 +13,7 @@ - + ./tests/ From edc3eb8c4a8e54b8f672e811b75420a5ba4611ed Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 15:23:46 +0200 Subject: [PATCH 32/48] ci: run only postgres tests against pgsql integration --- .github/workflows/ci-pgsql.yml | 2 +- Makefile | 9 +++++++++ composer.json | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index 02ee7a1f..7941219c 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -85,4 +85,4 @@ jobs: run: php vendor/bin/phpunit --colors=always --testsuite=Unit - name: ๐Ÿงช Run integration tests with phpunit - run: php vendor/bin/phpunit --colors=always --testsuite=DBAL + run: php vendor/bin/phpunit --colors=always --testsuite=DBAL --group driver-postgres diff --git a/Makefile b/Makefile index edd556b2..7a736239 100644 --- a/Makefile +++ b/Makefile @@ -195,6 +195,15 @@ test-sqlite: ## Run project php-unit tests with sqlite database $(APP_COMPOSER) test:sqlite .PHONY: test-sqlite +test-mysql: ## Run project php-unit tests with mysql database + $(APP_COMPOSER) test:mysql +.PHONY: test-mysql + +test-pgsql: ## Run project php-unit tests with postgres database + $(APP_COMPOSER) test:pgsql +.PHONY: test-pgsql + + # Release # ------------------------------------------------------------------------------------ commit: diff --git a/composer.json b/composer.json index 7d18fa81..d0856d18 100644 --- a/composer.json +++ b/composer.json @@ -111,6 +111,8 @@ "psalm:ci": "php vendor/bin/psalm --output-format=github --shepherd --show-info=false --stats --threads=4", "test": "php vendor/bin/phpunit --colors=always", "test:cc": "php vendor/bin/phpunit --colors=always --coverage", - "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite" + "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite", + "test:mysql": "php vendor/bin/phpunit --colors=always --group=driver-mysql", + "test:pgsql": "php vendor/bin/phpunit --colors=always --group=driver-postgres" } } From 8ba7bcc86b205b076d63c0f675fb5f0c60040e8f Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 15:26:58 +0200 Subject: [PATCH 33/48] feat: add initial psalm baseline file --- psalm-baseline.xml | 122 +++++++++++++++++++++++++++++++++++++++++++++ psalm.xml | 2 +- 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 psalm-baseline.xml diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 00000000..129861e6 --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/psalm.xml b/psalm.xml index 1246a88b..b3ac1541 100644 --- a/psalm.xml +++ b/psalm.xml @@ -7,11 +7,11 @@ findUnusedBaselineEntry="true" findUnusedCode="false" hoistConstants="true" - resolveFromConfigFile="true" findUnusedPsalmSuppress="true" findUnusedVariablesAndParams="true" ensureArrayStringOffsetsExist="true" addParamDefaultToDocblockType="true" + errorBaseline="psalm-baseline.xml" > From d421d646619433fffd7315943d60dfed75429309 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 15:45:12 +0200 Subject: [PATCH 34/48] ci: fix infection tests --- Makefile | 4 ++++ composer.json | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7a736239..0c1031c3 100644 --- a/Makefile +++ b/Makefile @@ -175,6 +175,10 @@ lint-psalm-ci: $(APP_COMPOSER) psalm:ci .PHONY: lint-psalm-ci +lint-psalm-baseline: ## Runs psalm to update its baseline + $(APP_COMPOSER) psalm:baseline:update +.PHONY: lint-psalm-baseline + lint-infect: ## Runs infection โ€“ mutation testing framework $(APP_COMPOSER) infection .PHONY: lint-infect diff --git a/composer.json b/composer.json index d0856d18..5f5fbe6c 100644 --- a/composer.json +++ b/composer.json @@ -106,9 +106,10 @@ "cs:diff": "php vendor/bin/php-cs-fixer fix --dry-run --verbose --diff --show-progress=dots", "cs:fix": "php vendor/bin/php-cs-fixer fix -v", "infection": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github", - "infection:ci": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github", + "infection:ci": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github -- --group=driver-sqlite", "psalm": "php vendor/bin/psalm --output-format=compact", "psalm:ci": "php vendor/bin/psalm --output-format=github --shepherd --show-info=false --stats --threads=4", + "psalm:baseline:update": "php vendor/bin/psalm --set-baseline=psalm-baseline.xml", "test": "php vendor/bin/phpunit --colors=always", "test:cc": "php vendor/bin/phpunit --colors=always --coverage", "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite", From 93d20362ddaf872b4ce2f999219b756540cbbb72 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 15:53:30 +0200 Subject: [PATCH 35/48] ci: fix mutation tests github action --- composer.json | 2 +- infection.json.dist | 4 +++- phpunit.xml | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 5f5fbe6c..6c5089da 100644 --- a/composer.json +++ b/composer.json @@ -106,7 +106,7 @@ "cs:diff": "php vendor/bin/php-cs-fixer fix --dry-run --verbose --diff --show-progress=dots", "cs:fix": "php vendor/bin/php-cs-fixer fix -v", "infection": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github", - "infection:ci": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github -- --group=driver-sqlite", + "infection:ci": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github", "psalm": "php vendor/bin/psalm --output-format=compact", "psalm:ci": "php vendor/bin/psalm --output-format=github --shepherd --show-info=false --stats --threads=4", "psalm:baseline:update": "php vendor/bin/psalm --set-baseline=psalm-baseline.xml", diff --git a/infection.json.dist b/infection.json.dist index e2767669..ea28d9c3 100644 --- a/infection.json.dist +++ b/infection.json.dist @@ -15,5 +15,7 @@ "mutators": { "@default": true, "@function_signature": false - } + }, + "testFramework":"phpunit", + "testFrameworkOptions": "--group=driver-sqlite" } diff --git a/phpunit.xml b/phpunit.xml index 406ea314..904ec5b5 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -6,6 +6,7 @@ colors="true" stopOnFailure="true" stopOnError="true" + executionOrder="random" > From ea076030259ba6deffee904fb234c40574e296d3 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 16:24:40 +0200 Subject: [PATCH 36/48] ci: add mysql integration action --- .github/workflows/ci-mysql.yml | 84 ++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/ci-mysql.yml diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml new file mode 100644 index 00000000..b54c2c6f --- /dev/null +++ b/.github/workflows/ci-mysql.yml @@ -0,0 +1,84 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - 2.x + +name: ๐Ÿ” Integration with MySQL + +jobs: + test-mysql: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: + - 'ubuntu-latest' + php-version: + - '8.2' + dependencies: + - locked + mysql-version: + - '8.3.0' + + services: + mysql: + image: mysql:${{ matrix.mysql-version }} + env: + MYSQL_DATABASE: spiral + MYSQL_ROOT_PASSWORD: root + MYSQL_ROOT_HOST: '%' + options: >- + --health-cmd mysqladmin ping + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 13306:3306 + + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.1 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.1 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, pdo, pdo_sqlite, json + ini-values: error_reporting=E_ALL + tools: composer:v2, pecl + coverage: none + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ—‘๏ธ Remove PHP platform configuration + if: "matrix.dependencies != 'locked'" + run: composer config platform.php --ansi --unset + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + uses: wayofdev/gh-actions/actions/composer/install@master + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿงช Run unit tests with phpunit + run: php vendor/bin/phpunit --colors=always --testsuite=Unit + + - name: ๐Ÿงช Run integration tests with phpunit + run: php vendor/bin/phpunit --colors=always --testsuite=DBAL --group driver-mysql From 822ca9bd3e329d3984be683ca3fc92b3600c82e5 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 16:28:10 +0200 Subject: [PATCH 37/48] chore: switch to latesst tag in mysql --- .github/workflows/ci-mysql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index b54c2c6f..90aa0ed9 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -20,7 +20,7 @@ jobs: dependencies: - locked mysql-version: - - '8.3.0' + - latest services: mysql: From 1cf29cc3ea7e928e27a9c916bc2561101aab1dbb Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 18:44:30 +0200 Subject: [PATCH 38/48] ci: fix mysql integration action --- .github/workflows/ci-mysql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index 90aa0ed9..95b24823 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -30,7 +30,7 @@ jobs: MYSQL_ROOT_PASSWORD: root MYSQL_ROOT_HOST: '%' options: >- - --health-cmd mysqladmin ping + --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5 From a428d00920fd7a6ea38be7a661ee381512e7adec Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 18:59:21 +0200 Subject: [PATCH 39/48] ci: add sqlserver (mssql) action --- .github/workflows/ci-mssql.yml | 83 ++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .github/workflows/ci-mssql.yml diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml new file mode 100644 index 00000000..039c7fce --- /dev/null +++ b/.github/workflows/ci-mssql.yml @@ -0,0 +1,83 @@ +--- + +on: # yamllint disable-line rule:truthy + pull_request: + branches: + - 2.x + +name: ๐Ÿ” Integration with SQLServer + +jobs: + test-mssql: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: + - 'ubuntu-latest' + php-version: + - '8.2' + dependencies: + - locked + mssql-version: + - latest + + services: + mssql: + image: mcr.microsoft.com/mssql/server:2019-latest + env: + ACCEPT_EULA: 'Y' + SA_PASSWORD: 'Strong(!)Password' + options: >- + --health-cmd="sqlcmd -S localhost -U SA -P 'Strong(!)Password' -Q 'SELECT 1'" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 11433:1433 + + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.1 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.1 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, pdo, pdo_sqlite, json + ini-values: error_reporting=E_ALL + tools: composer:v2, pecl + coverage: none + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ—‘๏ธ Remove PHP platform configuration + if: "matrix.dependencies != 'locked'" + run: composer config platform.php --ansi --unset + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + uses: wayofdev/gh-actions/actions/composer/install@master + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿงช Run unit tests with phpunit + run: php vendor/bin/phpunit --colors=always --testsuite=Unit + + - name: ๐Ÿงช Run integration tests with phpunit + run: php vendor/bin/phpunit --colors=always --testsuite=DBAL --group driver-sqlserver From 2387dbb20e3421a60290a0d595534f9f793bddc3 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 19:06:25 +0200 Subject: [PATCH 40/48] ci: add pdo dependencies to php, increase sqlserver health-checks --- .github/workflows/ci-mssql.yml | 12 ++++++------ .github/workflows/ci-mysql.yml | 2 +- .github/workflows/ci-pgsql.yml | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml index 039c7fce..592c8be7 100644 --- a/.github/workflows/ci-mssql.yml +++ b/.github/workflows/ci-mssql.yml @@ -27,12 +27,12 @@ jobs: image: mcr.microsoft.com/mssql/server:2019-latest env: ACCEPT_EULA: 'Y' - SA_PASSWORD: 'Strong(!)Password' + SA_PASSWORD: 'Pass_wo_rd' options: >- - --health-cmd="sqlcmd -S localhost -U SA -P 'Strong(!)Password' -Q 'SELECT 1'" - --health-interval 10s - --health-timeout 5s - --health-retries 5 + --health-cmd="sqlcmd -S localhost -U SA -P 'Pass_wo_rd' -Q 'SELECT 1'" + --health-interval 12s + --health-timeout 7s + --health-retries 7 ports: - 11433:1433 @@ -44,7 +44,7 @@ jobs: uses: shivammathur/setup-php@2.30.1 with: php-version: ${{ matrix.php-version }} - extensions: mbstring, pdo, pdo_sqlite, json + extensions: mbstring, pdo, pdo_sqlite, pdo_sqlsrv, json ini-values: error_reporting=E_ALL tools: composer:v2, pecl coverage: none diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index 95b24823..b0242afa 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -45,7 +45,7 @@ jobs: uses: shivammathur/setup-php@2.30.1 with: php-version: ${{ matrix.php-version }} - extensions: mbstring, pdo, pdo_sqlite, json + extensions: mbstring, pdo, pdo_sqlite, pdo_mysql, json ini-values: error_reporting=E_ALL tools: composer:v2, pecl coverage: none diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index 7941219c..57bfb699 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -49,7 +49,7 @@ jobs: uses: shivammathur/setup-php@2.30.1 with: php-version: ${{ matrix.php-version }} - extensions: mbstring, pdo, pdo_sqlite, json + extensions: mbstring, pdo, pdo_sqlite, pdo_pgsql, json ini-values: error_reporting=E_ALL tools: composer:v2, pecl coverage: none From 7b5da77659dd616c0bd878987e5d5a41a2504cf5 Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 19:10:57 +0200 Subject: [PATCH 41/48] ci: remove health-checks for sqlserver --- .github/workflows/ci-mssql.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml index 592c8be7..456fce6e 100644 --- a/.github/workflows/ci-mssql.yml +++ b/.github/workflows/ci-mssql.yml @@ -28,11 +28,6 @@ jobs: env: ACCEPT_EULA: 'Y' SA_PASSWORD: 'Pass_wo_rd' - options: >- - --health-cmd="sqlcmd -S localhost -U SA -P 'Pass_wo_rd' -Q 'SELECT 1'" - --health-interval 12s - --health-timeout 7s - --health-retries 7 ports: - 11433:1433 From d1c96e13648ce7ff1d92102b37ae56cc5c6a1a6e Mon Sep 17 00:00:00 2001 From: lotyp Date: Thu, 28 Mar 2024 19:14:59 +0200 Subject: [PATCH 42/48] ci: fix password for SA account of mssql --- .github/workflows/ci-mssql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml index 456fce6e..32be0e48 100644 --- a/.github/workflows/ci-mssql.yml +++ b/.github/workflows/ci-mssql.yml @@ -27,7 +27,7 @@ jobs: image: mcr.microsoft.com/mssql/server:2019-latest env: ACCEPT_EULA: 'Y' - SA_PASSWORD: 'Pass_wo_rd' + SA_PASSWORD: 'SSpaSS__1' ports: - 11433:1433 From 6ec430ec8980d412e498caf01989f268b2c572b7 Mon Sep 17 00:00:00 2001 From: lotyp Date: Fri, 29 Mar 2024 18:16:11 +0200 Subject: [PATCH 43/48] feat: add security and dependency analysis --- .github/workflows/ci-mssql.yml | 1 - .github/workflows/ci-mysql.yml | 1 - .github/workflows/ci-pgsql.yml | 1 - .github/workflows/ci.yml | 119 +++++++++++++++++++++++++++++++-- .phive/phars.xml | 4 ++ composer-require-checker.json | 2 + 6 files changed, 121 insertions(+), 7 deletions(-) create mode 100644 .phive/phars.xml create mode 100644 composer-require-checker.json diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml index 32be0e48..6c2da7b3 100644 --- a/.github/workflows/ci-mssql.yml +++ b/.github/workflows/ci-mssql.yml @@ -41,7 +41,6 @@ jobs: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite, pdo_sqlsrv, json ini-values: error_reporting=E_ALL - tools: composer:v2, pecl coverage: none - name: ๐Ÿ› ๏ธ Setup problem matchers diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index b0242afa..f926dd17 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -47,7 +47,6 @@ jobs: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite, pdo_mysql, json ini-values: error_reporting=E_ALL - tools: composer:v2, pecl coverage: none - name: ๐Ÿ› ๏ธ Setup problem matchers diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index 57bfb699..eea694d4 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -51,7 +51,6 @@ jobs: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite, pdo_pgsql, json ini-values: error_reporting=E_ALL - tools: composer:v2, pecl coverage: none - name: ๐Ÿ› ๏ธ Setup problem matchers diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15b26d35..fc007e73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,7 @@ name: ๐Ÿ” Integration jobs: code-coverage: + timeout-minutes: 5 runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true @@ -33,7 +34,6 @@ jobs: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite ini-values: error_reporting=E_ALL - tools: composer:v2, pecl coverage: xdebug - name: ๐Ÿ› ๏ธ Setup problem matchers @@ -69,8 +69,10 @@ jobs: with: files: .build/phpunit/logs/clover.xml token: ${{ secrets.CODECOV_TOKEN }} + verbose: true coding-standards: + timeout-minutes: 10 runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true @@ -94,7 +96,6 @@ jobs: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite ini-values: error_reporting=E_ALL - tools: composer:v2, pecl coverage: xdebug - name: ๐Ÿ› ๏ธ Setup problem matchers @@ -139,6 +140,7 @@ jobs: PHP_CS_FIXER_IGNORE_ENV: true static-analysis: + timeout-minutes: 5 runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true @@ -162,7 +164,6 @@ jobs: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite ini-values: error_reporting=E_ALL - tools: composer:v2, pecl coverage: xdebug - name: ๐Ÿ› ๏ธ Setup problem matchers @@ -192,6 +193,7 @@ jobs: run: composer psalm:ci mutation-testing: + timeout-minutes: 5 runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true @@ -215,7 +217,6 @@ jobs: php-version: ${{ matrix.php-version }} extensions: mbstring, pdo, pdo_sqlite ini-values: error_reporting=E_ALL - tools: composer:v2, pecl coverage: xdebug - name: ๐Ÿ› ๏ธ Setup problem matchers @@ -241,3 +242,113 @@ jobs: - name: ๐Ÿงช Run mutation testing using Xdebug and infection/infection run: composer infection:ci + + security-analysis: + timeout-minutes: 5 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: security-analysis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - "ubuntu-latest" + php-version: + - "8.1" + dependencies: + - "locked" + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.1 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.1 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, json + ini-values: error_reporting=E_ALL + coverage: none + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + uses: wayofdev/gh-actions/actions/composer/install@master + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿ‘€ Check installed packages for security vulnerability advisories + run: composer audit --ansi + + dependency-analysis: + timeout-minutes: 5 + runs-on: ${{ matrix.os }} + concurrency: + cancel-in-progress: true + group: dependency-analysis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + strategy: + fail-fast: true + matrix: + os: + - "ubuntu-latest" + php-version: + - "8.2" + dependencies: + - "locked" + + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4.1.1 + + - name: ๐Ÿ› ๏ธ Setup PHP + uses: shivammathur/setup-php@2.30.1 + with: + php-version: ${{ matrix.php-version }} + extensions: mbstring, json, curl, dom, xml, phar + ini-values: error_reporting=E_ALL + coverage: none + tools: phive + + - name: ๐Ÿ› ๏ธ Setup problem matchers + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: ๐Ÿค– Validate composer.json and composer.lock + run: composer validate --ansi --strict + + - name: ๐Ÿ” Get composer cache directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master + + - name: โ™ป๏ธ Restore cached dependencies installed with composer + uses: actions/cache@v4.0.2 + with: + path: ${{ env.COMPOSER_CACHE_DIR }} + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + uses: wayofdev/gh-actions/actions/composer/install@master + with: + dependencies: ${{ matrix.dependencies }} + + - name: ๐Ÿ“ฅ Install dependencies with phive + uses: wayofdev/gh-actions/actions/phive/install@master + with: + phive-home: '.phive' + trust-gpg-keys: '0x033E5F8D801A2F8D' + + - name: ๐Ÿ”ฌ Run maglnet/composer-require-checker + run: .phive/composer-require-checker check --ansi --config-file=$(pwd)/composer-require-checker.json --verbose diff --git a/.phive/phars.xml b/.phive/phars.xml new file mode 100644 index 00000000..8fa992c8 --- /dev/null +++ b/.phive/phars.xml @@ -0,0 +1,4 @@ + + + + diff --git a/composer-require-checker.json b/composer-require-checker.json new file mode 100644 index 00000000..2c63c085 --- /dev/null +++ b/composer-require-checker.json @@ -0,0 +1,2 @@ +{ +} From a5ad866ebbf9b55738b77daa335dd612a62d9c5c Mon Sep 17 00:00:00 2001 From: lotyp Date: Fri, 29 Mar 2024 19:26:21 +0200 Subject: [PATCH 44/48] ci: coding standards improvements fix(git): .gitattributes should ignore all dev files fix(ci): increase job timeouts, add timeouts to *sql ci workflows feat(dx): add phive installation fix(deps): Added ext-filter as dependency style(composer): sort composer fix(deps): Applied composer-require-checker --- .gitattributes | 36 +++++++++++-------- .github/workflows/ci-mssql.yml | 1 + .github/workflows/ci-mysql.yml | 1 + .github/workflows/ci-pgsql.yml | 1 + .github/workflows/ci.yml | 12 +++---- .phive/.gitignore | 3 ++ Makefile | 28 ++++++++++----- composer-require-checker.json | 4 +++ composer.json | 7 ++-- src/Driver/PDOStatementInterface.php | 4 ++- .../Database/Stub/Driver/TestPDOStatement.php | 4 ++- 11 files changed, 67 insertions(+), 34 deletions(-) create mode 100644 .phive/.gitignore diff --git a/.gitattributes b/.gitattributes index df9f0f9a..97087181 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,15 +1,21 @@ -/.build export-ignore -/.github export-ignore -/tests export-ignore -.editorconfig export-ignore -.env.example export-ignore -.gitattributes export-ignore -.gitignore export-ignore -.php-cs-fixer.dist.php export-ignore -.scrutinizer.yml export-ignore -.styleci.yml export-ignore -docker-compose.yaml export-ignore -infection.json.dist export-ignore -Makefile export-ignore -phpunit.xml export-ignore -psalm.xml export-ignore +/.build export-ignore +/.github export-ignore +/.phive/ export-ignore +/tests export-ignore +.editorconfig export-ignore +.env.example export-ignore +.gitattributes export-ignore +.gitignore export-ignore +.php-cs-fixer.dist.php export-ignore +.pre-commit-config.yaml export-ignore +.scrutinizer.yml export-ignore +.styleci.yml export-ignore +.yamllint.yaml export-ignore +composer.lock export-ignore +composer-require-checker.json export-ignore +docker-compose.yaml export-ignore +infection.json.dist export-ignore +Makefile export-ignore +phpunit.xml export-ignore +psalm.xml export-ignore +psalm-baseline.xml export-ignore diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml index 6c2da7b3..525baa5f 100644 --- a/.github/workflows/ci-mssql.yml +++ b/.github/workflows/ci-mssql.yml @@ -9,6 +9,7 @@ name: ๐Ÿ” Integration with SQLServer jobs: test-mssql: + timeout-minutes: 4 runs-on: ${{ matrix.os }} strategy: fail-fast: true diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index f926dd17..b15aba26 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -9,6 +9,7 @@ name: ๐Ÿ” Integration with MySQL jobs: test-mysql: + timeout-minutes: 4 runs-on: ${{ matrix.os }} strategy: fail-fast: true diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index eea694d4..343e46b3 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -9,6 +9,7 @@ name: ๐Ÿ” Integration with PostgreSQL jobs: test-pgsql: + timeout-minutes: 4 runs-on: ${{ matrix.os }} strategy: fail-fast: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc007e73..67af2a38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ name: ๐Ÿ” Integration jobs: code-coverage: - timeout-minutes: 5 + timeout-minutes: 4 runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true @@ -72,7 +72,7 @@ jobs: verbose: true coding-standards: - timeout-minutes: 10 + timeout-minutes: 16 runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true @@ -140,7 +140,7 @@ jobs: PHP_CS_FIXER_IGNORE_ENV: true static-analysis: - timeout-minutes: 5 + timeout-minutes: 4 runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true @@ -193,7 +193,7 @@ jobs: run: composer psalm:ci mutation-testing: - timeout-minutes: 5 + timeout-minutes: 16 runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true @@ -244,7 +244,7 @@ jobs: run: composer infection:ci security-analysis: - timeout-minutes: 5 + timeout-minutes: 4 runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true @@ -295,7 +295,7 @@ jobs: run: composer audit --ansi dependency-analysis: - timeout-minutes: 5 + timeout-minutes: 4 runs-on: ${{ matrix.os }} concurrency: cancel-in-progress: true diff --git a/.phive/.gitignore b/.phive/.gitignore new file mode 100644 index 00000000..71d2e19d --- /dev/null +++ b/.phive/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!phars.xml diff --git a/Makefile b/Makefile index 0c1031c3..04dac873 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,7 @@ EXPORT_VARS = '\ $${COMPOSE_PROJECT_NAME} \ $${COMPOSER_AUTH}' +# # Self documenting Makefile code # ------------------------------------------------------------------------------------ ifneq ($(TERM),) @@ -66,20 +67,20 @@ help: @echo ' ๐Ÿ“‘ Logs are stored in $(MAKE_LOGFILE)' @echo @echo ' ๐Ÿ“ฆ Package database (https://github.com/cycle/database)' - @echo ' ๐Ÿค  Author Andrij Orlenko (https://github.com/lotyp)' + @echo ' ๐Ÿค  Makefile Author Andrij Orlenko (https://github.com/lotyp)' @echo ' ๐Ÿข ${YELLOW}Org cycle (https://github.com/cycle)${RST}' .PHONY: help .EXPORT_ALL_VARIABLES: - +# # Default action # Defines default command when `make` is executed without additional parameters # ------------------------------------------------------------------------------------ -all: env prepare install hooks up +all: env prepare install hooks phive up .PHONY: all - +# # System Actions # ------------------------------------------------------------------------------------ env: ## Generate .env file from example, use `make env force=true`, to force re-create file @@ -99,7 +100,7 @@ prepare: mkdir -p .build/php-cs-fixer .PHONY: prepare - +# # Docker Actions # ------------------------------------------------------------------------------------ up: # Creates and starts containers, defined in docker-compose and override file @@ -133,7 +134,7 @@ ssh: ## Login inside running docker container $(APP_RUNNER) sh .PHONY: ssh - +# # Composer # ------------------------------------------------------------------------------------ install: ## Installs composer dependencies @@ -144,8 +145,12 @@ update: ## Updates composer dependencies by running composer update command $(APP_COMPOSER) update .PHONY: update +phive: ## Installs dependencies with phive + PHIVE_HOME=.build/phive phive install --trust-gpg-keys 0x033E5F8D801A2F8D +.PHONY: phive -# Code Quality, Git, Linting, Testing +# +# Code Quality, Git, Linting # ------------------------------------------------------------------------------------ hooks: ## Install git hooks from pre-commit-config pre-commit install @@ -187,6 +192,13 @@ lint-infect-ci: ## Runs infection โ€“ mutation testing framework $(APP_COMPOSER) infection:ci .PHONY: lint-infect-ci +lint-deps: ## Runs composer-require-checker โ€“ checks for dependencies that are not used + .phive/composer-require-checker check --config-file=$(shell pwd)/composer-require-checker.json --verbose +.PHONY: lint-deps + +# +# Testing +# ------------------------------------------------------------------------------------ test: ## Run project php-unit tests $(APP_COMPOSER) test .PHONY: test @@ -207,7 +219,7 @@ test-pgsql: ## Run project php-unit tests with postgres database $(APP_COMPOSER) test:pgsql .PHONY: test-pgsql - +# # Release # ------------------------------------------------------------------------------------ commit: diff --git a/composer-require-checker.json b/composer-require-checker.json index 2c63c085..c49ade90 100644 --- a/composer-require-checker.json +++ b/composer-require-checker.json @@ -1,2 +1,6 @@ { + "symbol-whitelist": [ + "Cycle\\Database\\Driver\\SQLServer\\Schema\\SQlServerForeignKey", + "Spiral\\Database\\Driver\\SQLServer\\Schema\\SQlServerForeignKey" + ] } diff --git a/composer.json b/composer.json index 6c5089da..8fc1fec7 100644 --- a/composer.json +++ b/composer.json @@ -47,6 +47,7 @@ ], "require": { "php": ">=8.1", + "ext-filter": "*", "ext-pdo": "*", "psr/log": "1 - 3", "spiral/core": "^2.8 || ^3.0", @@ -108,12 +109,12 @@ "infection": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github", "infection:ci": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github", "psalm": "php vendor/bin/psalm --output-format=compact", - "psalm:ci": "php vendor/bin/psalm --output-format=github --shepherd --show-info=false --stats --threads=4", "psalm:baseline:update": "php vendor/bin/psalm --set-baseline=psalm-baseline.xml", + "psalm:ci": "php vendor/bin/psalm --output-format=github --shepherd --show-info=false --stats --threads=4", "test": "php vendor/bin/phpunit --colors=always", "test:cc": "php vendor/bin/phpunit --colors=always --coverage", - "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite", "test:mysql": "php vendor/bin/phpunit --colors=always --group=driver-mysql", - "test:pgsql": "php vendor/bin/phpunit --colors=always --group=driver-postgres" + "test:pgsql": "php vendor/bin/phpunit --colors=always --group=driver-postgres", + "test:sqlite": "php vendor/bin/phpunit --colors=always --group=driver-sqlite" } } diff --git a/src/Driver/PDOStatementInterface.php b/src/Driver/PDOStatementInterface.php index 7a02409e..4944108d 100644 --- a/src/Driver/PDOStatementInterface.php +++ b/src/Driver/PDOStatementInterface.php @@ -64,7 +64,9 @@ public function fetchObject(string|null $class = stdClass::class, array $constru public function errorCode(): ?string; - #[ArrayShape([0 => 'string', 1 => 'int', 2 => 'string'])] + /** + * @return array{0:string, 1:int, 2:string} + */ public function errorInfo(): array; public function setAttribute(int $attribute, mixed $value): bool; diff --git a/tests/Database/Stub/Driver/TestPDOStatement.php b/tests/Database/Stub/Driver/TestPDOStatement.php index 08701852..8c624fdd 100644 --- a/tests/Database/Stub/Driver/TestPDOStatement.php +++ b/tests/Database/Stub/Driver/TestPDOStatement.php @@ -96,7 +96,9 @@ public function errorCode(): ?string return $this->statement->errorCode(...\func_get_args()); } - #[ArrayShape([0 => 'string', 1 => 'int', 2 => 'string'])] + /** + * @return array{0:string, 1:int, 2:string} + */ public function errorInfo(): array { return $this->statement->errorInfo(...\func_get_args()); From 1355dda2611e8dcb7cfb1e8120be268f56d53888 Mon Sep 17 00:00:00 2001 From: lotyp Date: Fri, 29 Mar 2024 19:28:10 +0200 Subject: [PATCH 45/48] chore: remove unused classes --- src/Driver/PDOStatementInterface.php | 1 - tests/Database/Stub/Driver/TestPDOStatement.php | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Driver/PDOStatementInterface.php b/src/Driver/PDOStatementInterface.php index 4944108d..2bf1ba16 100644 --- a/src/Driver/PDOStatementInterface.php +++ b/src/Driver/PDOStatementInterface.php @@ -12,7 +12,6 @@ namespace Cycle\Database\Driver; use IteratorAggregate; -use JetBrains\PhpStorm\ArrayShape; use PDO; use PDOStatement; use stdClass; diff --git a/tests/Database/Stub/Driver/TestPDOStatement.php b/tests/Database/Stub/Driver/TestPDOStatement.php index 8c624fdd..979952cd 100644 --- a/tests/Database/Stub/Driver/TestPDOStatement.php +++ b/tests/Database/Stub/Driver/TestPDOStatement.php @@ -6,7 +6,6 @@ use Closure; use Cycle\Database\Driver\PDOStatementInterface; -use JetBrains\PhpStorm\ArrayShape; use PDO; use stdClass; use Traversable; From cdeceaa3178dc7ac7b4b0fbb5a410a342a7cc003 Mon Sep 17 00:00:00 2001 From: lotyp Date: Fri, 29 Mar 2024 20:06:55 +0200 Subject: [PATCH 46/48] fix: psalm errors --- composer.json | 2 +- psalm-baseline.xml | 3 --- src/Driver/PDOStatementInterface.php | 2 +- tests/Database/Stub/Driver/TestPDOStatement.php | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 8fc1fec7..060eb3a4 100644 --- a/composer.json +++ b/composer.json @@ -108,7 +108,7 @@ "cs:fix": "php vendor/bin/php-cs-fixer fix -v", "infection": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github", "infection:ci": "vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github", - "psalm": "php vendor/bin/psalm --output-format=compact", + "psalm": "php vendor/bin/psalm", "psalm:baseline:update": "php vendor/bin/psalm --set-baseline=psalm-baseline.xml", "psalm:ci": "php vendor/bin/psalm --output-format=github --shepherd --show-info=false --stats --threads=4", "test": "php vendor/bin/phpunit --colors=always", diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 129861e6..43d9e57a 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -26,9 +26,6 @@ - - - diff --git a/src/Driver/PDOStatementInterface.php b/src/Driver/PDOStatementInterface.php index 2bf1ba16..f6e1b36c 100644 --- a/src/Driver/PDOStatementInterface.php +++ b/src/Driver/PDOStatementInterface.php @@ -64,7 +64,7 @@ public function fetchObject(string|null $class = stdClass::class, array $constru public function errorCode(): ?string; /** - * @return array{0:string, 1:int, 2:string} + * @return array{0:non-empty-string, 1:positive-int, 2:non-empty-string} */ public function errorInfo(): array; diff --git a/tests/Database/Stub/Driver/TestPDOStatement.php b/tests/Database/Stub/Driver/TestPDOStatement.php index 979952cd..de1df349 100644 --- a/tests/Database/Stub/Driver/TestPDOStatement.php +++ b/tests/Database/Stub/Driver/TestPDOStatement.php @@ -96,7 +96,7 @@ public function errorCode(): ?string } /** - * @return array{0:string, 1:int, 2:string} + * @return array{0:non-empty-string, 1:positive-int, 2:non-empty-string} */ public function errorInfo(): array { From 2d6b5b063b0c775a4ec1b3ed8a5134df19bf7d79 Mon Sep 17 00:00:00 2001 From: lotyp Date: Sun, 31 Mar 2024 02:14:08 +0200 Subject: [PATCH 47/48] feat: make commit runs through docker now --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 04dac873..c3dc73fa 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,12 @@ BUILDER_WIRED ?= $(BUILDER_PARAMS) --network project.$(COMPOSE_PROJECT_NAME) $(S # Shorthand envsubst command, executed through build-deps ENVSUBST ?= $(BUILDER) envsubst +# Commitizen docker image +CZ_RUNNER ?= docker run --rm --name commitizen \ + --platform linux/amd64 \ + -v $(shell pwd):/app \ + commitizen/commitizen:latest + EXPORT_VARS = '\ $${COMPOSE_PROJECT_NAME} \ $${COMPOSER_AUTH}' @@ -223,7 +229,7 @@ test-pgsql: ## Run project php-unit tests with postgres database # Release # ------------------------------------------------------------------------------------ commit: - cz commit + $(CZ_RUNNER) commit .PHONY: commit release: ## Create a new release From bbeb2f223851842c2237cd65fa98adbeddecb8ce Mon Sep 17 00:00:00 2001 From: lotyp Date: Mon, 1 Apr 2024 05:31:37 +0300 Subject: [PATCH 48/48] chore: same pass for all dbs --- .env.example | 6 +++--- composer.json | 3 +++ tests/bootstrap.php | 52 ++++++++++++++++++++++----------------------- tests/helpers.php | 21 ++++++++++++++++++ 4 files changed, 53 insertions(+), 29 deletions(-) create mode 100644 tests/helpers.php diff --git a/.env.example b/.env.example index 4838c716..5473cafc 100644 --- a/.env.example +++ b/.env.example @@ -10,11 +10,11 @@ DB_PORT=5432 DB_DATABASE=default DB_USERNAME=root -DB_PASSWORD=password +DB_PASSWORD=Strong(!)Password DB_SQLSERVER_FORWARD_PORT=11433 -DB_MYSQL_FORWARD_PORT=13333 -DB_PGSQL_FORWARD_PORT=15333 +DB_MYSQL_FORWARD_PORT=13306 +DB_PGSQL_FORWARD_PORT=15432 XDEBUG_MODE=coverage diff --git a/composer.json b/composer.json index 060eb3a4..663d0ee1 100644 --- a/composer.json +++ b/composer.json @@ -80,6 +80,9 @@ ] }, "autoload-dev": { + "files": [ + "tests/helpers.php" + ], "psr-4": { "Cycle\\Database\\Tests\\": "tests/Database" } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f86ea148..c6da8ce4 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -20,21 +20,21 @@ ), 'mysql' => new Database\Config\MySQLDriverConfig( connection: new Database\Config\MySQL\TcpConnectionConfig( - database: 'spiral', - host: '127.0.0.1', - port: 13306, - user: 'root', - password: 'root', + database: env('DB_DATABASE', 'spiral'), + host: 'mysql', + port: 3306, + user: env('DB_USER', 'root'), + password: env('DB_PASSWORD', 'root'), ), queryCache: true ), 'postgres' => new Database\Config\PostgresDriverConfig( connection: new Database\Config\Postgres\TcpConnectionConfig( - database: 'spiral', - host: '127.0.0.1', - port: 15432, - user: 'postgres', - password: 'postgres', + database: env('DB_DATABASE', 'spiral'), + host: 'pgsql', + port: 5432, + user: env('DB_USER', 'postgres'), + password: env('DB_PASSWORD', 'postgres'), ), schema: 'public', queryCache: true, @@ -42,10 +42,10 @@ 'sqlserver' => new Database\Config\SQLServerDriverConfig( connection: new Database\Config\SQLServer\TcpConnectionConfig( database: 'tempdb', - host: '127.0.0.1', - port: 11433, + host: 'sqlserver', + port: 1433, user: 'SA', - password: 'SSpaSS__1' + password: env('DB_PASSWORD', 'SSpaSS__1') ), queryCache: true ), @@ -56,11 +56,11 @@ ), 'postgres-mock' => new Database\Config\PostgresDriverConfig( connection: new Database\Config\Postgres\TcpConnectionConfig( - database: 'spiral', - host: '127.0.0.1', - port: 15432, - user: 'postgres', - password: 'postgres', + database: env('DB_DATABASE', 'spiral'), + host: 'pgsql', + port: 5432, + user: env('DB_USER', 'postgres'), + password: env('DB_PASSWORD', 'postgres'), ), schema: 'public', driver: Database\Tests\Stub\Driver\PostgresWrapDriver::class, @@ -68,11 +68,11 @@ ), 'mysql-mock' => new Database\Config\MySQLDriverConfig( connection: new Database\Config\MySQL\TcpConnectionConfig( - database: 'spiral', - host: '127.0.0.1', - port: 13306, - user: 'root', - password: 'root', + database: env('DB_DATABASE', 'spiral'), + host: 'mysql', + port: 3306, + user: env('DB_USER', 'root'), + password: env('DB_PASSWORD', 'root'), ), driver: Database\Tests\Stub\Driver\MysqlWrapDriver::class, queryCache: true, @@ -80,10 +80,10 @@ 'sqlserver-mock' => new Database\Config\SQLServerDriverConfig( connection: new Database\Config\SQLServer\TcpConnectionConfig( database: 'tempdb', - host: '127.0.0.1', - port: 11433, + host: 'sqlserver', + port: 1433, user: 'SA', - password: 'SSpaSS__1' + password: env('DB_PASSWORD', 'SSpaSS__1') ), driver: Database\Tests\Stub\Driver\MSSQLWrapDriver::class, queryCache: true, diff --git a/tests/helpers.php b/tests/helpers.php new file mode 100644 index 00000000..f3cadd11 --- /dev/null +++ b/tests/helpers.php @@ -0,0 +1,21 @@ +