Skip to content

Commit

Permalink
feature #182 Add SQL Enum support (michnovka, ogizanagi)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.x-dev branch.

Discussion
----------

Add SQL Enum support

Had some mess with branches (was working on main one, not on fork branch), so after renaming it got deleted in the old PR #179

This is the same content, just different branch name is used so that I can work on other stuff before this is merged. Sorry for the mix-up, didnt know renaming branch would close existing PR, I expected itd just be renamed there too

Commits
-------

8b58253 [Dev] Rework Makefile
a11eda8 [Tests] Fix skipped tests in PHPUnit beforeClass hooks
f35bebc [CI] Add MySQL for integration tests
371db9f Add SQL Enum support
  • Loading branch information
ogizanagi committed Apr 22, 2022
2 parents 7600213 + 8b58253 commit e623ba2
Show file tree
Hide file tree
Showing 34 changed files with 724 additions and 93 deletions.
24 changes: 13 additions & 11 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/.editorconfig export-ignore
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/.php-cs-fixer.php export-ignore
/.php-version export-ignore
/link export-ignore
/Makefile export-ignore
/phpunit.xml.dist export-ignore
/res/img export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/.make export-ignore
/.php-cs-fixer.php export-ignore
/.php-version export-ignore
/link export-ignore
/Makefile export-ignore
/docker-compose.yml export-ignore
/phpunit.xml.dist export-ignore
/res/img export-ignore
/tests export-ignore
36 changes: 33 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
test:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 8
timeout-minutes: 15
continue-on-error: ${{ matrix.allow-failure == 1 }}

strategy:
Expand Down Expand Up @@ -60,19 +60,22 @@ jobs:
symfony: '5.4.*@dev'
allow-unstable: true
mongodb: true
mysql: true

- name: 'Test Symfony 5.4 [Windows, PHP 8.1]'
os: 'windows-latest'
php: '8.1'
symfony: '5.4.*@dev'
mongodb: true
mysql: true
allow-unstable: true

- name: 'Test Symfony 6.0 [Linux, PHP 8.1]'
os: 'ubuntu-latest'
php: '8.1'
symfony: '6.0.*@dev'
mongodb: true
mysql: true
allow-unstable: true

# Bleeding edge (unreleased dev versions where failures are allowed)
Expand All @@ -83,6 +86,7 @@ jobs:
composer-flags: '--ignore-platform-req php'
allow-unstable: true
allow-failure: true
mysql: true
mongodb: true

steps:
Expand All @@ -98,7 +102,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: pdo_sqlite ${{ matrix.mongodb && ', mongodb' }}
extensions: pdo_sqlite ${{ matrix.mongodb && ', mongodb' }} ${{ matrix.mysql && ', pdo_mysql' }}
coverage: pcov
tools: 'composer:v2,flex'

Expand All @@ -112,6 +116,17 @@ jobs:
args: install mongodb
if: ${{ matrix.mongodb && matrix.os == 'windows-latest' }}

- name: 'Shutdown Default Ubuntu MySQL'
run: sudo service mysql stop
if: ${{ matrix.mysql && matrix.os == 'ubuntu-latest' }}

- name: 'Setup MySQL'
uses: ankane/setup-mysql@v1
with:
mysql-version: '8.0'
database: doctrine_tests
if: ${{ matrix.mysql }}

- name: 'Get composer cache directory'
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
Expand All @@ -132,9 +147,24 @@ jobs:
if: ${{ matrix.mongodb }}

- name: 'Install dependencies'
run: composer update --prefer-dist ${{ matrix.composer-flags }} --ansi
run: |
echo "::group::Install project deps"
composer update --prefer-dist ${{ matrix.composer-flags }} --ansi
echo "::endgroup::"
echo "::group::Install PHPUnit"
vendor/bin/simple-phpunit install
echo "::endgroup::"
env:
SYMFONY_REQUIRE: "${{ matrix.symfony }}"

- name: 'Set Doctrine MySQL DSN (Linux)'
run: echo "DOCTRINE_DBAL_URL=pdo-mysql://[email protected]:3306/doctrine_tests?serverVersion=8.0" >> $GITHUB_ENV
if: ${{ matrix.mysql && matrix.os == 'ubuntu-latest' }}

- name: 'Set Doctrine MySQL DSN (Windows)'
run: echo "DOCTRINE_DBAL_URL=pdo-mysql://[email protected]:3306/doctrine_tests?serverVersion=8.0" >> $env:GITHUB_ENV
if: ${{ matrix.mysql && matrix.os == 'windows-latest' }}

- name: 'Run PHPUnit tests'
run: vendor/bin/simple-phpunit --testdox --verbose ${{ matrix.code-coverage && '--coverage-text --coverage-clover build/logs/clover.xml' }}
71 changes: 71 additions & 0 deletions .make/help.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
########
# Help #
########

.DEFAULT_GOAL := help

HELP_HEADER = \nUsage: make [$(COLOR_INFO)command$(COLOR_RESET)]
HELP = \
$(call help_section, Help) \
$(call help,help,This help)
HELP_FOOTER = \n

define help_section
\n\n$(COLOR_COMMENT)$(strip $(1)):$(COLOR_RESET)
endef

define help
\n $(COLOR_INFO)$(1)$(COLOR_RESET) $(2)
endef

