Skip to content

Commit a03d6c0

Browse files
author
Stephan Wentz
committed
Initial import
0 parents  commit a03d6c0

File tree

106 files changed

+2676
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+2676
-0
lines changed

.github/workflows/build.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
2+
3+
name: "Build"
4+
5+
on:
6+
pull_request:
7+
push:
8+
branches:
9+
- "main"
10+
11+
jobs:
12+
tests:
13+
name: "Tests"
14+
15+
runs-on: "ubuntu-latest"
16+
17+
strategy:
18+
matrix:
19+
dependencies: ["lowest", "highest"]
20+
php-version:
21+
- "8.1"
22+
- "8.2"
23+
24+
steps:
25+
- name: "Checkout"
26+
uses: "actions/checkout@v2"
27+
28+
- name: "Install PHP"
29+
uses: "shivammathur/setup-php@v2"
30+
with:
31+
coverage: "none"
32+
php-version: "${{ matrix.php-version }}"
33+
extensions: mbstring
34+
35+
- name: "Cache dependencies"
36+
uses: "actions/cache@v2"
37+
with:
38+
path: "~/.composer/cache"
39+
key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}"
40+
restore-keys: "php-${{ matrix.php-version }}-composer-"
41+
42+
- name: "Install lowest dependencies"
43+
if: ${{ matrix.dependencies == 'lowest' }}
44+
run: "composer update --prefer-lowest --prefer-dist --no-interaction --no-progress --no-suggest"
45+
46+
- name: "Install highest dependencies"
47+
if: ${{ matrix.dependencies == 'highest' }}
48+
run: "composer update --prefer-dist --no-interaction --no-progress --no-suggest"
49+
50+
- name: "Code Style"
51+
run: "vendor/bin/phpcs"
52+
53+
- name: "Static Analysis"
54+
run: "vendor/bin/phpstan analyze"
55+
56+
- name: "Tests"
57+
run: "vendor/bin/phpunit"

