mirror of
https://github.com/opdavies/build-configs.git
synced 2025-02-08 16:15:03 +00:00
Add just and justfile
This commit is contained in:
parent
0d774daca0
commit
5029aab415
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
|
@ -20,9 +20,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
nix_path: nixpkgs=channel:nixos-23.05
|
nix_path: nixpkgs=channel:nixos-23.05
|
||||||
|
|
||||||
- run: ./run ci:test
|
- run: nix develop --command just ci-test
|
||||||
|
- run: nix develop --command just build
|
||||||
- run: ./run build
|
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
echo "DATE=$(date '+%Y-%m-%d-%H.%M.%S')" >> $GITHUB_ENV
|
echo "DATE=$(date '+%Y-%m-%d-%H.%M.%S')" >> $GITHUB_ENV
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
perSystem = { config, self', inputs', pkgs, system, ... }: {
|
perSystem = { config, self', inputs', pkgs, system, ... }: {
|
||||||
devshells.default = {
|
devshells.default = {
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
|
"just"
|
||||||
"php81"
|
"php81"
|
||||||
"php81Packages.composer"
|
"php81Packages.composer"
|
||||||
];
|
];
|
||||||
|
|
66
run → justfile
Executable file → Normal file
66
run → justfile
Executable file → Normal file
|
@ -1,29 +1,18 @@
|
||||||
#!/usr/bin/env bash
|
_default:
|
||||||
|
just --list
|
||||||
|
|
||||||
set -o errexit
|
build:
|
||||||
set -o pipefail
|
just clean
|
||||||
|
|
||||||
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.
|
# Install dependencies.
|
||||||
composer validate
|
composer validate
|
||||||
composer install --no-dev --prefer-dist --optimize-autoloader
|
composer install --no-dev --prefer-dist --optimize-autoloader
|
||||||
composer install --prefer-dist --optimize-autoloader --working-dir ./vendor-bin/box
|
composer install --prefer-dist --optimize-autoloader --working-dir ./vendor-bin/box
|
||||||
|
|
||||||
nix develop --command composer dump-env prod
|
composer dump-env prod
|
||||||
|
|
||||||
nix develop --command build-configs cache:clear
|
./build-configs cache:clear
|
||||||
nix develop --command build-configs cache:warmup
|
./build-configs cache:warmup
|
||||||
|
|
||||||
# Generate the phar file.
|
# Generate the phar file.
|
||||||
box compile --config box.json.dist
|
box compile --config box.json.dist
|
||||||
|
@ -33,36 +22,26 @@ function build {
|
||||||
tree dist/
|
tree dist/
|
||||||
|
|
||||||
# TODO: build a Nix derivation and add it to the store.
|
# TODO: build a Nix derivation and add it to the store.
|
||||||
}
|
|
||||||
|
|
||||||
function ci:test {
|
clean:
|
||||||
|
rm -fr dist/* tmp vendor vendor-bin/box/vendor
|
||||||
|
touch dist/.keep var/.keep
|
||||||
|
|
||||||
|
ci-test:
|
||||||
nix develop --command composer install
|
nix develop --command composer install
|
||||||
nix develop --command ./run test:snapshots
|
nix develop --command ./run test:snapshots
|
||||||
nix develop --command phpunit --testdox
|
nix develop --command phpunit --testdox
|
||||||
}
|
|
||||||
|
|
||||||
# Display a list of all available commands.
|
test *args:
|
||||||
function help {
|
phpunit {{ args }}
|
||||||
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
|
||||||
|
|
||||||
compgen -A function | grep -v "^_" | cat -n
|
create-snapshot config:
|
||||||
|
#!/usr/bin/env bash
|
||||||
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
|
set -o nounset
|
||||||
|
|
||||||
config="${1}"
|
config_file="tests/snapshots/configs/{{ config }}.yaml"
|
||||||
|
output_path="tests/snapshots/output/{{ config }}"
|
||||||
|
|
||||||
config_file="tests/snapshots/configs/${config}.yaml"
|
|
||||||
output_path="tests/snapshots/output/${config}"
|
|
||||||
|
|
||||||
cat "${config_file}"
|
cat "${config_file}"
|
||||||
|
|
||||||
rm -fr "${output_path}"
|
rm -fr "${output_path}"
|
||||||
|
@ -70,10 +49,9 @@ function test:create-snapshot {
|
||||||
./bin/build-configs app:generate --config-file "${config_file}" --output-dir "${output_path}"
|
./bin/build-configs app:generate --config-file "${config_file}" --output-dir "${output_path}"
|
||||||
|
|
||||||
git status "${output_path}"
|
git status "${output_path}"
|
||||||
}
|
|
||||||
|
|
||||||
# Generate a file and ensure it matches the expected version.
|
run-snapshots:
|
||||||
function test:snapshots {
|
#!/usr/bin/env bash
|
||||||
rm -rf .ignored/snapshots
|
rm -rf .ignored/snapshots
|
||||||
mkdir -p .ignored/snapshots
|
mkdir -p .ignored/snapshots
|
||||||
|
|
||||||
|
@ -107,7 +85,3 @@ function test:snapshots {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
}
|
|
||||||
|
|
||||||
TIMEFORMAT=$'\nTask completed in %3lR'
|
|
||||||
time "${@:-help}"
|
|
Loading…
Reference in a new issue