@owenlamont/ryl 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CODEOWNERS +1 -0
- package/.github/dependabot.yml +13 -0
- package/.github/workflows/ci.yml +107 -0
- package/.github/workflows/release.yml +613 -0
- package/.github/workflows/update_dependencies.yml +61 -0
- package/.github/workflows/update_linters.yml +56 -0
- package/.pre-commit-config.yaml +87 -0
- package/.yamllint +4 -0
- package/AGENTS.md +200 -0
- package/Cargo.lock +908 -0
- package/Cargo.toml +32 -0
- package/LICENSE +21 -0
- package/README.md +230 -0
- package/bin/ryl.js +1 -0
- package/clippy.toml +1 -0
- package/docs/config-presets.md +100 -0
- package/img/benchmark-5x5-5runs.svg +2176 -0
- package/package.json +28 -0
- package/pyproject.toml +42 -0
- package/ruff.toml +107 -0
- package/rumdl.toml +20 -0
- package/rust-toolchain.toml +3 -0
- package/rustfmt.toml +3 -0
- package/scripts/benchmark_perf_vs_yamllint.py +400 -0
- package/scripts/coverage-missing.ps1 +80 -0
- package/scripts/coverage-missing.sh +60 -0
- package/src/bin/discover_config_bin.rs +24 -0
- package/src/cli_support.rs +33 -0
- package/src/conf/mod.rs +85 -0
- package/src/config.rs +2099 -0
- package/src/decoder.rs +326 -0
- package/src/discover.rs +31 -0
- package/src/lib.rs +19 -0
- package/src/lint.rs +558 -0
- package/src/main.rs +535 -0
- package/src/migrate.rs +233 -0
- package/src/rules/anchors.rs +517 -0
- package/src/rules/braces.rs +77 -0
- package/src/rules/brackets.rs +77 -0
- package/src/rules/colons.rs +475 -0
- package/src/rules/commas.rs +372 -0
- package/src/rules/comments.rs +299 -0
- package/src/rules/comments_indentation.rs +243 -0
- package/src/rules/document_end.rs +175 -0
- package/src/rules/document_start.rs +84 -0
- package/src/rules/empty_lines.rs +152 -0
- package/src/rules/empty_values.rs +255 -0
- package/src/rules/float_values.rs +259 -0
- package/src/rules/flow_collection.rs +562 -0
- package/src/rules/hyphens.rs +104 -0
- package/src/rules/indentation.rs +803 -0
- package/src/rules/key_duplicates.rs +218 -0
- package/src/rules/key_ordering.rs +303 -0
- package/src/rules/line_length.rs +326 -0
- package/src/rules/mod.rs +25 -0
- package/src/rules/new_line_at_end_of_file.rs +23 -0
- package/src/rules/new_lines.rs +95 -0
- package/src/rules/octal_values.rs +121 -0
- package/src/rules/quoted_strings.rs +577 -0
- package/src/rules/span_utils.rs +37 -0
- package/src/rules/trailing_spaces.rs +65 -0
- package/src/rules/truthy.rs +420 -0
- package/tests/brackets_carriage_return.rs +114 -0
- package/tests/build_global_cfg_error.rs +23 -0
- package/tests/cli_anchors_rule.rs +143 -0
- package/tests/cli_braces_rule.rs +104 -0
- package/tests/cli_brackets_rule.rs +104 -0
- package/tests/cli_colons_rule.rs +65 -0
- package/tests/cli_commas_rule.rs +104 -0
- package/tests/cli_comments_indentation_rule.rs +61 -0
- package/tests/cli_comments_rule.rs +67 -0
- package/tests/cli_config_data_error.rs +30 -0
- package/tests/cli_config_flags.rs +66 -0
- package/tests/cli_config_migrate.rs +229 -0
- package/tests/cli_document_end_rule.rs +92 -0
- package/tests/cli_document_start_rule.rs +92 -0
- package/tests/cli_empty_lines_rule.rs +87 -0
- package/tests/cli_empty_values_rule.rs +68 -0
- package/tests/cli_env_config.rs +34 -0
- package/tests/cli_exit_and_errors.rs +41 -0
- package/tests/cli_file_encoding.rs +203 -0
- package/tests/cli_float_values_rule.rs +64 -0
- package/tests/cli_format_options.rs +316 -0
- package/tests/cli_global_cfg_relaxed.rs +20 -0
- package/tests/cli_hyphens_rule.rs +104 -0
- package/tests/cli_indentation_rule.rs +65 -0
- package/tests/cli_invalid_project_config.rs +39 -0
- package/tests/cli_key_duplicates_rule.rs +104 -0
- package/tests/cli_key_ordering_rule.rs +59 -0
- package/tests/cli_line_length_rule.rs +85 -0
- package/tests/cli_list_files.rs +29 -0
- package/tests/cli_new_line_rule.rs +141 -0
- package/tests/cli_new_lines_rule.rs +119 -0
- package/tests/cli_octal_values_rule.rs +60 -0
- package/tests/cli_quoted_strings_rule.rs +47 -0
- package/tests/cli_toml_config.rs +119 -0
- package/tests/cli_trailing_spaces_rule.rs +77 -0
- package/tests/cli_truthy_rule.rs +83 -0
- package/tests/cli_yaml_files_negation.rs +45 -0
- package/tests/colons_rule.rs +303 -0
- package/tests/common/compat.rs +114 -0
- package/tests/common/fake_env.rs +93 -0
- package/tests/common/mod.rs +1 -0
- package/tests/conf_builtin.rs +9 -0
- package/tests/config_anchors.rs +84 -0
- package/tests/config_braces.rs +121 -0
- package/tests/config_brackets.rs +127 -0
- package/tests/config_commas.rs +79 -0
- package/tests/config_comments.rs +65 -0
- package/tests/config_comments_indentation.rs +20 -0
- package/tests/config_deep_merge_nonstring_key.rs +24 -0
- package/tests/config_document_end.rs +54 -0
- package/tests/config_document_start.rs +55 -0
- package/tests/config_empty_lines.rs +48 -0
- package/tests/config_empty_values.rs +35 -0
- package/tests/config_env_errors.rs +23 -0
- package/tests/config_env_invalid_inline.rs +15 -0
- package/tests/config_env_missing.rs +63 -0
- package/tests/config_env_shim.rs +301 -0
- package/tests/config_explicit_file_parse_error.rs +55 -0
- package/tests/config_extended_features.rs +225 -0
- package/tests/config_extends_inline.rs +185 -0
- package/tests/config_extends_sequence.rs +18 -0
- package/tests/config_find_project_home_boundary.rs +54 -0
- package/tests/config_find_project_two_files_in_cwd.rs +47 -0
- package/tests/config_float_values.rs +34 -0
- package/tests/config_from_yaml_paths.rs +32 -0
- package/tests/config_hyphens.rs +51 -0
- package/tests/config_ignore_errors.rs +243 -0
- package/tests/config_ignore_overrides.rs +83 -0
- package/tests/config_indentation.rs +65 -0
- package/tests/config_invalid_globs.rs +16 -0
- package/tests/config_invalid_types.rs +19 -0
- package/tests/config_key_duplicates.rs +34 -0
- package/tests/config_key_ordering.rs +70 -0
- package/tests/config_line_length.rs +65 -0
- package/tests/config_locale.rs +111 -0
- package/tests/config_merge.rs +26 -0
- package/tests/config_new_lines.rs +89 -0
- package/tests/config_octal_values.rs +33 -0
- package/tests/config_quoted_strings.rs +195 -0
- package/tests/config_rule_level.rs +147 -0
- package/tests/config_rules_non_string_keys.rs +23 -0
- package/tests/config_scalar_overrides.rs +27 -0
- package/tests/config_to_toml.rs +110 -0
- package/tests/config_toml_coverage.rs +80 -0
- package/tests/config_toml_discovery.rs +304 -0
- package/tests/config_trailing_spaces.rs +152 -0
- package/tests/config_truthy.rs +77 -0
- package/tests/config_yaml_files.rs +62 -0
- package/tests/config_yaml_files_all_non_string.rs +15 -0
- package/tests/config_yaml_files_empty.rs +30 -0
- package/tests/coverage_commas.rs +46 -0
- package/tests/decoder_decode.rs +338 -0
- package/tests/discover_config_bin_all.rs +66 -0
- package/tests/discover_config_bin_env_invalid_yaml.rs +26 -0
- package/tests/discover_config_bin_project_config_parse_error.rs +24 -0
- package/tests/discover_config_bin_user_global_error.rs +26 -0
- package/tests/discover_module.rs +30 -0
- package/tests/discover_per_file_dir.rs +10 -0
- package/tests/discover_per_file_project_config_error.rs +21 -0
- package/tests/float_values.rs +43 -0
- package/tests/lint_multi_errors.rs +32 -0
- package/tests/main_yaml_ok_filtering.rs +30 -0
- package/tests/migrate_module.rs +259 -0
- package/tests/resolve_ctx_empty_parent.rs +16 -0
- package/tests/rule_anchors.rs +442 -0
- package/tests/rule_braces.rs +258 -0
- package/tests/rule_brackets.rs +217 -0
- package/tests/rule_commas.rs +205 -0
- package/tests/rule_comments.rs +197 -0
- package/tests/rule_comments_indentation.rs +127 -0
- package/tests/rule_document_end.rs +118 -0
- package/tests/rule_document_start.rs +60 -0
- package/tests/rule_empty_lines.rs +96 -0
- package/tests/rule_empty_values.rs +102 -0
- package/tests/rule_float_values.rs +109 -0
- package/tests/rule_hyphens.rs +65 -0
- package/tests/rule_indentation.rs +455 -0
- package/tests/rule_key_duplicates.rs +76 -0
- package/tests/rule_key_ordering.rs +207 -0
- package/tests/rule_line_length.rs +200 -0
- package/tests/rule_new_lines.rs +51 -0
- package/tests/rule_octal_values.rs +53 -0
- package/tests/rule_quoted_strings.rs +290 -0
- package/tests/rule_trailing_spaces.rs +41 -0
- package/tests/rule_truthy.rs +236 -0
- package/tests/user_global_invalid_yaml.rs +32 -0
- package/tests/yamllint_compat_anchors.rs +280 -0
- package/tests/yamllint_compat_braces.rs +411 -0
- package/tests/yamllint_compat_brackets.rs +364 -0
- package/tests/yamllint_compat_colons.rs +298 -0
- package/tests/yamllint_compat_colors.rs +80 -0
- package/tests/yamllint_compat_commas.rs +375 -0
- package/tests/yamllint_compat_comments.rs +167 -0
- package/tests/yamllint_compat_comments_indentation.rs +281 -0
- package/tests/yamllint_compat_config.rs +170 -0
- package/tests/yamllint_compat_document_end.rs +243 -0
- package/tests/yamllint_compat_document_start.rs +136 -0
- package/tests/yamllint_compat_empty_lines.rs +117 -0
- package/tests/yamllint_compat_empty_values.rs +179 -0
- package/tests/yamllint_compat_float_values.rs +216 -0
- package/tests/yamllint_compat_hyphens.rs +223 -0
- package/tests/yamllint_compat_indentation.rs +398 -0
- package/tests/yamllint_compat_key_duplicates.rs +139 -0
- package/tests/yamllint_compat_key_ordering.rs +170 -0
- package/tests/yamllint_compat_line_length.rs +375 -0
- package/tests/yamllint_compat_list.rs +127 -0
- package/tests/yamllint_compat_new_line.rs +133 -0
- package/tests/yamllint_compat_newline_types.rs +185 -0
- package/tests/yamllint_compat_octal_values.rs +172 -0
- package/tests/yamllint_compat_quoted_strings.rs +154 -0
- package/tests/yamllint_compat_syntax.rs +200 -0
- package/tests/yamllint_compat_trailing_spaces.rs +162 -0
- package/tests/yamllint_compat_truthy.rs +130 -0
- package/tests/yamllint_compat_yaml_files.rs +81 -0
- package/typos.toml +2 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
use std::fs;
|
|
2
|
+
|
|
3
|
+
use tempfile::tempdir;
|
|
4
|
+
|
|
5
|
+
#[path = "common/compat.rs"]
|
|
6
|
+
mod compat;
|
|
7
|
+
|
|
8
|
+
use compat::{
|
|
9
|
+
SCENARIOS, build_ryl_command, build_yamllint_command, capture_with_env,
|
|
10
|
+
ensure_yamllint_installed,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
#[test]
|
|
14
|
+
fn anchors_rule_matches_yamllint() {
|
|
15
|
+
ensure_yamllint_installed();
|
|
16
|
+
|
|
17
|
+
let dir = tempdir().unwrap();
|
|
18
|
+
|
|
19
|
+
let default_cfg = dir.path().join("anchors-default.yml");
|
|
20
|
+
fs::write(
|
|
21
|
+
&default_cfg,
|
|
22
|
+
"rules:\n document-start: disable\n anchors: enable\n",
|
|
23
|
+
)
|
|
24
|
+
.unwrap();
|
|
25
|
+
|
|
26
|
+
let allow_forward_cfg = dir.path().join("anchors-allow-forward.yml");
|
|
27
|
+
fs::write(
|
|
28
|
+
&allow_forward_cfg,
|
|
29
|
+
"rules:\n document-start: disable\n anchors:\n forbid-undeclared-aliases: false\n",
|
|
30
|
+
)
|
|
31
|
+
.unwrap();
|
|
32
|
+
|
|
33
|
+
let duplicates_cfg = dir.path().join("anchors-duplicates.yml");
|
|
34
|
+
fs::write(
|
|
35
|
+
&duplicates_cfg,
|
|
36
|
+
"rules:\n document-start: disable\n anchors:\n forbid-undeclared-aliases: false\n forbid-duplicated-anchors: true\n",
|
|
37
|
+
)
|
|
38
|
+
.unwrap();
|
|
39
|
+
|
|
40
|
+
let unused_cfg = dir.path().join("anchors-unused.yml");
|
|
41
|
+
fs::write(
|
|
42
|
+
&unused_cfg,
|
|
43
|
+
"rules:\n document-start: disable\n anchors:\n forbid-unused-anchors: true\n",
|
|
44
|
+
)
|
|
45
|
+
.unwrap();
|
|
46
|
+
|
|
47
|
+
let valid_file = dir.path().join("valid.yaml");
|
|
48
|
+
fs::write(&valid_file, "---\n- &anchor value\n- *anchor\n").unwrap();
|
|
49
|
+
|
|
50
|
+
let undeclared_file = dir.path().join("undeclared.yaml");
|
|
51
|
+
fs::write(&undeclared_file, "---\n- *missing\n- &missing value\n").unwrap();
|
|
52
|
+
|
|
53
|
+
let duplicate_file = dir.path().join("duplicate.yaml");
|
|
54
|
+
fs::write(&duplicate_file, "---\n- &anchor one\n- &anchor two\n").unwrap();
|
|
55
|
+
|
|
56
|
+
let unused_file = dir.path().join("unused.yaml");
|
|
57
|
+
fs::write(&unused_file, "---\n- &anchor value\n- 1\n").unwrap();
|
|
58
|
+
|
|
59
|
+
let regex_file = dir.path().join("regex.yaml");
|
|
60
|
+
fs::write(
|
|
61
|
+
®ex_file,
|
|
62
|
+
"repos:\n - repo: local\n hooks:\n - id: shellcheck\n files: ^scripts/.*\\.sh$\n",
|
|
63
|
+
)
|
|
64
|
+
.unwrap();
|
|
65
|
+
|
|
66
|
+
let exe = env!("CARGO_BIN_EXE_ryl");
|
|
67
|
+
|
|
68
|
+
for scenario in SCENARIOS {
|
|
69
|
+
// Default config: undeclared alias should fail
|
|
70
|
+
let mut ryl_default = build_ryl_command(exe, scenario.ryl_format);
|
|
71
|
+
ryl_default
|
|
72
|
+
.arg("-c")
|
|
73
|
+
.arg(&default_cfg)
|
|
74
|
+
.arg(&undeclared_file);
|
|
75
|
+
let (ryl_default_code, ryl_default_output) =
|
|
76
|
+
capture_with_env(ryl_default, scenario.envs);
|
|
77
|
+
|
|
78
|
+
let mut yam_default = build_yamllint_command(scenario.yam_format);
|
|
79
|
+
yam_default
|
|
80
|
+
.arg("-c")
|
|
81
|
+
.arg(&default_cfg)
|
|
82
|
+
.arg(&undeclared_file);
|
|
83
|
+
let (yam_default_code, yam_default_output) =
|
|
84
|
+
capture_with_env(yam_default, scenario.envs);
|
|
85
|
+
|
|
86
|
+
assert_eq!(
|
|
87
|
+
ryl_default_code, 1,
|
|
88
|
+
"ryl undeclared exit ({})",
|
|
89
|
+
scenario.label
|
|
90
|
+
);
|
|
91
|
+
assert_eq!(
|
|
92
|
+
yam_default_code, 1,
|
|
93
|
+
"yamllint undeclared exit ({})",
|
|
94
|
+
scenario.label
|
|
95
|
+
);
|
|
96
|
+
assert_eq!(
|
|
97
|
+
ryl_default_output, yam_default_output,
|
|
98
|
+
"undeclared diagnostics mismatch ({})",
|
|
99
|
+
scenario.label
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// Forward alias allowed when disabled
|
|
103
|
+
let mut ryl_allow = build_ryl_command(exe, scenario.ryl_format);
|
|
104
|
+
ryl_allow
|
|
105
|
+
.arg("-c")
|
|
106
|
+
.arg(&allow_forward_cfg)
|
|
107
|
+
.arg(&undeclared_file);
|
|
108
|
+
let (ryl_allow_code, ryl_allow_output) =
|
|
109
|
+
capture_with_env(ryl_allow, scenario.envs);
|
|
110
|
+
|
|
111
|
+
let mut yam_allow = build_yamllint_command(scenario.yam_format);
|
|
112
|
+
yam_allow
|
|
113
|
+
.arg("-c")
|
|
114
|
+
.arg(&allow_forward_cfg)
|
|
115
|
+
.arg(&undeclared_file);
|
|
116
|
+
let (yam_allow_code, yam_allow_output) =
|
|
117
|
+
capture_with_env(yam_allow, scenario.envs);
|
|
118
|
+
|
|
119
|
+
assert_eq!(
|
|
120
|
+
ryl_allow_code, 0,
|
|
121
|
+
"ryl allow-forward exit ({})",
|
|
122
|
+
scenario.label
|
|
123
|
+
);
|
|
124
|
+
assert_eq!(
|
|
125
|
+
yam_allow_code, 0,
|
|
126
|
+
"yamllint allow-forward exit ({})",
|
|
127
|
+
scenario.label
|
|
128
|
+
);
|
|
129
|
+
assert_eq!(
|
|
130
|
+
ryl_allow_output, yam_allow_output,
|
|
131
|
+
"allow-forward diagnostics mismatch ({})",
|
|
132
|
+
scenario.label
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
// Duplicate anchors
|
|
136
|
+
let mut ryl_duplicate = build_ryl_command(exe, scenario.ryl_format);
|
|
137
|
+
ryl_duplicate
|
|
138
|
+
.arg("-c")
|
|
139
|
+
.arg(&duplicates_cfg)
|
|
140
|
+
.arg(&duplicate_file);
|
|
141
|
+
let (ryl_duplicate_code, ryl_duplicate_output) =
|
|
142
|
+
capture_with_env(ryl_duplicate, scenario.envs);
|
|
143
|
+
|
|
144
|
+
let mut yam_duplicate = build_yamllint_command(scenario.yam_format);
|
|
145
|
+
yam_duplicate
|
|
146
|
+
.arg("-c")
|
|
147
|
+
.arg(&duplicates_cfg)
|
|
148
|
+
.arg(&duplicate_file);
|
|
149
|
+
let (yam_duplicate_code, yam_duplicate_output) =
|
|
150
|
+
capture_with_env(yam_duplicate, scenario.envs);
|
|
151
|
+
|
|
152
|
+
assert_eq!(
|
|
153
|
+
ryl_duplicate_code, 1,
|
|
154
|
+
"ryl duplicate exit ({})",
|
|
155
|
+
scenario.label
|
|
156
|
+
);
|
|
157
|
+
assert_eq!(
|
|
158
|
+
yam_duplicate_code, 1,
|
|
159
|
+
"yamllint duplicate exit ({})",
|
|
160
|
+
scenario.label
|
|
161
|
+
);
|
|
162
|
+
assert_eq!(
|
|
163
|
+
ryl_duplicate_output, yam_duplicate_output,
|
|
164
|
+
"duplicate diagnostics mismatch ({})",
|
|
165
|
+
scenario.label
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
// Unused anchors
|
|
169
|
+
let mut ryl_unused = build_ryl_command(exe, scenario.ryl_format);
|
|
170
|
+
ryl_unused.arg("-c").arg(&unused_cfg).arg(&unused_file);
|
|
171
|
+
let (ryl_unused_code, ryl_unused_output) =
|
|
172
|
+
capture_with_env(ryl_unused, scenario.envs);
|
|
173
|
+
|
|
174
|
+
let mut yam_unused = build_yamllint_command(scenario.yam_format);
|
|
175
|
+
yam_unused.arg("-c").arg(&unused_cfg).arg(&unused_file);
|
|
176
|
+
let (yam_unused_code, yam_unused_output) =
|
|
177
|
+
capture_with_env(yam_unused, scenario.envs);
|
|
178
|
+
|
|
179
|
+
assert_eq!(ryl_unused_code, 1, "ryl unused exit ({})", scenario.label);
|
|
180
|
+
assert_eq!(
|
|
181
|
+
yam_unused_code, 1,
|
|
182
|
+
"yamllint unused exit ({})",
|
|
183
|
+
scenario.label
|
|
184
|
+
);
|
|
185
|
+
assert_eq!(
|
|
186
|
+
ryl_unused_output, yam_unused_output,
|
|
187
|
+
"unused diagnostics mismatch ({})",
|
|
188
|
+
scenario.label
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
// Valid file should pass
|
|
192
|
+
let mut ryl_valid = build_ryl_command(exe, scenario.ryl_format);
|
|
193
|
+
ryl_valid.arg("-c").arg(&default_cfg).arg(&valid_file);
|
|
194
|
+
let (ryl_valid_code, ryl_valid_output) =
|
|
195
|
+
capture_with_env(ryl_valid, scenario.envs);
|
|
196
|
+
|
|
197
|
+
let mut yam_valid = build_yamllint_command(scenario.yam_format);
|
|
198
|
+
yam_valid.arg("-c").arg(&default_cfg).arg(&valid_file);
|
|
199
|
+
let (yam_valid_code, yam_valid_output) =
|
|
200
|
+
capture_with_env(yam_valid, scenario.envs);
|
|
201
|
+
|
|
202
|
+
assert_eq!(ryl_valid_code, 0, "ryl valid exit ({})", scenario.label);
|
|
203
|
+
assert_eq!(
|
|
204
|
+
yam_valid_code, 0,
|
|
205
|
+
"yamllint valid exit ({})",
|
|
206
|
+
scenario.label
|
|
207
|
+
);
|
|
208
|
+
assert_eq!(
|
|
209
|
+
ryl_valid_output, yam_valid_output,
|
|
210
|
+
"valid diagnostics mismatch ({})",
|
|
211
|
+
scenario.label
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
// Plain scalars containing '*' should not be treated as aliases
|
|
215
|
+
let mut ryl_regex = build_ryl_command(exe, scenario.ryl_format);
|
|
216
|
+
ryl_regex.arg("-c").arg(&default_cfg).arg(®ex_file);
|
|
217
|
+
let (ryl_regex_code, ryl_regex_output) =
|
|
218
|
+
capture_with_env(ryl_regex, scenario.envs);
|
|
219
|
+
|
|
220
|
+
let mut yam_regex = build_yamllint_command(scenario.yam_format);
|
|
221
|
+
yam_regex.arg("-c").arg(&default_cfg).arg(®ex_file);
|
|
222
|
+
let (yam_regex_code, yam_regex_output) =
|
|
223
|
+
capture_with_env(yam_regex, scenario.envs);
|
|
224
|
+
|
|
225
|
+
assert_eq!(ryl_regex_code, 0, "ryl regex exit ({})", scenario.label);
|
|
226
|
+
assert_eq!(
|
|
227
|
+
yam_regex_code, 0,
|
|
228
|
+
"yamllint regex exit ({})",
|
|
229
|
+
scenario.label
|
|
230
|
+
);
|
|
231
|
+
assert_eq!(
|
|
232
|
+
ryl_regex_output, yam_regex_output,
|
|
233
|
+
"regex diagnostics mismatch ({})",
|
|
234
|
+
scenario.label
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
#[test]
|
|
240
|
+
fn wildcard_paths_are_not_aliases_matches_yamllint() {
|
|
241
|
+
ensure_yamllint_installed();
|
|
242
|
+
|
|
243
|
+
let dir = tempdir().unwrap();
|
|
244
|
+
let cfg = dir.path().join("anchors-default.yml");
|
|
245
|
+
fs::write(
|
|
246
|
+
&cfg,
|
|
247
|
+
"rules:\n document-start: disable\n anchors: enable\n",
|
|
248
|
+
)
|
|
249
|
+
.unwrap();
|
|
250
|
+
|
|
251
|
+
let input = dir.path().join("wildcards.yaml");
|
|
252
|
+
fs::write(
|
|
253
|
+
&input,
|
|
254
|
+
"run: ./dev/sign.sh dist/airflow-*.tgz dist/airflow-*-source.tar.gz\n",
|
|
255
|
+
)
|
|
256
|
+
.unwrap();
|
|
257
|
+
|
|
258
|
+
let exe = env!("CARGO_BIN_EXE_ryl");
|
|
259
|
+
|
|
260
|
+
for scenario in SCENARIOS {
|
|
261
|
+
let mut ryl_cmd = build_ryl_command(exe, scenario.ryl_format);
|
|
262
|
+
ryl_cmd.arg("-c").arg(&cfg).arg(&input);
|
|
263
|
+
let (ryl_code, ryl_msg) = capture_with_env(ryl_cmd, scenario.envs);
|
|
264
|
+
|
|
265
|
+
let mut yam_cmd = build_yamllint_command(scenario.yam_format);
|
|
266
|
+
yam_cmd.arg("-c").arg(&cfg).arg(&input);
|
|
267
|
+
let (yam_code, yam_msg) = capture_with_env(yam_cmd, scenario.envs);
|
|
268
|
+
|
|
269
|
+
assert_eq!(
|
|
270
|
+
ryl_code, yam_code,
|
|
271
|
+
"exit mismatch for wildcard scalar ({})",
|
|
272
|
+
scenario.label
|
|
273
|
+
);
|
|
274
|
+
assert_eq!(
|
|
275
|
+
ryl_msg, yam_msg,
|
|
276
|
+
"diagnostics mismatch for wildcard scalar ({})",
|
|
277
|
+
scenario.label
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
use std::fs;
|
|
2
|
+
|
|
3
|
+
use tempfile::tempdir;
|
|
4
|
+
|
|
5
|
+
#[path = "common/compat.rs"]
|
|
6
|
+
mod compat;
|
|
7
|
+
|
|
8
|
+
use compat::{
|
|
9
|
+
SCENARIOS, build_ryl_command, build_yamllint_command, capture_with_env,
|
|
10
|
+
ensure_yamllint_installed,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
#[test]
|
|
14
|
+
fn braces_rule_matches_yamllint() {
|
|
15
|
+
ensure_yamllint_installed();
|
|
16
|
+
|
|
17
|
+
let dir = tempdir().unwrap();
|
|
18
|
+
|
|
19
|
+
let default_cfg = dir.path().join("braces-default.yml");
|
|
20
|
+
fs::write(
|
|
21
|
+
&default_cfg,
|
|
22
|
+
"rules:\n document-start: disable\n braces: enable\n",
|
|
23
|
+
)
|
|
24
|
+
.unwrap();
|
|
25
|
+
|
|
26
|
+
let warning_cfg = dir.path().join("braces-warning.yml");
|
|
27
|
+
fs::write(
|
|
28
|
+
&warning_cfg,
|
|
29
|
+
"rules:\n document-start: disable\n braces:\n level: warning\n",
|
|
30
|
+
)
|
|
31
|
+
.unwrap();
|
|
32
|
+
|
|
33
|
+
let min_cfg = dir.path().join("braces-min.yml");
|
|
34
|
+
fs::write(
|
|
35
|
+
&min_cfg,
|
|
36
|
+
"rules:\n document-start: disable\n braces:\n min-spaces-inside: 1\n max-spaces-inside: -1\n",
|
|
37
|
+
)
|
|
38
|
+
.unwrap();
|
|
39
|
+
|
|
40
|
+
let max_cfg = dir.path().join("braces-max.yml");
|
|
41
|
+
fs::write(
|
|
42
|
+
&max_cfg,
|
|
43
|
+
"rules:\n document-start: disable\n braces:\n max-spaces-inside: 1\n",
|
|
44
|
+
)
|
|
45
|
+
.unwrap();
|
|
46
|
+
|
|
47
|
+
let empty_cfg = dir.path().join("braces-empty.yml");
|
|
48
|
+
fs::write(
|
|
49
|
+
&empty_cfg,
|
|
50
|
+
"rules:\n document-start: disable\n braces:\n min-spaces-inside-empty: 1\n max-spaces-inside-empty: 2\n",
|
|
51
|
+
)
|
|
52
|
+
.unwrap();
|
|
53
|
+
|
|
54
|
+
let forbid_cfg = dir.path().join("braces-forbid.yml");
|
|
55
|
+
fs::write(
|
|
56
|
+
&forbid_cfg,
|
|
57
|
+
"rules:\n document-start: disable\n braces:\n forbid: true\n",
|
|
58
|
+
)
|
|
59
|
+
.unwrap();
|
|
60
|
+
|
|
61
|
+
let forbid_non_empty_cfg = dir.path().join("braces-forbid-non-empty.yml");
|
|
62
|
+
fs::write(
|
|
63
|
+
&forbid_non_empty_cfg,
|
|
64
|
+
"rules:\n document-start: disable\n braces:\n forbid: non-empty\n",
|
|
65
|
+
)
|
|
66
|
+
.unwrap();
|
|
67
|
+
|
|
68
|
+
let default_violation = dir.path().join("default.yaml");
|
|
69
|
+
fs::write(&default_violation, "---\nobject: { key: 1 }\n").unwrap();
|
|
70
|
+
|
|
71
|
+
let min_violation = dir.path().join("min.yaml");
|
|
72
|
+
fs::write(&min_violation, "---\nobject: {key: 1}\n").unwrap();
|
|
73
|
+
|
|
74
|
+
let max_violation = dir.path().join("max.yaml");
|
|
75
|
+
fs::write(&max_violation, "---\nobject: { key: 1 }\n").unwrap();
|
|
76
|
+
|
|
77
|
+
let empty_min_violation = dir.path().join("empty-min.yaml");
|
|
78
|
+
fs::write(&empty_min_violation, "---\nobject: {}\n").unwrap();
|
|
79
|
+
|
|
80
|
+
let empty_max_violation = dir.path().join("empty-max.yaml");
|
|
81
|
+
fs::write(&empty_max_violation, "---\nobject: { }\n").unwrap();
|
|
82
|
+
|
|
83
|
+
let forbid_violation = dir.path().join("forbid.yaml");
|
|
84
|
+
fs::write(&forbid_violation, "---\nobject: {key: 1}\n").unwrap();
|
|
85
|
+
|
|
86
|
+
let forbid_spaces_violation = dir.path().join("forbid-spaces.yaml");
|
|
87
|
+
fs::write(&forbid_spaces_violation, "---\nobject: { key: 1 }\n").unwrap();
|
|
88
|
+
|
|
89
|
+
let exe = env!("CARGO_BIN_EXE_ryl");
|
|
90
|
+
|
|
91
|
+
for scenario in SCENARIOS {
|
|
92
|
+
let mut ryl_default = build_ryl_command(exe, scenario.ryl_format);
|
|
93
|
+
ryl_default
|
|
94
|
+
.arg("-c")
|
|
95
|
+
.arg(&default_cfg)
|
|
96
|
+
.arg(&default_violation);
|
|
97
|
+
let (ryl_default_code, ryl_default_output) =
|
|
98
|
+
capture_with_env(ryl_default, scenario.envs);
|
|
99
|
+
|
|
100
|
+
let mut yam_default = build_yamllint_command(scenario.yam_format);
|
|
101
|
+
yam_default
|
|
102
|
+
.arg("-c")
|
|
103
|
+
.arg(&default_cfg)
|
|
104
|
+
.arg(&default_violation);
|
|
105
|
+
let (yam_default_code, yam_default_output) =
|
|
106
|
+
capture_with_env(yam_default, scenario.envs);
|
|
107
|
+
|
|
108
|
+
assert_eq!(ryl_default_code, 1, "ryl default exit ({})", scenario.label);
|
|
109
|
+
assert_eq!(
|
|
110
|
+
yam_default_code, 1,
|
|
111
|
+
"yamllint default exit ({})",
|
|
112
|
+
scenario.label
|
|
113
|
+
);
|
|
114
|
+
assert_eq!(
|
|
115
|
+
ryl_default_output, yam_default_output,
|
|
116
|
+
"default diagnostics mismatch ({})",
|
|
117
|
+
scenario.label
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
let mut ryl_warning = build_ryl_command(exe, scenario.ryl_format);
|
|
121
|
+
ryl_warning
|
|
122
|
+
.arg("-c")
|
|
123
|
+
.arg(&warning_cfg)
|
|
124
|
+
.arg(&default_violation);
|
|
125
|
+
let (ryl_warning_code, ryl_warning_output) =
|
|
126
|
+
capture_with_env(ryl_warning, scenario.envs);
|
|
127
|
+
|
|
128
|
+
let mut yam_warning = build_yamllint_command(scenario.yam_format);
|
|
129
|
+
yam_warning
|
|
130
|
+
.arg("-c")
|
|
131
|
+
.arg(&warning_cfg)
|
|
132
|
+
.arg(&default_violation);
|
|
133
|
+
let (yam_warning_code, yam_warning_output) =
|
|
134
|
+
capture_with_env(yam_warning, scenario.envs);
|
|
135
|
+
|
|
136
|
+
assert_eq!(ryl_warning_code, 0, "ryl warning exit ({})", scenario.label);
|
|
137
|
+
assert_eq!(
|
|
138
|
+
yam_warning_code, 0,
|
|
139
|
+
"yamllint warning exit ({})",
|
|
140
|
+
scenario.label
|
|
141
|
+
);
|
|
142
|
+
assert_eq!(
|
|
143
|
+
ryl_warning_output, yam_warning_output,
|
|
144
|
+
"warning diagnostics mismatch ({})",
|
|
145
|
+
scenario.label
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
let mut ryl_min = build_ryl_command(exe, scenario.ryl_format);
|
|
149
|
+
ryl_min.arg("-c").arg(&min_cfg).arg(&min_violation);
|
|
150
|
+
let (ryl_min_code, ryl_min_output) = capture_with_env(ryl_min, scenario.envs);
|
|
151
|
+
|
|
152
|
+
let mut yam_min = build_yamllint_command(scenario.yam_format);
|
|
153
|
+
yam_min.arg("-c").arg(&min_cfg).arg(&min_violation);
|
|
154
|
+
let (yam_min_code, yam_min_output) = capture_with_env(yam_min, scenario.envs);
|
|
155
|
+
|
|
156
|
+
assert_eq!(ryl_min_code, 1, "ryl min exit ({})", scenario.label);
|
|
157
|
+
assert_eq!(yam_min_code, 1, "yamllint min exit ({})", scenario.label);
|
|
158
|
+
assert_eq!(
|
|
159
|
+
ryl_min_output, yam_min_output,
|
|
160
|
+
"min diagnostics mismatch ({})",
|
|
161
|
+
scenario.label
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
let mut ryl_max = build_ryl_command(exe, scenario.ryl_format);
|
|
165
|
+
ryl_max.arg("-c").arg(&max_cfg).arg(&max_violation);
|
|
166
|
+
let (ryl_max_code, ryl_max_output) = capture_with_env(ryl_max, scenario.envs);
|
|
167
|
+
|
|
168
|
+
let mut yam_max = build_yamllint_command(scenario.yam_format);
|
|
169
|
+
yam_max.arg("-c").arg(&max_cfg).arg(&max_violation);
|
|
170
|
+
let (yam_max_code, yam_max_output) = capture_with_env(yam_max, scenario.envs);
|
|
171
|
+
|
|
172
|
+
assert_eq!(ryl_max_code, 1, "ryl max exit ({})", scenario.label);
|
|
173
|
+
assert_eq!(yam_max_code, 1, "yamllint max exit ({})", scenario.label);
|
|
174
|
+
assert_eq!(
|
|
175
|
+
ryl_max_output, yam_max_output,
|
|
176
|
+
"max diagnostics mismatch ({})",
|
|
177
|
+
scenario.label
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
let mut ryl_empty_min = build_ryl_command(exe, scenario.ryl_format);
|
|
181
|
+
ryl_empty_min
|
|
182
|
+
.arg("-c")
|
|
183
|
+
.arg(&empty_cfg)
|
|
184
|
+
.arg(&empty_min_violation);
|
|
185
|
+
let (ryl_empty_min_code, ryl_empty_min_output) =
|
|
186
|
+
capture_with_env(ryl_empty_min, scenario.envs);
|
|
187
|
+
|
|
188
|
+
let mut yam_empty_min = build_yamllint_command(scenario.yam_format);
|
|
189
|
+
yam_empty_min
|
|
190
|
+
.arg("-c")
|
|
191
|
+
.arg(&empty_cfg)
|
|
192
|
+
.arg(&empty_min_violation);
|
|
193
|
+
let (yam_empty_min_code, yam_empty_min_output) =
|
|
194
|
+
capture_with_env(yam_empty_min, scenario.envs);
|
|
195
|
+
|
|
196
|
+
assert_eq!(
|
|
197
|
+
ryl_empty_min_code, 1,
|
|
198
|
+
"ryl empty-min exit ({})",
|
|
199
|
+
scenario.label
|
|
200
|
+
);
|
|
201
|
+
assert_eq!(
|
|
202
|
+
yam_empty_min_code, 1,
|
|
203
|
+
"yamllint empty-min exit ({})",
|
|
204
|
+
scenario.label
|
|
205
|
+
);
|
|
206
|
+
assert_eq!(
|
|
207
|
+
ryl_empty_min_output, yam_empty_min_output,
|
|
208
|
+
"empty-min diagnostics mismatch ({})",
|
|
209
|
+
scenario.label
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
let mut ryl_empty_max = build_ryl_command(exe, scenario.ryl_format);
|
|
213
|
+
ryl_empty_max
|
|
214
|
+
.arg("-c")
|
|
215
|
+
.arg(&empty_cfg)
|
|
216
|
+
.arg(&empty_max_violation);
|
|
217
|
+
let (ryl_empty_max_code, ryl_empty_max_output) =
|
|
218
|
+
capture_with_env(ryl_empty_max, scenario.envs);
|
|
219
|
+
|
|
220
|
+
let mut yam_empty_max = build_yamllint_command(scenario.yam_format);
|
|
221
|
+
yam_empty_max
|
|
222
|
+
.arg("-c")
|
|
223
|
+
.arg(&empty_cfg)
|
|
224
|
+
.arg(&empty_max_violation);
|
|
225
|
+
let (yam_empty_max_code, yam_empty_max_output) =
|
|
226
|
+
capture_with_env(yam_empty_max, scenario.envs);
|
|
227
|
+
|
|
228
|
+
assert_eq!(
|
|
229
|
+
ryl_empty_max_code, 1,
|
|
230
|
+
"ryl empty-max exit ({})",
|
|
231
|
+
scenario.label
|
|
232
|
+
);
|
|
233
|
+
assert_eq!(
|
|
234
|
+
yam_empty_max_code, 1,
|
|
235
|
+
"yamllint empty-max exit ({})",
|
|
236
|
+
scenario.label
|
|
237
|
+
);
|
|
238
|
+
assert_eq!(
|
|
239
|
+
ryl_empty_max_output, yam_empty_max_output,
|
|
240
|
+
"empty-max diagnostics mismatch ({})",
|
|
241
|
+
scenario.label
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
let mut ryl_forbid = build_ryl_command(exe, scenario.ryl_format);
|
|
245
|
+
ryl_forbid.arg("-c").arg(&forbid_cfg).arg(&forbid_violation);
|
|
246
|
+
let (ryl_forbid_code, ryl_forbid_output) =
|
|
247
|
+
capture_with_env(ryl_forbid, scenario.envs);
|
|
248
|
+
|
|
249
|
+
let mut yam_forbid = build_yamllint_command(scenario.yam_format);
|
|
250
|
+
yam_forbid.arg("-c").arg(&forbid_cfg).arg(&forbid_violation);
|
|
251
|
+
let (yam_forbid_code, yam_forbid_output) =
|
|
252
|
+
capture_with_env(yam_forbid, scenario.envs);
|
|
253
|
+
|
|
254
|
+
assert_eq!(ryl_forbid_code, 1, "ryl forbid exit ({})", scenario.label);
|
|
255
|
+
assert_eq!(
|
|
256
|
+
yam_forbid_code, 1,
|
|
257
|
+
"yamllint forbid exit ({})",
|
|
258
|
+
scenario.label
|
|
259
|
+
);
|
|
260
|
+
assert_eq!(
|
|
261
|
+
ryl_forbid_output, yam_forbid_output,
|
|
262
|
+
"forbid diagnostics mismatch ({})",
|
|
263
|
+
scenario.label
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
let mut ryl_forbid_spaces = build_ryl_command(exe, scenario.ryl_format);
|
|
267
|
+
ryl_forbid_spaces
|
|
268
|
+
.arg("-c")
|
|
269
|
+
.arg(&forbid_non_empty_cfg)
|
|
270
|
+
.arg(&forbid_spaces_violation);
|
|
271
|
+
let (ryl_forbid_spaces_code, ryl_forbid_spaces_output) =
|
|
272
|
+
capture_with_env(ryl_forbid_spaces, scenario.envs);
|
|
273
|
+
|
|
274
|
+
let mut yam_forbid_spaces = build_yamllint_command(scenario.yam_format);
|
|
275
|
+
yam_forbid_spaces
|
|
276
|
+
.arg("-c")
|
|
277
|
+
.arg(&forbid_non_empty_cfg)
|
|
278
|
+
.arg(&forbid_spaces_violation);
|
|
279
|
+
let (yam_forbid_spaces_code, yam_forbid_spaces_output) =
|
|
280
|
+
capture_with_env(yam_forbid_spaces, scenario.envs);
|
|
281
|
+
|
|
282
|
+
assert_eq!(
|
|
283
|
+
ryl_forbid_spaces_code, 1,
|
|
284
|
+
"ryl forbid-non-empty exit ({})",
|
|
285
|
+
scenario.label
|
|
286
|
+
);
|
|
287
|
+
assert_eq!(
|
|
288
|
+
yam_forbid_spaces_code, 1,
|
|
289
|
+
"yamllint forbid-non-empty exit ({})",
|
|
290
|
+
scenario.label
|
|
291
|
+
);
|
|
292
|
+
assert_eq!(
|
|
293
|
+
ryl_forbid_spaces_output, yam_forbid_spaces_output,
|
|
294
|
+
"forbid-non-empty diagnostics mismatch ({})",
|
|
295
|
+
scenario.label
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
let mut ryl_forbid_empty = build_ryl_command(exe, scenario.ryl_format);
|
|
299
|
+
ryl_forbid_empty
|
|
300
|
+
.arg("-c")
|
|
301
|
+
.arg(&forbid_non_empty_cfg)
|
|
302
|
+
.arg(&empty_min_violation);
|
|
303
|
+
let (ryl_forbid_empty_code, ryl_forbid_empty_output) =
|
|
304
|
+
capture_with_env(ryl_forbid_empty, scenario.envs);
|
|
305
|
+
|
|
306
|
+
let mut yam_forbid_empty = build_yamllint_command(scenario.yam_format);
|
|
307
|
+
yam_forbid_empty
|
|
308
|
+
.arg("-c")
|
|
309
|
+
.arg(&forbid_non_empty_cfg)
|
|
310
|
+
.arg(&empty_min_violation);
|
|
311
|
+
let (yam_forbid_empty_code, yam_forbid_empty_output) =
|
|
312
|
+
capture_with_env(yam_forbid_empty, scenario.envs);
|
|
313
|
+
|
|
314
|
+
assert_eq!(
|
|
315
|
+
ryl_forbid_empty_code, 0,
|
|
316
|
+
"ryl forbid-non-empty empty exit ({})",
|
|
317
|
+
scenario.label
|
|
318
|
+
);
|
|
319
|
+
assert_eq!(
|
|
320
|
+
yam_forbid_empty_code, 0,
|
|
321
|
+
"yamllint forbid-non-empty empty exit ({})",
|
|
322
|
+
scenario.label
|
|
323
|
+
);
|
|
324
|
+
assert_eq!(
|
|
325
|
+
ryl_forbid_empty_output, yam_forbid_empty_output,
|
|
326
|
+
"forbid-non-empty empty diagnostics mismatch ({})",
|
|
327
|
+
scenario.label
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
#[test]
|
|
333
|
+
fn nested_double_curly_flow_mapping_matches_yamllint() {
|
|
334
|
+
ensure_yamllint_installed();
|
|
335
|
+
|
|
336
|
+
let dir = tempdir().unwrap();
|
|
337
|
+
let cfg = dir.path().join("braces-forbid.yml");
|
|
338
|
+
fs::write(
|
|
339
|
+
&cfg,
|
|
340
|
+
"rules:\n document-start: disable\n braces:\n forbid: true\n",
|
|
341
|
+
)
|
|
342
|
+
.unwrap();
|
|
343
|
+
|
|
344
|
+
let input = dir.path().join("double-curly.yml");
|
|
345
|
+
fs::write(&input, "outer: {{inner: 1}: 2}\n").unwrap();
|
|
346
|
+
|
|
347
|
+
let exe = env!("CARGO_BIN_EXE_ryl");
|
|
348
|
+
|
|
349
|
+
for scenario in SCENARIOS {
|
|
350
|
+
let mut ryl_cmd = build_ryl_command(exe, scenario.ryl_format);
|
|
351
|
+
ryl_cmd.arg("-c").arg(&cfg).arg(&input);
|
|
352
|
+
let (ryl_code, ryl_msg) = capture_with_env(ryl_cmd, scenario.envs);
|
|
353
|
+
|
|
354
|
+
let mut yam_cmd = build_yamllint_command(scenario.yam_format);
|
|
355
|
+
yam_cmd.arg("-c").arg(&cfg).arg(&input);
|
|
356
|
+
let (yam_code, yam_msg) = capture_with_env(yam_cmd, scenario.envs);
|
|
357
|
+
|
|
358
|
+
assert_eq!(
|
|
359
|
+
ryl_code, yam_code,
|
|
360
|
+
"exit mismatch for nested double-curly flow mapping ({})",
|
|
361
|
+
scenario.label
|
|
362
|
+
);
|
|
363
|
+
assert_eq!(
|
|
364
|
+
ryl_msg, yam_msg,
|
|
365
|
+
"diagnostics mismatch for nested double-curly flow mapping ({})",
|
|
366
|
+
scenario.label
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
#[test]
|
|
372
|
+
fn github_actions_payload_expression_braces_match_yamllint() {
|
|
373
|
+
ensure_yamllint_installed();
|
|
374
|
+
|
|
375
|
+
let dir = tempdir().unwrap();
|
|
376
|
+
let cfg = dir.path().join("cfg.yml");
|
|
377
|
+
fs::write(
|
|
378
|
+
&cfg,
|
|
379
|
+
"extends: default\nrules:\n line-length:\n max: 110\n",
|
|
380
|
+
)
|
|
381
|
+
.unwrap();
|
|
382
|
+
|
|
383
|
+
let input = dir.path().join("input.yml");
|
|
384
|
+
fs::write(
|
|
385
|
+
&input,
|
|
386
|
+
"---\nsteps:\n - uses: slackapi/slack-github-action@v2.1.1\n with:\n token: ${{ env.SLACK_BOT_TOKEN }}\n # yamllint disable rule:line-length\n payload: |\n channel: \"internal-airflow-ci-cd\"\n text: \"🚨🕒 Failure Alert: ${{ env.workflow_id }} on branch *${{ env.branch }}* 🕒🚨\\n\\n*Details:* <${{ env.run_url }}|View the failure log>\"\n blocks:\n - type: \"section\"\n text:\n type: \"mrkdwn\"\n text: \"🚨🕒 Failure Alert: ${{ env.workflow_id }} ${{ env.branch }} 🕒🚨\\n\\n*Details:* <${{ env.run_url }}|View the failure log>\"\n env:\n run_url: ${{ steps.find-workflow-run-status.outputs.run-url }}\n branch: ${{ matrix.branch }}\n workflow_id: ${{ matrix.workflow-id }}\n",
|
|
387
|
+
)
|
|
388
|
+
.unwrap();
|
|
389
|
+
|
|
390
|
+
let exe = env!("CARGO_BIN_EXE_ryl");
|
|
391
|
+
for scenario in SCENARIOS {
|
|
392
|
+
let mut ryl_cmd = build_ryl_command(exe, scenario.ryl_format);
|
|
393
|
+
ryl_cmd.arg("-c").arg(&cfg).arg("--strict").arg(&input);
|
|
394
|
+
let (ryl_code, ryl_msg) = capture_with_env(ryl_cmd, scenario.envs);
|
|
395
|
+
|
|
396
|
+
let mut yam_cmd = build_yamllint_command(scenario.yam_format);
|
|
397
|
+
yam_cmd.arg("-c").arg(&cfg).arg("--strict").arg(&input);
|
|
398
|
+
let (yam_code, yam_msg) = capture_with_env(yam_cmd, scenario.envs);
|
|
399
|
+
|
|
400
|
+
assert_eq!(
|
|
401
|
+
ryl_code, yam_code,
|
|
402
|
+
"exit mismatch for github actions payload expressions ({})",
|
|
403
|
+
scenario.label
|
|
404
|
+
);
|
|
405
|
+
assert_eq!(
|
|
406
|
+
ryl_msg, yam_msg,
|
|
407
|
+
"diagnostics mismatch for github actions payload expressions ({})",
|
|
408
|
+
scenario.label
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
}
|