This repository has been archived by the owner on Feb 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·149 lines (116 loc) · 3.22 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
set -e
TTY=""
if [[ ! -t 1 ]]; then
TTY="-T"
fi
export COMPOSE_DOCKER_CLI_BUILD=1
export DOCKER_BUILDKIT=1
function task:build-and-push-images {
export DOCKER_BUILDKIT=1
docker-compose build assets
docker-compose push assets
}
function task:copy-theme-assets {
docker container run --entrypoint sh --name oliverdavies-uk-assets ghcr.io/opdavies/oliverdavies-uk-assets:node-14
docker cp oliverdavies-uk-assets:/node/build web/themes/custom/opdavies
docker container rm oliverdavies-uk-assets
}
function task:bash {
task:exec bash "${@}"
}
function task:ci:build {
docker-compose build php
docker-compose push php
}
function task:ci:deploy {
ansible-galaxy install -r tools/deployment/requirements.yml
ansible-playbook tools/deployment/deploy.yml \
-e "ansistrano_deploy_branch=${1:-production}" \
-i tools/deployment/hosts.yml \
--vault-password-file="${2:-tools/deployment/.vault-pass.txt}" \
"${@}"
}
function task:ci:test {
task:lint:dockerfile
}
function task:exec {
# Run any command in the php container.
docker-compose exec $TTY php "${@}"
}
function task:composer {
# Execute Composer commands.
task:exec composer "${@}"
}
function task:db:export {
task:drush sql:dump \
--gzip \
--result-file=/app/drupal.sql
}
function task:drupal:install {
# Install Drupal.
task:drush site:install -y --account-pass admin123 --existing-config
}
function task:drush {
# Execute Drush commands.
task:exec drush "${@}"
}
function task:frontend:console {
docker-compose run --rm node
}
function task:help {
printf "%s <task> [args]\n\nTasks:\n" "${0}"
# Only show functions that have the "task:" prefix.
compgen -A function | sed -En 's/task:(.*)/\1/p' | cat -n
printf "\nExtended help:\n Each task has comments for general usage\n"
}
function task:lint:dockerfile {
docker container run --rm -i \
-v $(pwd)/.hadolint.yaml:/.config/hadolint.yaml \
hadolint/hadolint hadolint \
--ignore DL3008 \
--ignore DL3022 \
"${@}" - < Dockerfile
}
function task:test:functional {
run-tests --testsuite functional "${@}"
}
function task:test:integration {
# Run integration tests.
run-tests --testsuite kernel "${@}"
}
function task:test:quality {
# Run quality checks (code linting, static analysis, etc.).
docker-compose run --no-deps php phpcs
docker-compose run --no-deps php phpstan "--memory-limit=256M"
}
function task:test:unit {
# Run unit tests.
run-tests --testsuite unit "${@}"
}
function run-tests {
# Run PHPUnit tests.
docker-compose run --rm php --user ${DOCKER_WEB_USER} php phpunit "${@}"
}
function task:yarn:build:css {
# Build CSS assets, this is meant to be run from within the assets container.
local args=()
if [ "${NODE_ENV}" == "production" ]; then
args=(--minify)
else
args=(--watch)
fi
tailwindcss --postcss --input assets/css/tailwind.pcss \
--output build/app.css "${args[@]}"
}
function task:yarn:build:js {
# Build JS assets, this is meant to be run from within the assets container.
local args=()
if [ "${NODE_ENV}" == "production" ]; then
args=(--minify)
else
args=(--sourcemap --watch)
fi
esbuild assets/js/*.* --outdir=build --bundle "${args[@]}"
}
eval "task:${@:-help}"