mirror of
https://github.com/opdavies/build-configs.git
synced 2025-09-06 19:35:33 +01:00
Add just and justfile
This commit is contained in:
parent
0d774daca0
commit
5029aab415
3 changed files with 23 additions and 49 deletions
113
run
113
run
|
@ -1,113 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
export PATH=$PATH:./bin:./vendor/bin:./vendor-bin/box/vendor/bin
|
||||
|
||||
# Delete any temporary or generated files.
|
||||
function clean {
|
||||
rm -fr dist/* tmp vendor vendor-bin/box/vendor
|
||||
touch dist/.keep var/.keep
|
||||
}
|
||||
|
||||
# Build the phar version of build-configs.
|
||||
function build {
|
||||
clean
|
||||
|
||||
# Install dependencies.
|
||||
composer validate
|
||||
composer install --no-dev --prefer-dist --optimize-autoloader
|
||||
composer install --prefer-dist --optimize-autoloader --working-dir ./vendor-bin/box
|
||||
|
||||
nix develop --command composer dump-env prod
|
||||
|
||||
nix develop --command build-configs cache:clear
|
||||
nix develop --command build-configs cache:warmup
|
||||
|
||||
# Generate the phar file.
|
||||
box compile --config box.json.dist
|
||||
|
||||
rm -f .env.local .env.local.php
|
||||
|
||||
tree dist/
|
||||
|
||||
# TODO: build a Nix derivation and add it to the store.
|
||||
}
|
||||
|
||||
function ci:test {
|
||||
nix develop --command composer install
|
||||
nix develop --command ./run test:snapshots
|
||||
nix develop --command phpunit --testdox
|
||||
}
|
||||
|
||||
# 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 test {
|
||||
phpunit "${@}"
|
||||
}
|
||||
|
||||
# Create a new snapshot for a configuration based on generated files.
|
||||
function test:create-snapshot {
|
||||
set -o nounset
|
||||
|
||||
config="${1}"
|
||||
|
||||
config_file="tests/snapshots/configs/${config}.yaml"
|
||||
output_path="tests/snapshots/output/${config}"
|
||||
|
||||
cat "${config_file}"
|
||||
|
||||
rm -fr "${output_path}"
|
||||
|
||||
./bin/build-configs app:generate --config-file "${config_file}" --output-dir "${output_path}"
|
||||
|
||||
git status "${output_path}"
|
||||
}
|
||||
|
||||
# Generate a file and ensure it matches the expected version.
|
||||
function test:snapshots {
|
||||
rm -rf .ignored/snapshots
|
||||
mkdir -p .ignored/snapshots
|
||||
|
||||
local configs=(
|
||||
# TODO: add more configurations for different types and configurations.
|
||||
drupal
|
||||
drupal-commerce-kickstart
|
||||
drupal-localgov
|
||||
fractal
|
||||
)
|
||||
|
||||
for config in "${configs[@]}"; do
|
||||
config_file="tests/snapshots/configs/${config}.yaml"
|
||||
input_path="tests/snapshots/output/${config}"
|
||||
output_path=".ignored/snapshots/output/${config}"
|
||||
|
||||
cat "${config_file}"
|
||||
|
||||
./bin/build-configs app:generate --config-file "${config_file}" --output-dir "${output_path}"
|
||||
|
||||
find "${input_path}" -type f -print0 | while IFS= read -r -d '' original_file; do
|
||||
generated_file="${output_path}/${original_file#"${input_path}"/}"
|
||||
|
||||
if cmp -s "${original_file}" "${generated_file}"; then
|
||||
echo "Files match: ${original_file}"
|
||||
else
|
||||
# TODO: show the diff for all failed files. This will stop after the first failure.
|
||||
echo "Files do not match: ${original_file}"
|
||||
diff "${original_file}" "${generated_file}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
TIMEFORMAT=$'\nTask completed in %3lR'
|
||||
time "${@:-help}"
|
Loading…
Add table
Add a link
Reference in a new issue