-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
135 lines (103 loc) · 4.23 KB
/
justfile
File metadata and controls
135 lines (103 loc) · 4.23 KB
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
repo_root := `pwd`
svn_dir := "./wp-org-svn"
svn_user := "staticwebio"
wordpress_dir := "./dev/data/wordpress1"
alias b := build
alias fmt := format
alias t := test
alias u := update
alias w := watch-dev
[private]
list:
@# First command in the file is invoked by default
@just --list
# Build plugin zip for GitHub release
build:
nix build .#plugin
# Build plugin zip for wordpress.org release
build-wp-org:
nix build .#pluginWpOrg
# Run tests and other checks
check: _check_no_test test
_check_no_test:
#!/usr/bin/env bash
out=$(nix build --print-out-paths ".#checks.$(nix eval --impure --raw --expr 'builtins.currentSystem').snapCacheCheck")
if [ -t 1 ]; then cat "$out/log"; else sed 's/\x1b\[[0-9;]*m//g' "$out/log"; fi
_check_no_test_raw: _lint _validate _phpcs
php ./vendor/bin/rector --debug --dry-run --ansi
# Run development server
[working-directory('dev')]
dev CLEAN="false" DEBUG="false":
{{ if CLEAN == "true" { "rm -rf data" } else { "" } }}
{{ if DEBUG == "true" { "ENABLE_XDEBUG=true nix run . --impure -- --no-server" } else { "nix run . -- --no-server" } }}
# Format source and then check for unfixable issues
format: && _format-php
just --fmt --unstable
fd -e json -x jsonfmt -w
fd -e nix -x nixfmt
_format-php:
just _phpcbf || true && just _phpcs
_lint:
php ./vendor/bin/parallel-lint --colors src
_phpcbf:
php ./vendor/bin/phpcbf -d memory_limit=512M --standard=./phpcs.xml --extensions=php src tests *.php || true
_phpcs:
php ./vendor/bin/phpcs -d memory_limit=512M -s --colors --standard=./phpcs.xml --extensions=php src tests *.php
# Run rector code transformations
rector: && _phpcbf
# We sometimes get errors running without --debug
php ./vendor/bin/rector --debug
# Checkout WordPress.org subversion repo
svn-checkout:
svn co https://plugins.svn.wordpress.org/snapcache "{{ svn_dir }}"
# Release latest source build using version in update.json
svn-release:
just _svn-sync-trunk "$(nix build .#pluginWpOrgSrc --print-out-paths)" "$(jq -r .version update.json)"
just _svn-release-version "$(jq -r .version update.json)"
_svn-release-version VERSION:
svn cp "{{ svn_dir }}"/trunk "{{ svn_dir }}"/tags/"{{ VERSION }}"
svn ci "{{ svn_dir }}"/tags/"{{ VERSION }}" --username "{{ svn_user }}" -m "tagging version {{ VERSION }}"
_svn-sync-trunk SRC VERSION:
rsync -avc --no-times --delete --chmod=F664,D775 --owner "{{ SRC }}"/* "{{ svn_dir }}"/trunk/
svn add --force "{{ svn_dir }}"/trunk/*
svn ci "{{ svn_dir }}"/trunk --username "{{ svn_user }}" -m "version {{ VERSION }}"
# Update subversion repo from WordPress.org
svn-update:
svn up "{{ svn_dir }}"
# Validate and run tests in a sandbox
test: _validate _phpcs _test-integration
# Run integration tests in a sandbox
_test-integration:
nix flake check ./dev
# Run integration tests against a live dev server
_test-integration-live:
WORDPRESS_DIR="$(realpath {{ wordpress_dir }})" php ./vendor/bin/phpunit --testsuite Integration
# Run tests against a live dev server
test-live: _test-integration-live
# Test against github:staticweb-io/wordpress-flake#prerelease
test-wordpress-prerelease:
#!/usr/bin/env bash
set -euo pipefail
rev=$(nix flake metadata ./dev --json 2>/dev/null | jq -r '.locks.nodes["wordpress-flake"].locked.rev')
version=$(nix eval "github:staticweb-io/wordpress-flake/$rev#prerelease.version" --raw 2>/dev/null)
echo "Testing WordPress prerelease version $version"
WORDPRESS_PACKAGE=prerelease nix flake check --impure ./dev
_update-composer-deps: && update-hashes
composer update
# Upgrade dependencies
update: _update-flakes _update-composer-deps
_update-flakes:
nix flake update
fd flake.nix -j 4 -x bash -c 'echo "Updating flake inputs in {//}"; cd "{//}" && nix flake update --inputs-from "$0"' "{{ repo_root }}"
# Update the vendorHash after a composer.json change
update-hashes:
./bin/update-hashes
# Update the update.json file with current values
update-json:
./bin/update-json
_validate:
composer validate --strict
_watch-dev-cmd: format _validate _test-integration
# Run formatters and dev server tests when files change
watch-dev:
@watchexec --exts json,nix,php --on-busy-update=queue --stdin-quit -- just _watch-dev-cmd