Skip to content

Commit 15260a6

Browse files
committed
Use parallel-processes in bin/start
1 parent dbda484 commit 15260a6

File tree

7 files changed

+78
-7
lines changed

7 files changed

+78
-7
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ jobs:
99

1010
phpstan:
1111
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
php: [--php=7.4, --php=8.0]
1215
steps:
1316
- uses: actions/checkout@v2
1417
- uses: ./.github/actions/ci-env
15-
- run: bin/ci/phpstan
18+
- run: bin/ci/phpstan ${{ matrix.php }}
1619

1720
phpdd:
1821
runs-on: ubuntu-latest

bin/ci/shellcheck

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ for fileToCheck in "${filesToCheck[@]}"; do
2121
# SC2034: COMPOSER_HOME_SYMFONY appears unused. Verify use (or export if used externally).
2222
# SC2086: Double quote to prevent globbing and word splitting. (needed for ${DOCKER_INTERACTIVE_PARAMETER})
2323
# SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
24-
shellcheck --color=always --exclude SC1090,SC2034,SC2086,SC2181 "${fileToCheck}"
24+
# SC2230: which is non-standard. Use builtin 'command -v' instead.
25+
shellcheck --color=always --exclude SC1090,SC2034,SC2086,SC2181,SC2230 "${fileToCheck}"
2526
if [ ${?} != 0 ]; then
2627
exitCode=1
2728
fi

bin/composer

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ set -eu
55
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/..")"
66

77
source "${ROOT_DIR}"/config/version/composer-version.env
8+
source "${ROOT_DIR}"/bin/docker-ids-parameters.inc.bash
89
source "${ROOT_DIR}"/bin/docker-interactive-parameter.inc.bash
910

1011
docker \
1112
run \
1213
--rm \
1314
--tty \
1415
${DOCKER_INTERACTIVE_PARAMETER} \
15-
--volume "${ROOT_DIR}":/app \
16-
--user "$(id -u)":"$(id -g)" \
17-
--env COMPOSER_CACHE_DIR=/app/var/composer \
16+
--volume "${ROOT_DIR}":"${ROOT_DIR}" \
17+
--user "${DOCKER_UID}":"${DOCKER_GID}" \
18+
--env COMPOSER_CACHE_DIR="${ROOT_DIR}"/var/composer \
19+
--workdir "${ROOT_DIR}" \
1820
composer:"${COMPOSER_VERSION}" \
1921
"${@}"

bin/docker-ids-parameters.inc.bash

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
if [ -n "${HOST_UID:-}" ]; then
6+
readonly DOCKER_UID="${HOST_UID}"
7+
else
8+
readonly DOCKER_UID="$(id -u)"
9+
fi
10+
11+
if [ -n "${HOST_GID:-}" ]; then
12+
readonly DOCKER_GID="${HOST_GID}"
13+
else
14+
readonly DOCKER_GID="$(id -g)"
15+
fi

bin/start

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,20 @@ set -eu
44

55
readonly ROOT_DIR="$(realpath "$(dirname "$(realpath "$0")")/..")"
66

7-
"${ROOT_DIR}"/bin/ci/docker
8-
"${ROOT_DIR}"/bin/composer install
7+
source "${ROOT_DIR}"/bin/docker-interactive-parameter.inc.bash
8+
9+
docker \
10+
run \
11+
--rm \
12+
--tty \
13+
${DOCKER_INTERACTIVE_PARAMETER} \
14+
--volume "${ROOT_DIR}":"${ROOT_DIR}" \
15+
--volume "$(which docker)":/usr/bin/docker \
16+
--volume /var/run/docker.sock:/var/run/docker.sock \
17+
--env HOST_UID="$(id -u)" \
18+
--env HOST_GID="$(id -g)" \
19+
--workdir "${ROOT_DIR}" \
20+
steevanb/php-parallel-processes:parallel-processes-0.2.1 \
21+
php \
22+
bin/start.php \
23+
"${@}"

bin/start.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Steevanb\ParallelProcess\{
6+
Console\Application\ParallelProcessesApplication,
7+
Process\Process
8+
};
9+
use Symfony\Component\Console\Input\ArgvInput;
10+
11+
require $_ENV['COMPOSER_GLOBAL_AUTOLOAD_FILE_NAME'];
12+
13+
$rootDir = dirname(__DIR__);
14+
15+
$ciDockerProcess = (new Process([$rootDir . '/bin/ci/docker']))
16+
->setName('bin/ci/docker');
17+
18+
$ciEnvProcess = (new Process([$rootDir . '/bin/ci/env']))
19+
->setName('bin/ci/env');
20+
$ciEnvProcess->getStartCondition()->addProcessSuccessful($ciDockerProcess);
21+
22+
(new ParallelProcessesApplication())
23+
->addProcess($ciDockerProcess)
24+
->addProcess($ciEnvProcess)
25+
->addProcess(
26+
(new Process([$rootDir . '/bin/parallel-processes/docker']))
27+
->setName('bin/parallel-processes/docker')
28+
)
29+
->addProcess(
30+
(new Process([$rootDir . '/bin/release/docker']))
31+
->setName('bin/release/docker')
32+
)
33+
->run(new ArgvInput($argv));

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
- Create configuration for repository version
88
- Create configuration for Composer version
99
- Rework bin/ci/shellcheck to find files to check instead of having a list
10+
- Update phpstan, add some plugins and run it for PHP 7.4 and 8.0
11+
- Use parallel-processes in `bin/start`
1012

1113
### [0.2.1](../../compare/0.2.0...0.2.1) - 2022-01-08
1214

0 commit comments

Comments
 (0)