-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjustfile
More file actions
133 lines (101 loc) · 3.85 KB
/
justfile
File metadata and controls
133 lines (101 loc) · 3.85 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
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
nix flake lock
_check_no_test: _lint _validate _phpcs
php ./vendor/bin/rector --debug --dry-run
# Run development server
[working-directory('dev')]
dev CLEAN="false":
{{ if CLEAN == "true" { "rm -rf data" } else { "" } }}
nix run
# Format source and then check for unfixable issues
format: && _format-php
just --fmt --unstable
fd --glob "*.nix" -x nixfmt
_format-php:
just _phpcbf || true && just _phpcs
_lint:
php ./vendor/bin/parallel-lint src views
_phpcbf:
php ./vendor/bin/phpcbf -d memory_limit=512M --standard=./phpcs.xml --extensions=php src tests views *.php || true
_phpcs:
php ./vendor/bin/phpcs -d memory_limit=512M -s --standard=./phpcs.xml --extensions=php src tests views *.php
# Run rector code transformations
rector *args: && _phpcbf
# We sometimes get errors running without --debug
php ./vendor/bin/rector --debug {{ args }}
# Checkout WordPress.org subversion repo
svn-checkout:
svn co https://plugins.svn.wordpress.org/staticweb-deploy "{{ svn_dir }}"
# Release latest source build using version in update.json
svn-release:
just _svn-sync-trunk "$(nix build .#pluginWpOrgSrc --print-out-paths)"
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 }}" --username "{{ svn_user }}" -m "tagging version {{ VERSION }}"
_svn-sync-trunk SRC:
rsync -av --delete --chmod=F664,D775 --owner "{{ SRC }}"/* "{{ svn_dir }}"/trunk/
svn add --force "{{ svn_dir }}"/trunk/*
# Update subversion repo from WordPress.org
svn-update:
svn up "{{ svn_dir }}"
# Run tests in a sandbox
test: _test-integration
# Run AWS tests against a live dev server
_test-aws:
WORDPRESS_DIR="$(realpath {{ wordpress_dir }})" php ./vendor/bin/phpunit --testsuite AWS
# 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-aws
# 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: _lint 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