mirror of
https://github.com/opdavies/build-configs.git
synced 2025-09-06 03:15:34 +01:00
chore(run): replace justfiles with run files
This commit is contained in:
parent
3a86b4813a
commit
f5a8c691f0
11 changed files with 386 additions and 263 deletions
23
templates/drupal/.github/workflows/ci.yml.twig
vendored
23
templates/drupal/.github/workflows/ci.yml.twig
vendored
|
@ -17,30 +17,9 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Install just
|
||||
run: |
|
||||
curl --proto '=https' \
|
||||
--tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin
|
||||
|
||||
- name: Checkout the code
|
||||
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
|
||||
|
||||
- name: Build and test
|
||||
run: |
|
||||
docker compose version
|
||||
|
||||
docker network create traefik_proxy
|
||||
|
||||
cp --no-clobber .env.example .env
|
||||
|
||||
docker compose build --progress plain
|
||||
|
||||
docker compose up --detach
|
||||
docker compose logs
|
||||
|
||||
just composer install --quiet --no-progress
|
||||
|
||||
just test --testdox --colors=always
|
||||
|
||||
just _run php phpcs
|
||||
just _run php phpstan analyze --no-progress --memory-limit=512M
|
||||
./run ci:test
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
# {{ managedText | raw }}
|
||||
|
||||
default:
|
||||
@just --list
|
||||
|
||||
# Start the project
|
||||
start:
|
||||
cp -v --no-clobber .env.example .env
|
||||
docker compose up -d
|
||||
|
||||
# Stop the project
|
||||
stop:
|
||||
docker compose down
|
||||
|
||||
composer *args:
|
||||
{{ "just _exec php composer {{ args }}" | raw }}
|
||||
|
||||
alias phpunit := test
|
||||
|
||||
test *args:
|
||||
{{ "just _exec php phpunit --colors=always {{ args }}" | raw }}
|
||||
|
||||
drush *args:
|
||||
{{ "just _exec php drush {{ args }}" | raw }}
|
||||
|
||||
install *args:
|
||||
{{ "just _exec php drush site:install -y {{ args }}" | raw }}
|
||||
|
||||
# Enable or disable Git hooks
|
||||
git-hooks command:
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
case "{{ '{{ command }}'|raw }}" in
|
||||
"on")
|
||||
echo "Enabling Git hooks..."
|
||||
git config core.hooksPath .githooks
|
||||
;;
|
||||
"off")
|
||||
echo "Disabling Git hooks..."
|
||||
git config --unset core.hooksPath
|
||||
;;
|
||||
*)
|
||||
echo "Error: Invalid argument. Must be either 'on' or 'off'"
|
||||
;;
|
||||
esac
|
||||
|
||||
{% if experimental.runGitHooksBeforePush %}
|
||||
test-commit:
|
||||
just _run php phpcs
|
||||
just _run php phpstan analyze --no-progress --memory-limit=512M
|
||||
|
||||
just test --testdox --testsuite unit
|
||||
just test --testdox --testsuite kernel
|
||||
{% endif %}
|
||||
|
||||
_exec +args:
|
||||
{{ "docker compose exec -T {{ args }}" | raw }}
|
||||
|
||||
_run service command *args:
|
||||
docker compose run \
|
||||
--entrypoint {{ "{{ command }}"|raw }} \
|
||||
--no-deps \
|
||||
--rm \
|
||||
-T \
|
||||
{{ "{{ service }} {{ args }}"|raw }}
|
||||
|
||||
# vim: ft=just
|
118
templates/drupal/run.twig
Executable file
118
templates/drupal/run.twig
Executable file
|
@ -0,0 +1,118 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# {{ managedText | raw }}
|
||||
|
||||
set -eu
|
||||
|
||||
# Run automated tests as part of the Continuous Integration (CI) pipeline.
|
||||
function ci:test {
|
||||
lint:dockerfile
|
||||
|
||||
docker compose version
|
||||
|
||||
docker network create traefik_proxy
|
||||
|
||||
cp --no-clobber .env.example .env
|
||||
|
||||
docker compose build --progress plain
|
||||
|
||||
docker compose up --detach
|
||||
docker compose logs
|
||||
|
||||
composer install --quiet --no-progress
|
||||
|
||||
test --testdox
|
||||
|
||||
quality
|
||||
}
|
||||
|
||||
# Run a command within the php container.
|
||||
function cmd {
|
||||
docker compose exec php "${@}"
|
||||
}
|
||||
|
||||
function coding-standards {
|
||||
cmd phpcs "${@}"
|
||||
}
|
||||
|
||||
function composer {
|
||||
_exec php composer "${@}"
|
||||
}
|
||||
|
||||
function drush {
|
||||
_exec php drush "${@}"
|
||||
}
|
||||
|
||||
function git-hooks:off {
|
||||
git config --unset core.hooksPath
|
||||
}
|
||||
|
||||
function git-hooks:on {
|
||||
git config core.hooksPath .githooks
|
||||
}
|
||||
|
||||
# Display a list of all available commands.
|
||||
function help {
|
||||
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
||||
|
||||
compgen -A function | grep -v "^_" | cat -n
|
||||
|
||||
printf "\nExtended help:\n Each task has comments for general usage\n"
|
||||
}
|
||||
|
||||
function lint:dockerfile {
|
||||
docker container run --rm -i \
|
||||
hadolint/hadolint hadolint --ignore DL3008 --ignore DL3059 -t style "${@}" - < Dockerfile
|
||||
}
|
||||
|
||||
function quality {
|
||||
coding-standards
|
||||
static-analysis
|
||||
}
|
||||
|
||||
function start {
|
||||
cp -v --no-clobber .env.example .env
|
||||
|
||||
docker compose up -d
|
||||
}
|
||||
|
||||
function static-analysis {
|
||||
cmd phpstan --memory-limit=-1 --no-progress "${@}"
|
||||
}
|
||||
|
||||
function stop {
|
||||
docker compose down
|
||||
}
|
||||
|
||||
function test {
|
||||
_exec php phpunit --colors=always "${@}"
|
||||
}
|
||||
|
||||
function test:commit {
|
||||
test --testdox --testsuite functional
|
||||
test --testdox --testsuite kernel
|
||||
test --testdox --testsuite unit
|
||||
|
||||
quality
|
||||
}
|
||||
|
||||
function _exec {
|
||||
docker compose exec -T "${@}"
|
||||
}
|
||||
|
||||
function _run {
|
||||
local service="${1}"
|
||||
local command="${2}"
|
||||
|
||||
docker compose run \
|
||||
--entrypoint "${command}" \
|
||||
--no-deps \
|
||||
--rm \
|
||||
-T \
|
||||
"${service}" "${@}"
|
||||
}
|
||||
|
||||
TIMEFORMAT=$'\nTask completed in %3lR'
|
||||
time "${@:-help}"
|
||||
|
||||
# vim: ft=bash
|
Loading…
Add table
Add a link
Reference in a new issue