Skip to content

Commit 9813889

Browse files
thxCodeshanewxy
authored andcommitted
ci: refactor
- support tests directory - enable doc generation sorting Signed-off-by: thxCode <thxcode0824@gmail.com>
1 parent c0081d1 commit 9813889

File tree

8 files changed

+100
-52
lines changed

8 files changed

+100
-52
lines changed

.terraform-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ settings:
2424
type: true
2525

2626
sort:
27-
enabled: false
27+
enabled: true

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ help:
1818
# Usage:
1919
#
2020
# * [dev] `make generate`, generate README file.
21-
# - `make generate examples/standalone` only generate docs and schema under examples/standalone directory.
22-
# - `make generate docs examples/standalone` only generate README file under examples/standalone directory.
23-
# - `make generate schema examples/standalone` only generate schema.yaml under examples/standalone directory.
21+
# - `make generate examples/hello-world` only generate docs and schema under examples/hello-world directory.
22+
# - `make generate docs examples/hello-world` only generate README file under examples/hello-world directory.
23+
# - `make generate schema examples/hello-world` only generate schema.yaml under examples/hello-world directory.
2424
#
2525
# * [dev] `make lint`, check style and security.
2626
# - `LINT_DIRTY=true make lint` verify whether the code tree is dirty.
27-
# - `make lint examples/standalone` only verify the code under examples/standalone directory.
27+
# - `make lint examples/hello-world` only verify the code under examples/hello-world directory.
2828
#
2929
# * [dev] `make test`, execute unit testing.
30-
# - `make test example/standalone` only test the code under examples/standalone directory.
30+
# - `make test examples/hello-world` only test the code under examples/hello-world directory.
3131
#
3232
# * [ci] `make ci`, execute `make generate`, `make lint` and `make test`.
3333
#

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,29 @@ No modules.
7474

