Skip to content

Commit

Permalink
Basic implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sweetchuck committed Jan 17, 2021
1 parent 286b28f commit b0d5e2d
Show file tree
Hide file tree
Showing 24 changed files with 8,574 additions and 1 deletion.
128 changes: 128 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@

version: 2.1

.env_app: &env_app
APP_COMPOSER_VERSION: '2.0.1'
APP_COMPOSER_HASH: 'c31c1e292ad7be5f49291169c0ac8f683499edddcfd4e42232982d0fd193004208a58ff6f353fde0012d35fdd72bc394'
SHELL: '/bin/bash'

.env_composer: &env_composer
COMPOSER_NO_INTERACTION: '1'
COMPOSER_MEMORY_LIMIT: '-1'
COMPOSER_DISABLE_XDEBUG_WARN: '1'

orbs:
codecov: 'codecov/codecov@1.0.5'

executors:
php704:
environment:
<<: *env_app
<<: *env_composer

docker:
-
name: 'main'
image: 'circleci/php:7.4'

commands:
install_composer:
description: 'Install Composer CLI tool'
steps:
-
run:
name: ''
command: |4
mkdir -p "${HOME}/.local/bin"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === getenv('APP_COMPOSER_HASH')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php \
--filename 'composer' \
--install-dir "${HOME}/.local/bin" \
--version "${APP_COMPOSER_VERSION}"
php -r "unlink('composer-setup.php');"
whereis composer
which composer
type composer
composer --version
composer_install:
description: 'Install Composer dependencies with cache restore and save'
steps:
-
restore_cache:
name: 'Composer - cache restore'
keys:
- 'composer-{{ checksum "./composer.lock" }}-2'

-
run:
name: 'Composer - install'
command: >
composer install --no-progress --ansi
-
save_cache:
name: 'Composer - cache save'
key: 'composer-{{ checksum "./composer.lock" }}-2'
paths:
- '~/.composer/cache/'


lint:
description: 'Run linters'
steps:
-
run:
name: 'Run linters'
command: 'bin/robo --ansi lint'

test:
description: 'Run tests'
steps:
-
run:
name: 'Codeception - unit'
command: 'bin/robo --ansi test unit'
- codecov/upload:
flags: 'unit'
file: './tests/_output/machine/coverage/unit/coverage.xml'
- store_test_results:
name: 'Store unit test results'
path: './tests/_output/machine/junit'

jobs:
build:
executor: 'php704'
working_directory: '~/repo'
steps:
- 'checkout'
- 'composer_install'
lint:
executor: 'php704'
working_directory: '~/repo'
steps:
- 'checkout'
- 'composer_install'
- 'lint'
test_php704:
executor: 'php704'
working_directory: '~/repo'
steps:
- 'checkout'
- 'composer_install'
- 'test'

workflows:
lint_and_test:
jobs:
-
build: {}
-
lint:
requires:
- build
-
test_php704:
requires:
- build
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
end_of_line = LF
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
31 changes: 31 additions & 0 deletions .git-hooks
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

echo "BEGIN Git hook: ${sghHookName}"

function sghExit ()
{
echo "END Git hook: ${sghHookName}"

exit $1
}

export COMPOSER_DISABLE_XDEBUG_WARN=1

# @todo Better detection for executables: php, composer.phar.
sghRobo="$(composer config 'bin-dir')/robo"

test -s "${sghBridge}-local" && . "${sghBridge}-local"

sghTask="githook:${sghHookName}"

# Exit without error if "robo" doesn't exists or it has no corresponding task.
test -x "$sghRobo" || sghExit 0
"${sghRobo}" help "${sghTask}" 1> /dev/null 2>&1 || sghExit 0

if [ "$sghHasInput" = 'true' ]; then
"$sghRobo" "${sghTask}" $@ <<< $(</dev/stdin) || sghExit $?
else
"$sghRobo" "${sghTask}" $@ || sghExit $?
fi

sghExit 0
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

/bin/

/reports/

/tests/_data/fixtures/project-template/*/vendor/
/tests/_envs/*.local.yml
/tests/_output/
/tests/_support/_generated/
/tests/*.suite.yml

/vendor/

/.git-hooks-local
/codeception.yml
/phpcs.xml
/sweetchuck-composer-suite-*.tar
/sweetchuck-composer-suite-*.zip
Loading

0 comments on commit b0d5e2d

Please sign in to comment.