.github/workflows/code_coverage.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Code Coverage
2+
3+
on:
4+
pull_request: null
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
code_coverage:
11+
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: shivammathur/setup-php@master
16+
with:
17+
php-version: 8.2
18+
coverage: xdebug
19+
- name: Load dependencies from cache
20+
id: composer-cache
21+
run: |
22+
echo "::set-output name=dir::$(composer config cache-files-dir)"
23+
- uses: actions/cache@v1
24+
with:
25+
path: ${{ steps.composer-cache.outputs.dir }}
26+
key: ${{ runner.os }}-php8.2-composer-${{ hashFiles('**/composer.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-php8.2-composer-
29+
30+
- run: composer install --prefer-dist --no-progress --no-suggest
31+
- run: php vendor/bin/phpunit --coverage-clover build/logs/clover.xml
32+
33+
- uses: codecov/codecov-action@v3
34+
with:
35+
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
36+
files: build/logs/clover.xml # optional
37+
flags: unittests # optional
38+
name: codecov-umbrella # optional
39+
fail_ci_if_error: true # optional (default = false)
40+
verbose: true # optional (default = false)

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/.phpcs-cache
2+
/.phpunit.cache
3+
/.xdebug-filter.php
4+
/composer.lock
5+
/phpcs.xml
6+
/phpstan.neon
7+
/phpunit.xml
8+
/vendor/

.releaserc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": [
3+
"@brainbits/semantic-release-config-symfony",
4+
],
5+
"assets": ["CHANGELOG.md"],
6+
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
7+
}

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# [2.0.0](https://gitlab.brainbits.net/tspm/php-packages/database-command/compare/1.1.0...2.0.0) (2023-02-03)
2+
3+
4+
### Bug Fixes
5+
6+
* Add semantic release ([d3b3c87](https://gitlab.brainbits.net/tspm/php-packages/database-command/commit/d3b3c87bda4611b61bbb947803e0f25bdaea5246))
7+
8+
9+
### Features
10+
11+
* Update to PHP 8.2 / Symfony 6.2 ([f1d2431](https://gitlab.brainbits.net/tspm/php-packages/database-command/commit/f1d24312dc3ef6bea8432b08dec8d51bad105ea7))
12+
13+
14+
### BREAKING CHANGES
15+
16+
* Remove compatibility for old PHP and Symfony versions

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Installation
2+
3+
Register the commands in your `services.yaml`.
4+
5+
```yaml
6+
Tspm\DatabaseCommand\Command\SchemaExistsCommand: ~
7+
8+
Tspm\DatabaseCommand\Command\WaitForDatabaseCommand: ~
9+
```
10+
11+
For older symfony systems use:
12+
```yaml
13+
Tspm\DatabaseCommand\Command\SchemaExistsCommand:
14+
arguments:
15+
$connection: '@doctrine.dbal.default_connection'
16+
tags:
17+
- { name: 'console.command' }
18+
19+
Tspm\DatabaseCommand\Command\WaitForDatabaseCommand:
20+
arguments:
21+
$connection: '@doctrine.dbal.default_connection'
22+
tags:
23+
- { name: 'console.command' }
24+
```

bin/_include/defaults

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env sh
2+
3+
DOCKER_USER=""
4+
if [ "$(uname)" = "Linux" ]; then
5+
DOCKER_USER="${DOCKER_USER:="--user $(id -u):$(id -g)"}"
6+
fi
7+
DOCKER_MOUNT_MODE="${DOCKER_MOUNT_MODE:=":cached"}"

bin/_include/functions-composer

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env sh
2+
3+
# createComposerDockerExtras <result-var-by-ref>
4+
createComposerDockerExtras() {
5+
local __resultvar=$1
6+
7+
result=""
8+
9+
if [ -n "$SSH_FORWARD_ENABLED" ]; then
10+
if [ "$(uname)" = "Linux" ]; then
11+
result="--volume /etc/passwd:/etc/passwd:ro --volume /etc/group:/etc/group:ro --volume $SSH_AUTH_SOCK:/ssh-auth.sock --env SSH_AUTH_SOCK=/ssh-auth.sock ${result}"
12+
else
13+
result="--volume /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock --env SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock ${result}"
14+
fi
15+
fi
16+
17+
if [ -n "${COMPOSER_AUTH_ENABLED}" ]; then
18+
if [ -n "${COMPOSER_AUTH}" ]; then
19+
result="--env COMPOSER_AUTH=${COMPOSER_AUTH} ${result}"
20+
elif [ -n "${COMPOSER_AUTH_REPO}" ] && [ -n "${COMPOSER_AUTH_USER}" ] && [ -n "${COMPOSER_AUTH_PASSWORD}" ]; then
21+
composerAuth='{"http-basic":{"'${COMPOSER_AUTH_REPO}'":{"username":"'${COMPOSER_AUTH_USER}'","password":"'${COMPOSER_AUTH_PASSWORD}'"}}}'
22+
result="--env COMPOSER_AUTH=${composerAuth} ${result}"
23+
elif [ ! -f "${HOME}/.composer/auth.json" ]; then
24+
printf "${warning}Please make sure that %s/.composer/auth.json exists and the credentials of your repository are present, or provide env vars COMPOSER_AUTH_REPO, COMPOSER_AUTH_USER and COMPOSER_AUTH_PASSWORD${reset}\n" "${HOME}"
25+
fi
26+
fi
27+
28+
eval $__resultvar="'$result'"
29+
}
30+
31+
# createComposerDockerExtras <result-var-by-ref>
32+
createComposerDockerBuildExtras() {
33+
local __resultvar=$1
34+
35+
if [ -n "${COMPOSER_AUTH_ENABLED}" ]; then
36+
if [ -n "${COMPOSER_AUTH}" ]; then
37+
result="--build-arg COMPOSER_AUTH=${COMPOSER_AUTH} ${COMPOSER_DOCKER_EXTRAS}"
38+
elif [ -n "${COMPOSER_AUTH_REPO}" ] && [ -n "${COMPOSER_AUTH_USER}" ] && [ -n "${COMPOSER_AUTH_PASSWORD}" ]; then
39+
composerAuth='{"http-basic":{"'${COMPOSER_AUTH_REPO}'":{"username":"'${COMPOSER_AUTH_USER}'","password":"'${COMPOSER_AUTH_PASSWORD}'"}}}'
40+
result="--build-arg COMPOSER_AUTH=${composerAuth} ${DOCKER_BUILD_EXTRAS}"
41+
elif [ -f "${HOME}/.composer/auth.json" ]; then
42+
result="--secret id=composer-auth-json,src=${HOME}/.composer/auth.json ${DOCKER_BUILD_EXTRAS}"
43+
else
44+
printf "Please make sure that %s/.composer/auth.json exists and the credentials of your repository are present, or provide env vars COMPOSER_AUTH_REPO, COMPOSER_AUTH_USER and COMPOSER_AUTH_PASSWORD\n" "${HOME}"
45+
exit 1
46+
fi
47+
fi
48+
49+
eval $__resultvar="'$result'"
50+
}

bin/_include/functions-misc

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/env sh
2+
3+
# requireEnv <name>
4+
requireEnv() {
5+
name="$1"
6+
if eval "[ \"\$$name\" = \"\" ]"; then
7+
printf "${failure}Need ${failure_name}%s${failure} environment variable${reset}\n" "${name}"
8+
exit 1
9+
fi
10+
}
11+
12+
# showCmd <cmd>
13+
showCmd() {
14+
cmd="${1}"
15+
if [ "${SHOW_CMD}" = "1" ]; then
16+
printf "${command}$ %s${reset}\n" "${cmd}"
17+
fi
18+
}
19+
20+
# include a local configuration file and the related user configuration file
21+
includeLocalConfig() {
22+
configName="${1}"
23+
shift 1
24+
25+
if [ -f "${BIN_DIR}/local/include-${configName}" ]; then
26+
if [ "${SHOW_CMD}" = "1" ]; then
27+
>&2 printf "${command}Include local config ${command_name}${BIN_DIR}/local/include-${configName}${reset}\n"
28+
fi
29+
30+
. "${BIN_DIR}/local/include-${configName}"
31+
fi
32+
33+
if [ -f "${BIN_DIR}/local/include-${configName}-user" ]; then
34+
if [ "${SHOW_CMD}" = "1" ]; then
35+
>&2 printf "${command}Include local config ${command_name}${BIN_DIR}/local/include-${configName}-user${reset}\n"
36+
fi
37+
38+
. "${BIN_DIR}/local/include-${configName}-user"
39+
fi
40+
}
41+
42+
# interactiveTty
43+
interactiveTty() {
44+
if [ -t 0 ]; then
45+
echo "--interactive --tty"
46+
fi
47+
}
48+
49+
# pullImage <image>
50+
pullImage() {
51+
image="${1}"
52+
if [ -n "${image}" ] && [ -z "${NO_PULL}" ]; then
53+
docker pull -q "${image}"
54+
fi
55+
}
56+
57+
# wrapper <wrapperName> <localName>
58+
wrapper() {
59+
wrapperName="${1}"
60+
localName="${2}"
61+
if [ -z "${wrapperName}" ]; then
62+
>&2 printf "${failure}No wrapperName given in wrapper()${reset}\n"
63+
>&2 printf "Args:\n"
64+
echo "echo"
65+
exit 1
66+
fi
67+
if [ -z "${localName}" ]; then
68+
>&2 printf "${failure}No localName given in wrapper()${reset}\n"
69+
>&2 printf "Args:\n"
70+
echo "echo"
71+
exit 1
72+
fi
73+
74+
if [ -z ${NO_LOCAL} ] && [ -n "${LOCAL_WRAPPER_DIR}" ] && [ -f "${LOCAL_WRAPPER_DIR}/bin/${localName}" ]; then
75+
localPath="${LOCAL_WRAPPER_DIR}/bin/${localName}"
76+
>&2 printf "${command}local ${command_name}${localPath}${reset}\n"
77+
echo "${localPath}"
78+
else
79+
wrapperPath="${BIN_DIR}/wrapper/devtools-${wrapperName}"
80+
>&2 printf "${command}wrapper ${command_name}${wrapperPath}${reset}\n"
81+
echo "${wrapperPath}"
82+
fi
83+
}

bin/all-checks

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
# Do not modify this file - this file is created by bin/wrapper/dist-sync and will be overriden every time dist-sync is invoked.
4+
# see https://gitlab.brainbits.net/docker/dist/-/blob/master/README.md
5+
6+
. "$(dirname $0)/config"
7+
8+
includeLocalConfig "all-checks" $*
9+
10+
printf "${check_all}### running all checks...${reset}\n"
11+
12+
if [ -z "$NO_PULL" ]; then
13+
"${BIN_DIR}/wrapper/devtools-pull" -q
14+
fi
15+
16+
checks=($CHECKS)
17+
warn_checks=($WARN_CHECKS)
18+
results=()
19+
timings=()
20+
21+
for checkCmd in ${checks[@]}; do
22+
start=$(date +%s)
23+
24+
"${BIN_DIR}/check/${checkCmd}"
25+
results+=($?)
26+
27+
end=$(date +%s)
28+
timings+=($((end-start)))
29+
done
30+
31+
exitCode=0
32+
for index in ${!checks[@]}; do
33+
checkCmd=${checks[$index]}
34+
result=${results[$index]}
35+
timing=${timings[$index]}
36+
37+
printf "${check_all}### ${command}%4d s${check_all} | " "${timing}"
38+
if [[ ${result} -eq 125 ]]; then
39+
printf "${failure}✘ docker run for ${checkCmd} failed. Is docker running? ${reset}\n"
40+
if [[ ${exitCode} -eq 0 ]]; then
41+
exitCode="${result}"
42+
fi
43+
elif [[ $result == 0 ]]; then
44+
printf "${success}${checkCmd} ${reset}\n"
45+
elif [[ " ${warn_checks[@]} " =~ " ${checkCmd} " ]]; then
46+
printf "${warning}! ${checkCmd}${reset}\n"
47+
else
48+
printf "${failure}${checkCmd} ${reset}\n"
49+
if [[ ${exitCode} -eq 0 ]]; then
50+
exitCode=${result}
51+
fi
52+
fi
53+
done
54+
55+
exit $exitCode

bin/check/_variant/code-style-phpcs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env sh
2+
3+
# Do not modify this file - this file is created by bin/wrapper/dist-sync and will be overriden every time dist-sync is invoked.
4+
# see https://gitlab.brainbits.net/docker/dist/-/blob/master/README.md
5+
6+
. "$(dirname $0)/../../config"
7+
8+
cmd=$*
9+
if [ $# -eq 0 ]; then
10+
cmd=""
11+
if [ -n "${CI}" ]; then
12+
cmd="${cmd} -q"
13+
fi
14+
15+
if [ -n "${CODE_STYLE_REPORT_FILE}" ]; then
16+
mkdir -p "$(dirname ${CODE_STYLE_REPORT_FILE})"
17+
cmd="${cmd} --report=Satesh\\Phpcs\\GitLabReport --report-file=${CODE_STYLE_REPORT_FILE}"
18+
fi
19+
fi
20+
21+
"$(wrapper phpcs ${PHPCS_CMD:-phpcs})" ${cmd}

0 commit comments

Comments
 (0)