7575
| Name | Description | Type | Default | Required |
7676
|------|-------------|------|---------|:--------:|
77-
| <a name="input_context"></a> [context](#input\_context) | Receive contextual information. When Walrus deploys, Walrus will inject specific contextual information into this field.<br><br>Examples:<pre>context:<br> project:<br> name: string<br> id: string<br> environment:<br> name: string<br> id: string<br> resource:<br> name: string<br> id: string</pre> | `map(any)` | `{}` | no |
78-
| <a name="input_infrastructure"></a> [infrastructure](#input\_infrastructure) | Specify the infrastructure information for deploying.<br><br>Examples:<pre>infrastructure:<br> vpc_id: string # the ID of the VPC where the Redis service applies<br> kms_key_id: string, optional # the ID of the KMS key which to encrypt the Redis data<br> domain_suffix: string, optional # a private DNS namespace of the CloudMap where to register the applied Redis service</pre> | <pre>object({<br> vpc_id = string<br> kms_key_id = optional(string)<br> domain_suffix = optional(string)<br> })</pre> | n/a | yes |
7977
| <a name="input_architecture"></a> [architecture](#input\_architecture) | Specify the deployment architecture, select from standalone or replication. | `string` | `"standalone"` | no |
80-
| <a name="input_replication_readonly_replicas"></a> [replication\_readonly\_replicas](#input\_replication\_readonly\_replicas) | Specify the number of read-only replicas under the replication deployment. | `number` | `1` | no |
81-
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | Specify the deployment engine version. | `string` | `"7.0"` | no |
78+
| <a name="input_context"></a> [context](#input\_context) | Receive contextual information. When Walrus deploys, Walrus will inject specific contextual information into this field.<br><br>Examples:<pre>context:<br> project:<br> name: string<br> id: string<br> environment:<br> name: string<br> id: string<br> resource:<br> name: string<br> id: string</pre> | `map(any)` | `{}` | no |
8279
| <a name="input_engine_parameters"></a> [engine\_parameters](#input\_engine\_parameters) | Specify the deployment parameters, see https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/ParameterGroups.Redis.html. | <pre>list(object({<br> name = string<br> value = string<br> }))</pre> | `[]` | no |
80+
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | Specify the deployment engine version. | `string` | `"7.0"` | no |
81+
| <a name="input_infrastructure"></a> [infrastructure](#input\_infrastructure) | Specify the infrastructure information for deploying.<br><br>Examples:<pre>infrastructure:<br> vpc_id: string # the ID of the VPC where the Redis service applies<br> kms_key_id: string, optional # the ID of the KMS key which to encrypt the Redis data<br> domain_suffix: string, optional # a private DNS namespace of the CloudMap where to register the applied Redis service</pre> | <pre>object({<br> vpc_id = string<br> kms_key_id = optional(string)<br> domain_suffix = optional(string)<br> })</pre> | n/a | yes |
8382
| <a name="input_password"></a> [password](#input\_password) | Specify the account password. The password must be 16-32 characters long and start with any letter, number, or the following symbols: ! # $ % ^ & * ( ) \_ + - =.<br>If not specified, it will generate a random password. | `string` | `null` | no |
83+
| <a name="input_replication_readonly_replicas"></a> [replication\_readonly\_replicas](#input\_replication\_readonly\_replicas) | Specify the number of read-only replicas under the replication deployment. | `number` | `1` | no |
8484
| <a name="input_resources"></a> [resources](#input\_resources) | Specify the computing resources.<br>Examples:<pre>resources:<br> class: string, optional # https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/CacheNodes.SupportedTypes.html</pre> | <pre>object({<br> class = optional(string, "cache.t3.micro")<br> })</pre> | <pre>{<br> "class": "cache.t3.micro"<br>}</pre> | no |
8585

8686
## Outputs
8787

8888
| Name | Description |
8989
|------|-------------|
90-
| <a name="output_context"></a> [context](#output\_context) | The input context, a map, which is used for orchestration. |
91-
| <a name="output_refer"></a> [refer](#output\_refer) | The refer, a map, including hosts, ports and account, which is used for dependencies or collaborations. |
92-
| <a name="output_connection"></a> [connection](#output\_connection) | The connection, a string combined host and port, might be a comma separated string or a single string. |
93-
| <a name="output_connection_readonly"></a> [connection\_readonly](#output\_connection\_readonly) | The readonly connection, a string combined host and port, might be a comma separated string or a single string. |
9490
| <a name="output_address"></a> [address](#output\_address) | The address, a string only has host, might be a comma separated string or a single string. |
9591
| <a name="output_address_readonly"></a> [address\_readonly](#output\_address\_readonly) | The readonly address, a string only has host, might be a comma separated string or a single string. |
96-
| <a name="output_port"></a> [port](#output\_port) | The port of the service. |
97-
| <a name="output_password"></a> [password](#output\_password) | The password of the account to access the service. |
92+
| <a name="output_connection"></a> [connection](#output\_connection) | The connection, a string combined host and port, might be a comma separated string or a single string. |
93+
| <a name="output_connection_readonly"></a> [connection\_readonly](#output\_connection\_readonly) | The readonly connection, a string combined host and port, might be a comma separated string or a single string. |
94+
| <a name="output_context"></a> [context](#output\_context) | The input context, a map, which is used for orchestration. |
9895
| <a name="output_endpoints"></a> [endpoints](#output\_endpoints) | The endpoints, a list of string combined host and port. |
9996
| <a name="output_endpoints_readonly"></a> [endpoints\_readonly](#output\_endpoints\_readonly) | The readonly endpoints, a list of string combined host and port. |
97+
| <a name="output_password"></a> [password](#output\_password) | The password of the account to access the service. |
98+
| <a name="output_port"></a> [port](#output\_port) | The port of the service. |
99+
| <a name="output_refer"></a> [refer](#output\_refer) | The refer, a map, including hosts, ports and account, which is used for dependencies or collaborations. |
100100
<!-- END_TF_DOCS -->
101101

102102
## License

examples/replication/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ No inputs.
4949

5050
| Name | Description |
5151
|------|-------------|
52-
| <a name="output_context"></a> [context](#output\_context) | n/a |
53-
| <a name="output_refer"></a> [refer](#output\_refer) | n/a |
54-
| <a name="output_connection"></a> [connection](#output\_connection) | n/a |
55-
| <a name="output_connection_readonly"></a> [connection\_readonly](#output\_connection\_readonly) | n/a |
5652
| <a name="output_address"></a> [address](#output\_address) | n/a |
5753
| <a name="output_address_readonly"></a> [address\_readonly](#output\_address\_readonly) | n/a |
58-
| <a name="output_port"></a> [port](#output\_port) | n/a |
59-
| <a name="output_password"></a> [password](#output\_password) | n/a |
54+
| <a name="output_connection"></a> [connection](#output\_connection) | n/a |
55+
| <a name="output_connection_readonly"></a> [connection\_readonly](#output\_connection\_readonly) | n/a |
56+
| <a name="output_context"></a> [context](#output\_context) | n/a |
6057
| <a name="output_endpoints"></a> [endpoints](#output\_endpoints) | n/a |
6158
| <a name="output_endpoints_readonly"></a> [endpoints\_readonly](#output\_endpoints\_readonly) | n/a |
59+
| <a name="output_password"></a> [password](#output\_password) | n/a |
60+
| <a name="output_port"></a> [port](#output\_port) | n/a |
61+
| <a name="output_refer"></a> [refer](#output\_refer) | n/a |
6262
<!-- END_TF_DOCS -->

examples/standalone/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ No inputs.
5353

5454
| Name | Description |
5555
|------|-------------|
56-
| <a name="output_context"></a> [context](#output\_context) | n/a |
57-
| <a name="output_refer"></a> [refer](#output\_refer) | n/a |
58-
| <a name="output_connection"></a> [connection](#output\_connection) | n/a |
59-
| <a name="output_connection_readonly"></a> [connection\_readonly](#output\_connection\_readonly) | n/a |
6056
| <a name="output_address"></a> [address](#output\_address) | n/a |
6157
| <a name="output_address_readonly"></a> [address\_readonly](#output\_address\_readonly) | n/a |
62-
| <a name="output_port"></a> [port](#output\_port) | n/a |
63-
| <a name="output_password"></a> [password](#output\_password) | n/a |
58+
| <a name="output_connection"></a> [connection](#output\_connection) | n/a |
59+
| <a name="output_connection_readonly"></a> [connection\_readonly](#output\_connection\_readonly) | n/a |
60+
| <a name="output_context"></a> [context](#output\_context) | n/a |
6461
| <a name="output_endpoints"></a> [endpoints](#output\_endpoints) | n/a |
6562
| <a name="output_endpoints_readonly"></a> [endpoints\_readonly](#output\_endpoints\_readonly) | n/a |
63+
| <a name="output_password"></a> [password](#output\_password) | n/a |
64+
| <a name="output_port"></a> [port](#output\_port) | n/a |
65+
| <a name="output_refer"></a> [refer](#output\_refer) | n/a |
6666
<!-- END_TF_DOCS -->

hack/generate.sh

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,15 @@ function generate_doc() {
4747
fi
4848

4949
seal::terraform::docs "${target}" --config="${target}/.terraform-docs.yml" --recursive
50-
local examples=()
51-
# shellcheck disable=SC2086
52-
IFS=" " read -r -a examples <<<"$(seal::util::find_subdirs ${target}/examples)"
53-
for example in "${examples[@]}"; do
54-
seal::terraform::docs "${target}/examples/${example}" --config="${target}/.terraform-docs.yml"
55-
done
50+
51+
if [[ -d "${target}/examples" ]]; then
52+
local examples=()
53+
# shellcheck disable=SC2086
54+
IFS=" " read -r -a examples <<<"$(seal::util::find_subdirs ${target}/examples)"
55+
for example in "${examples[@]}"; do
56+
seal::terraform::docs "${target}/examples/${example}" --config="${target}/.terraform-docs.yml"
57+
done
58+
fi
5659
}
5760

5861
function generate_schema() {
@@ -76,12 +79,15 @@ function generate_schema() {
7679
fi
7780

7881
seal::walrus_cli::schema "${target}"
79-
local sub_modules=()
80-
# shellcheck disable=SC2086
81-
IFS=" " read -r -a sub_modules <<<"$(seal::util::find_subdirs ${target}/modules)"
82-
for module in "${sub_modules[@]}"; do
83-
seal::walrus_cli::schema "${target}/modules/${module}"
84-
done
82+
83+
if [[ -d "${target}/modules" ]]; then
84+
local modules=()
85+
# shellcheck disable=SC2086
86+
IFS=" " read -r -a modules <<<"$(seal::util::find_subdirs ${target}/modules)"
87+
for module in "${modules[@]}"; do
88+
seal::walrus_cli::schema "${target}/modules/${module}"
89+
done
90+
fi
8591
}
8692

8793
#

hack/lint.sh

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,33 @@ function lint() {
4343
seal::terraform::format "${target}" -recursive
4444

4545
seal::terraform::validate "${target}"
46-
local examples=()
47-
# shellcheck disable=SC2086
48-
IFS=" " read -r -a examples <<<"$(seal::util::find_subdirs ${target}/examples)"
49-
for example in "${examples[@]}"; do
50-
seal::terraform::validate "${target}/examples/${example}"
51-
done
46+
47+
if [[ -d "${target}/examples" ]]; then
48+
local examples=()
49+
# shellcheck disable=SC2086
50+
IFS=" " read -r -a examples <<<"$(seal::util::find_subdirs ${target}/examples)"
51+
for example in "${examples[@]}"; do
52+
seal::terraform::validate "${target}/examples/${example}"
53+
done
54+
fi
55+
56+
if [[ -d "${target}/modules" ]]; then
57+
local modules=()
58+
# shellcheck disable=SC2086
59+
IFS=" " read -r -a modules <<<"$(seal::util::find_subdirs ${target}/modules)"
60+
for module in "${modules[@]}"; do
61+
seal::terraform::validate "${target}/modules/${module}"
62+
done
63+
fi
64+
65+
if [[ -d "${target}/tests" ]]; then
66+
local tests=()
67+
# shellcheck disable=SC2086
68+
IFS=" " read -r -a tests <<<"$(seal::util::find_subdirs ${target}/tests)"
69+
for test in "${tests[@]}"; do
70+
seal::terraform::validate "${target}/tests/${test}"
71+
done
72+
fi
5273

5374
seal::terraform::lint "${target}" --recursive
5475

hack/test.sh

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,33 @@ function test() {
3131
fi
3232

3333
seal::terraform::test "${target}"
34-
local examples=()
35-
# shellcheck disable=SC2086
36-
IFS=" " read -r -a examples <<<"$(seal::util::find_subdirs ${target}/examples)"
37-
for example in "${examples[@]}"; do
38-
seal::terraform::test "${target}/examples/${example}"
39-
done
34+
35+
if [[ -d "${target}/examples" ]]; then
36+
local examples=()
37+
# shellcheck disable=SC2086
38+
IFS=" " read -r -a examples <<<"$(seal::util::find_subdirs ${target}/examples)"
39+
for example in "${examples[@]}"; do
40+
seal::terraform::test "${target}/examples/${example}"
41+
done
42+
fi
43+
44+
if [[ -d "${target}/modules" ]]; then
45+
local modules=()
46+
# shellcheck disable=SC2086
47+
IFS=" " read -r -a examples <<<"$(seal::util::find_subdirs ${target}/modules)"
48+
for module in "${modules[@]}"; do
49+
seal::terraform::test "${target}/modules/${module}"
50+
done
51+
fi
52+
53+
if [[ -d "${target}/tests" ]]; then
54+
local tests=()
55+
# shellcheck disable=SC2086
56+
IFS=" " read -r -a tests <<<"$(seal::util::find_subdirs ${target}/tests)"
57+
for test in "${tests[@]}"; do
58+
seal::terraform::test "${target}/tests/${test}"
59+
done
60+
fi
4061
}
4162

4263
#

0 commit comments

Comments
 (0)