Skip to content

Commit 61abe92

Browse files
Added Makefile support. (#156)
Co-authored-by: Alex Skrypnyk <alex@drevops.com>
1 parent 0f3ae7b commit 61abe92

File tree

8 files changed

+414
-58
lines changed

8 files changed

+414
-58
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ indent_size = 2
2727

2828
[*.xml]
2929
indent_size = 4
30+
31+
[Makefile*]
32+
indent_style = tab

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# .github export-ignore
1010
# .gitignore export-ignore
1111
# .twig-cs-fixer.php export-ignore
12+
# Makefile export-ignore
1213
# composer.dev.json export-ignore
1314
# phpcs.xml export-ignore
1415
# phpmd.xml export-ignore

.scaffold/tests/bats/_assert_init.bash

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ assert_files_present_common() {
1010
pushd "${dir}" >/dev/null || exit 1
1111

1212
# Assert that some files must exist.
13-
assert_file_exists ".ahoy.yml"
1413
assert_file_exists ".editorconfig"
1514
assert_file_exists ".gitattributes"
1615
assert_file_exists ".gitignore"
@@ -115,25 +114,73 @@ assert_files_present_extension_type_theme() {
115114
popd >/dev/null || exit 1
116115
}
117116

118-
assert_workflow() {
117+
assert_ci_provider_circleci() {
118+
local dir="${1:-$(pwd)}"
119+
pushd "${dir}" >/dev/null || exit 1
120+
121+
assert_file_exists ".circleci/config.yml"
122+
123+
popd >/dev/null || exit 1
124+
}
125+
126+
assert_ci_provider_gha() {
127+
local dir="${1:-$(pwd)}"
128+
pushd "${dir}" >/dev/null || exit 1
129+
130+
assert_file_not_exists ".circleci/config.yml"
131+
132+
popd >/dev/null || exit 1
133+
}
134+
135+
assert_command_wrapper_ahoy() {
136+
local dir="${1:-$(pwd)}"
137+
pushd "${dir}" >/dev/null || exit 1
138+
139+
assert_file_exists ".ahoy.yml"
140+
assert_file_not_exists "Makefile"
141+
142+
popd >/dev/null || exit 1
143+
}
144+
145+
assert_command_wrapper_makefile() {
146+
local dir="${1:-$(pwd)}"
147+
pushd "${dir}" >/dev/null || exit 1
148+
149+
assert_file_not_exists ".ahoy.yml"
150+
assert_file_exists "Makefile"
151+
152+
popd >/dev/null || exit 1
153+
}
154+
155+
assert_command_wrapper_none() {
156+
local dir="${1:-$(pwd)}"
157+
pushd "${dir}" >/dev/null || exit 1
158+
159+
assert_file_not_exists ".ahoy.yml"
160+
assert_file_not_exists "Makefile"
161+
162+
popd >/dev/null || exit 1
163+
}
164+
165+
assert_workflow_run() {
119166
local dir="${1:-$(pwd)}"
120167

121168
pushd "${dir}" >/dev/null || exit 1
122169

123-
# Very basic workflow.
124170
./.devtools/assemble.sh
125171
./.devtools/start.sh
126172
./.devtools/provision.sh
127173

128174
pushd "build" >/dev/null || exit 1
129-
# Lint.
175+
130176
vendor/bin/phpcs
131177
vendor/bin/phpstan
132178
vendor/bin/rector --clear-cache --dry-run
133179
vendor/bin/phpmd . text phpmd.xml
134180
vendor/bin/twig-cs-fixer
135-
# Test.
181+
136182
vendor/bin/phpunit
183+
137184
popd >/dev/null || exit 1
138185

139186
popd >/dev/null || exit 1

.scaffold/tests/bats/ahoy.bats

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ load _helper
44

55
export BATS_FIXTURE_EXPORT_CODEBASE_ENABLED=1
66

7+
@test "ahoy build" {
8+
run ahoy build
9+
assert_success
10+
assert_output_contains "PROVISION COMPLETE"
11+
}
12+
713
@test "ahoy assemble" {
814
run ahoy assemble
915
assert_success
@@ -17,6 +23,7 @@ export BATS_FIXTURE_EXPORT_CODEBASE_ENABLED=1
1723
@test "ahoy start" {
1824
run ahoy start
1925
assert_failure
26+
assert_output_not_contains "ENVIRONMENT READY"
2027

2128
ahoy assemble
2229
run ahoy start
@@ -35,27 +42,9 @@ export BATS_FIXTURE_EXPORT_CODEBASE_ENABLED=1
3542

3643
run ahoy stop
3744
assert_success
38-
3945
assert_output_contains "ENVIRONMENT STOPPED"
4046
}
4147

42-
@test "ahoy lint, lint-fix" {
43-
ahoy assemble
44-
assert_success
45-
46-
ahoy lint
47-
assert_success
48-
49-
# shellcheck disable=SC2016
50-
echo '$a=123;echo $a;' >>your_extension.module
51-
run ahoy lint
52-
assert_failure
53-
54-
run ahoy lint-fix
55-
run ahoy lint
56-
assert_success
57-
}
58-
5948
@test "ahoy build - basic workflow" {
6049
run ahoy build
6150
assert_success
@@ -86,6 +75,23 @@ export BATS_FIXTURE_EXPORT_CODEBASE_ENABLED=1
8675
assert_success
8776
}
8877

78+
@test "ahoy lint, lint-fix" {
79+
ahoy assemble
80+
assert_success
81+
82+
ahoy lint
83+
assert_success
84+
85+
# shellcheck disable=SC2016
86+
echo '$a=123;echo $a;' >>your_extension.module
87+
run ahoy lint
88+
assert_failure
89+
90+
run ahoy lint-fix
91+
run ahoy lint
92+
assert_success
93+
}
94+
8995
@test "ahoy test unit failure" {
9096
run ahoy assemble
9197
assert_success

.scaffold/tests/bats/functional.init.bats

Lines changed: 73 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,95 @@ export SCRIPT_FILE="init.sh"
1616
# bats test_tags=smoke
1717
@test "Init, defaults - extension module, workflow" {
1818
answers=(
19-
"Force Crystal" # name
20-
"force_crystal" # machine_name
21-
"module" # type
22-
"GitHub Actions" # ci_provider
23-
"nothing" # remove init script
24-
"nothing" # proceed with init
19+
"Force Crystal" # name
20+
"force_crystal" # machine_name
21+
"module" # type
22+
"gha" # ci_provider
23+
"nothing" # remove init script
24+
"nothing" # command_wrapper
25+
"nothing" # proceed with init
2526
)
2627
tui_run "${answers[@]}"
2728

2829
assert_output_contains "Please follow the prompts to adjust your extension configuration"
2930
assert_files_present_common "${BUILD_DIR}"
3031
assert_files_present_extension_type_module "${BUILD_DIR}"
31-
assert_file_not_exists ".circleci/config.yml"
32+
assert_ci_provider_gha "${BUILD_DIR}"
33+
assert_command_wrapper_ahoy "${BUILD_DIR}"
3234
assert_output_contains "Initialization complete."
3335

34-
assert_workflow "${BUILD_DIR}"
36+
assert_workflow_run "${BUILD_DIR}"
3537
}
3638

37-
# bats test_tags=smoke
3839
@test "Init, extension theme, workflow" {
3940
answers=(
40-
"Force Crystal" # name
41-
"force_crystal" # machine_name
42-
"theme" # type
43-
"GitHub Actions" # ci_provider
44-
"nothing" # remove init script
45-
"nothing" # proceed with init
41+
"Force Crystal" # name
42+
"force_crystal" # machine_name
43+
"theme" # type
44+
"gha" # ci_provider
45+
"nothing" # command_wrapper
46+
"nothing" # remove init script
47+
"nothing" # proceed with init
4648
)
4749
tui_run "${answers[@]}"
4850

4951
assert_output_contains "Please follow the prompts to adjust your extension configuration"
5052
assert_files_present_common "${BUILD_DIR}"
5153
assert_files_present_extension_type_theme "${BUILD_DIR}"
52-
assert_file_not_exists ".circleci/config.yml"
54+
assert_ci_provider_gha "${BUILD_DIR}"
55+
assert_command_wrapper_ahoy "${BUILD_DIR}"
5356
assert_output_contains "Initialization complete."
5457

55-
assert_workflow "${BUILD_DIR}"
58+
assert_workflow_run "${BUILD_DIR}"
5659
}
5760

58-
# bats test_tags=smoke
59-
@test "Init, CircleCI" {
61+
@test "Init, circleci" {
62+
answers=(
63+
"Force Crystal" # name
64+
"force_crystal" # machine_name
65+
"module" # type
66+
"circleci" # ci_provider
67+
"nothing" # command_wrapper
68+
"nothing" # remove init script
69+
"nothing" # proceed with init
70+
)
71+
tui_run "${answers[@]}"
72+
73+
assert_output_contains "Please follow the prompts to adjust your extension configuration"
74+
assert_files_present_common "${BUILD_DIR}"
75+
assert_files_present_extension_type_module "${BUILD_DIR}"
76+
assert_ci_provider_circleci "${BUILD_DIR}"
77+
assert_command_wrapper_ahoy "${BUILD_DIR}"
78+
assert_output_contains "Initialization complete."
79+
}
80+
81+
@test "Init, Makefile" {
82+
answers=(
83+
"Force Crystal" # name
84+
"force_crystal" # machine_name
85+
"module" # type
86+
"circleci" # ci_provider
87+
"makefile" # command_wrapper
88+
"nothing" # remove init script
89+
"nothing" # proceed with init
90+
)
91+
tui_run "${answers[@]}"
92+
93+
assert_output_contains "Please follow the prompts to adjust your extension configuration"
94+
assert_files_present_common "${BUILD_DIR}"
95+
assert_files_present_extension_type_module "${BUILD_DIR}"
96+
assert_ci_provider_circleci "${BUILD_DIR}"
97+
assert_command_wrapper_makefile "${BUILD_DIR}"
98+
assert_output_contains "Initialization complete."
99+
}
100+
101+
@test "Init, no command wrapper" {
60102
answers=(
61103
"Force Crystal" # name
62104
"force_crystal" # machine_name
63105
"module" # type
64-
"CircleCI" # ci_provider
106+
"circleci" # ci_provider
107+
"none" # command_wrapper
65108
"nothing" # remove init script
66109
"nothing" # proceed with init
67110
)
@@ -70,8 +113,8 @@ export SCRIPT_FILE="init.sh"
70113
assert_output_contains "Please follow the prompts to adjust your extension configuration"
71114
assert_files_present_common "${BUILD_DIR}"
72115
assert_files_present_extension_type_module "${BUILD_DIR}"
73-
assert_file_exists ".circleci/config.yml"
74-
assert_dir_not_exists ".github/workflows"
116+
assert_ci_provider_circleci "${BUILD_DIR}"
117+
assert_command_wrapper_none "${BUILD_DIR}"
75118
assert_output_contains "Initialization complete."
76119
}
77120

@@ -80,7 +123,8 @@ export SCRIPT_FILE="init.sh"
80123
"Force Crystal" # name
81124
"force_crystal" # machine_name
82125
"module" # type
83-
"CircleCI" # ci_provider
126+
"gha" # ci_provider
127+
"nothing" # command_wrapper
84128
"n" # remove init script
85129
"nothing" # proceed with init
86130
)
@@ -89,6 +133,8 @@ export SCRIPT_FILE="init.sh"
89133
assert_output_contains "Please follow the prompts to adjust your extension configuration"
90134
assert_files_present_common "${BUILD_DIR}"
91135
assert_files_present_extension_type_module "${BUILD_DIR}"
136+
assert_ci_provider_gha "${BUILD_DIR}"
137+
assert_command_wrapper_ahoy "${BUILD_DIR}"
92138
assert_file_exists "init.sh"
93139
assert_output_contains "Initialization complete."
94140
}
@@ -98,7 +144,8 @@ export SCRIPT_FILE="init.sh"
98144
"Force Crystal" # name
99145
"force_crystal" # machine_name
100146
"module" # type
101-
"CircleCI" # ci_provider
147+
"gha" # ci_provider
148+
"nothing" # command_wrapper
102149
"y" # remove init script
103150
"nothing" # proceed with init
104151
)
@@ -107,6 +154,8 @@ export SCRIPT_FILE="init.sh"
107154
assert_output_contains "Please follow the prompts to adjust your extension configuration"
108155
assert_files_present_common "${BUILD_DIR}"
109156
assert_files_present_extension_type_module "${BUILD_DIR}"
157+
assert_ci_provider_gha "${BUILD_DIR}"
158+
assert_command_wrapper_ahoy "${BUILD_DIR}"
110159
assert_file_not_exists "init.sh"
111160
assert_output_contains "Initialization complete."
112161
}

0 commit comments

Comments
 (0)