mirror of
https://github.com/opdavies/build-configs.git
synced 2025-02-02 05:47:32 +00:00
Replace just
with run
This commit is contained in:
parent
bfe0117e5e
commit
75bbef2dc9
18
.github/workflows/ci.yml
vendored
18
.github/workflows/ci.yml
vendored
|
@ -1,5 +1,4 @@
|
||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
|
@ -9,24 +8,9 @@ on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 12 15 * *"
|
- cron: "0 12 15 * *"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
|
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
|
||||||
|
- run: ./run ci:test
|
||||||
- uses: cachix/install-nix-action@6ed004b9ccb68dbc28e7c85bee15fa93dbd214ac # v22
|
|
||||||
with:
|
|
||||||
nix_path: nixpkgs=channel:nixos-23.05
|
|
||||||
|
|
||||||
- run: nix develop --command just ci-test
|
|
||||||
- run: nix develop --command just build
|
|
||||||
|
|
||||||
- run: |
|
|
||||||
echo "DATE=$(date '+%Y-%m-%d-%H.%M.%S')" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5 # v1.13.0
|
|
||||||
with:
|
|
||||||
artifacts: dist/build-configs
|
|
||||||
tag: ${{ env.DATE }}
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
name: build-configs
|
name: build-configs
|
||||||
type: symfony
|
type: symfony
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
flake:
|
flake:
|
||||||
devshell:
|
devshell:
|
||||||
packages:
|
packages:
|
||||||
- just
|
- bashInteractive
|
||||||
- php82
|
- php82
|
||||||
- php82Packages.composer
|
- php82Packages.composer
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
inherit (pkgs) mkShell;
|
inherit (pkgs) mkShell;
|
||||||
in {
|
in {
|
||||||
devShells.${system}.default =
|
devShells.${system}.default =
|
||||||
mkShell { buildInputs = with pkgs; [ just php82 php82Packages.composer ]; };
|
mkShell { buildInputs = with pkgs; [ bashInteractive php82 php82Packages.composer ]; };
|
||||||
|
|
||||||
formatter.${system} = pkgs.nixfmt;
|
formatter.${system} = pkgs.nixfmt;
|
||||||
};
|
};
|
||||||
|
|
87
justfile
87
justfile
|
@ -1,87 +0,0 @@
|
||||||
_default:
|
|
||||||
just --list
|
|
||||||
|
|
||||||
build:
|
|
||||||
just clean
|
|
||||||
|
|
||||||
# Install dependencies.
|
|
||||||
composer validate
|
|
||||||
composer install --no-dev --prefer-dist --optimize-autoloader
|
|
||||||
composer install --prefer-dist --optimize-autoloader --working-dir ./vendor-bin/box
|
|
||||||
|
|
||||||
composer dump-env prod
|
|
||||||
|
|
||||||
./bin/build-configs cache:clear
|
|
||||||
./bin/build-configs cache:warmup
|
|
||||||
|
|
||||||
# Generate the phar file.
|
|
||||||
./vendor-bin/box/vendor/bin/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.
|
|
||||||
|
|
||||||
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 just run-snapshots
|
|
||||||
nix develop --command vendor/bin/phpunit --testdox
|
|
||||||
|
|
||||||
test *args:
|
|
||||||
phpunit {{ args }}
|
|
||||||
|
|
||||||
create-snapshot config:
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -o nounset
|
|
||||||
|
|
||||||
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}"
|
|
||||||
|
|
||||||
run-snapshots:
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
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
|
|
93
run
Executable file
93
run
Executable file
|
@ -0,0 +1,93 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
export PATH="$PATH:./vendor/bin"
|
||||||
|
|
||||||
|
function build {
|
||||||
|
nix build .
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci:test {
|
||||||
|
composer install
|
||||||
|
test:snapshots
|
||||||
|
test --testdox
|
||||||
|
}
|
||||||
|
|
||||||
|
function clean {
|
||||||
|
rm -fr dist/* tmp vendor vendor-bin/box/vendor
|
||||||
|
touch dist/.keep var/.keep
|
||||||
|
}
|
||||||
|
|
||||||
|
function create-snapshot {
|
||||||
|
local 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"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
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}"
|
||||||
|
|
||||||
|
# vim: ft=bash
|
Loading…
Reference in a new issue