help:
@printf "$(HELP_HEADER)"
@printf "$(HELP)"
@awk ' \
BEGIN { \
sectionsName[1] = "Commands" ; \
sectionsCount = 1 ; \
} \
/^[-a-zA-Z0-9_.@%\/]+:/ { \
if (match(lastLine, /^## (.*)/)) { \
command = substr($$1, 1, index($$1, ":") - 1) ; \
section = substr(lastLine, RSTART + 3, index(lastLine, " - ") - 4) ; \
if (section) { \
message = substr(lastLine, index(lastLine, " - ") + 3, RLENGTH) ; \
sectionIndex = 0 ; \
for (i = 1; i <= sectionsCount; i++) { \
if (sectionsName[i] == section) { \
sectionIndex = i ; \
} \
} \
if (!sectionIndex) { \
sectionIndex = sectionsCount++ + 1 ; \
sectionsName[sectionIndex] = section ; \
} \
} else { \
message = substr(lastLine, RSTART + 3, RLENGTH) ; \
sectionIndex = 1 ; \
} \
if (length(command) > sectionsCommandLength[sectionIndex]) { \
sectionsCommandLength[sectionIndex] = length(command) ; \
} \
sectionCommandIndex = sectionsCommandCount[sectionIndex]++ + 1; \
helpsCommand[sectionIndex, sectionCommandIndex] = command ; \
helpsMessage[sectionIndex, sectionCommandIndex] = message ; \
} \
} \
{ lastLine = $$0 } \
END { \
for (i = 1; i <= sectionsCount; i++) { \
if (sectionsCommandCount[i]) { \
printf "\n\n$(COLOR_COMMENT)%s:$(COLOR_RESET)", sectionsName[i] ; \
for (j = 1; j <= sectionsCommandCount[i]; j++) { \
printf "\n $(COLOR_INFO)%-" sectionsCommandLength[i] "s$(COLOR_RESET) %s", helpsCommand[i, j], helpsMessage[i, j] ; \
} \
} \
} \
} \
' $(MAKEFILE_LIST)
@printf "$(HELP_FOOTER)"
@printf "\n"
.PHONY: help
121 changes: 121 additions & 0 deletions .make/text.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
##########
# Colors #
##########

COLOR_RESET := \033[0m
COLOR_ERROR := \033[31m
COLOR_INFO := \033[32m
COLOR_WARNING := \033[33m
COLOR_COMMENT := \033[36m

######################
# Special Characters #
######################

# Usage:
# $(call message, Foo$(,) bar) = Foo, bar

, := ,

########
# Time #
########

# Usage:
# $(call time) = 11:06:20

define time
`date -u +%T`
endef

###########
# Message #
###########

# Usage:
# $(call message, Foo bar) = Foo bar
# $(call message_success, Foo bar) = (っ◕‿◕)っ Foo bar
# $(call message_warning, Foo bar) = ¯\_(ツ)_/¯ Foo bar
# $(call message_error, Foo bar) = (╯°□°)╯︵ ┻━┻ Foo bar

define message
printf "$(COLOR_INFO)$(strip $(1))$(COLOR_RESET)\n"
endef

define message_success
printf "$(COLOR_INFO)(っ◕‿◕)っ $(strip $(1))$(COLOR_RESET)\n"
endef

define message_warning
printf "$(COLOR_WARNING)¯\_(ツ)_/¯ $(strip $(1))$(COLOR_RESET)\n"
endef

define message_error
printf "$(COLOR_ERROR)(╯°□°)╯︵ ┻━┻ $(strip $(1))$(COLOR_RESET)\n"
endef

#######
# Log #
#######

# Usage:
# $(call log, Foo bar) = [11:06:20] [target] Foo bar
# $(call log_warning, Foo bar) = [11:06:20] [target] ¯\_(ツ)_/¯ Foo bar
# $(call log_error, Foo bar) = [11:06:20] [target] (╯°□°)╯︵ ┻━┻ Foo bar

define log
printf "[$(COLOR_COMMENT)$(call time)$(COLOR_RESET)] [$(COLOR_COMMENT)$(@)$(COLOR_RESET)] " ; $(call message, $(1))
endef

define log_warning
printf "[$(COLOR_COMMENT)$(call time)$(COLOR_RESET)] [$(COLOR_COMMENT)$(@)$(COLOR_RESET)] " ; $(call message_warning, $(1))
endef

define log_error
printf "[$(COLOR_COMMENT)$(call time)$(COLOR_RESET)] [$(COLOR_COMMENT)$(@)$(COLOR_RESET)] " ; $(call message_error, $(1))
endef

###########
# Confirm #
###########

# Usage:
# $(call confirm, Foo bar) = ༼ つ ◕_◕ ༽つ Foo bar (y/N):

define confirm
$(if $(CONFIRM),, \
printf "$(COLOR_INFO) ༼ つ ◕_◕ ༽つ $(COLOR_WARNING)$(strip $(1)) $(COLOR_RESET)$(COLOR_WARNING)(y/N)$(COLOR_RESET): "; \
read CONFIRM ; if [ "$$CONFIRM" != "y" ]; then printf "\n"; exit 1; fi; \
)
endef

################
# Conditionals #
################

# Usage:
# $(call error_if_not, $(FOO), FOO has not been specified) = (╯°□°)╯︵ ┻━┻ FOO has not been specified

define error_if_not
$(if $(strip $(1)),, \
$(call message_error, $(strip $(2))) ; exit 1 \
)
endef

# Usage:
# $(call confirm_if, $(FOO), Foo bar) = ༼ つ ◕_◕ ༽つ Foo bar (y/N):

define confirm_if
$(if $(strip $(1)), \
$(call confirm, $(strip $(2)))
)
endef

# Usage:
# $(call confirm_if_not, $(FOO), Foo bar) = ༼ つ ◕_◕ ༽つ Foo bar (y/N):

define confirm_if_not
$(if $(strip $(1)),, \
$(call confirm, $(strip $(2)))
)
endef
Loading

0 comments on commit e623ba2

Please sign in to comment.