jenkinsfilelint-engine 0.1.0__tar.gz
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.
- jenkinsfilelint_engine-0.1.0/Cargo.lock +7 -0
- jenkinsfilelint_engine-0.1.0/Cargo.toml +17 -0
- jenkinsfilelint_engine-0.1.0/DESIGN.md +94 -0
- jenkinsfilelint_engine-0.1.0/PKG-INFO +137 -0
- jenkinsfilelint_engine-0.1.0/README.md +121 -0
- jenkinsfilelint_engine-0.1.0/pyproject.toml +33 -0
- jenkinsfilelint_engine-0.1.0/python/jenkinsfilelint_engine/__init__.py +36 -0
- jenkinsfilelint_engine-0.1.0/python/jenkinsfilelint_engine/__main__.py +9 -0
- jenkinsfilelint_engine-0.1.0/rustfmt.toml +1 -0
- jenkinsfilelint_engine-0.1.0/scripts/check_engine_version.py +162 -0
- jenkinsfilelint_engine-0.1.0/scripts/corpus_check.py +197 -0
- jenkinsfilelint_engine-0.1.0/src/ast.rs +227 -0
- jenkinsfilelint_engine-0.1.0/src/diag.rs +55 -0
- jenkinsfilelint_engine-0.1.0/src/lexer.rs +594 -0
- jenkinsfilelint_engine-0.1.0/src/main.rs +330 -0
- jenkinsfilelint_engine-0.1.0/src/parser.rs +1283 -0
- jenkinsfilelint_engine-0.1.0/src/validate.rs +1158 -0
- jenkinsfilelint_engine-0.1.0/tests/fixtures/valid.groovy +71 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/.gitattributes +2 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e01_missing_agent.groovy +7 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e02_missing_stages.groovy +3 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e03_stage_without_steps.groovy +8 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e04_step_typo.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e05_duplicate_agent.groovy +7 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e06_unknown_top_section.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e07_bad_post_condition.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e08_bad_when_condition.groovy +9 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e09_nested_parallel.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e10_steps_and_parallel.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e11_empty_stages.groovy +5 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e12_env_list_value.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e13_unknown_option.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e14_bad_agent_type.groovy +6 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e15_bad_parameter_type.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e16_two_pipelines.groovy +21 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e17_pipeline_in_node.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e18_stage_without_name.groovy +8 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e19_matrix_without_axes.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e20_input_without_message.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e21_duplicate_stage_names.groovy +7 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e22_stages_without_stage.groovy +6 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e23_unknown_stage_directive.groovy +9 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e24_stage_step_in_steps.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e25_properties_step.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e26_unknown_trigger.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e27_empty_steps.groovy +9 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e28_when_empty.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e29_post_empty.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e30_agent_label_no_arg.groovy +6 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e31_parallel_and_stages.groovy +13 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e32_env_no_value.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e33_stage_outside_stages.groovy +6 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e34_when_all_of_empty.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e35_parameters_string_no_name.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e36_dup_parallel_siblings.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e37_dup_matrix_siblings.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e38_dup_nested_siblings.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e39_axis_name_gstring.groovy +19 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e40_axis_name_number.groovy +19 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e41_axis_name_property.groovy +19 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e42_axis_values_bare_words.groovy +19 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e43_axis_name_invalid_identifier.groovy +19 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e44_axis_name_duplicate_bare_word.groovy +23 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e45_gstring_stage_name.groovy +7 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e46_gstring_stage_name_semicolons.groovy +7 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e47_failfast_in_parallel.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e48_failfast_in_top_level_stages.groovy +7 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e49_failfast_in_matrix.groovy +19 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e50_failfast_in_matrix_stages.groovy +19 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e51_failfast_in_sequential_stages.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e52_env_concat_with_variable.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e53_env_negated_variable.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e54_label_first_in_script_block.groovy +15 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e55_stage_name_not_a_string.groovy +8 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e56_stage_bare_word_duplicate.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e57_shared_lib_pipeline_in_step_block.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e58_pipeline_in_nested_step_blocks.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e59_agent_docker_unknown_option.groovy +13 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e60_agent_dockerfile_unknown_option.groovy +13 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e61_agent_node_unknown_option.groovy +13 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e62_if_in_steps.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e63_def_in_steps.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e64_assignment_in_steps.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e65_if_in_nested_step_block.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e66_script_without_block.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e67_pipeline_in_steps.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e68_steps_without_block.groovy +8 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e69_when_expression_without_block.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e70_statement_in_pipeline.groovy +9 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e71_agent_docker_without_image.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e72_agent_key_without_value.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e73_agent_key_two_values.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e74_stage_two_names.groovy +8 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e75_stage_without_block.groovy +6 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e76_post_without_block.groovy +9 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e77_tools_empty.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e78_tools_statement.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e79_options_statement.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e80_matrix_not_an_axis.groovy +23 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e81_matrix_axis_unknown_field.groovy +21 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e82_matrix_not_values_in_axes.groovy +20 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e83_parallel_step_bad_argument.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e84_input_without_block.groovy +9 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e85_matrix_without_block.groovy +8 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e86_parenthesized_big_integer.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e87_parallel_step_with_a_map.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/e88_missing_agent_beside_helper_pipeline.groovy +21 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/expected.txt +765 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/p01_kubernetes_agent.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/p02_tools.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/p03_plugin_options.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/p04_unknown_step.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/p05_bad_step_param.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/p06_timeout_bad_unit.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/p07_timeout_missing_param.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/p08_plugin_trigger.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/p09_plugin_when.groovy +9 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/p10_plugin_parameter.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/p11_plugin_step_in_steps.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/p12_retry_string.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s01_unclosed_brace.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s02_unclosed_string.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s03_unclosed_paren.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s04_extra_closing_brace.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s05_unclosed_gstring_expr.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s06_bad_token.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s07_map_missing_comma.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s08_else_without_if.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s09_unclosed_block_comment.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s10_unclosed_triple_quote.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s11_missing_closing_bracket.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s12_bad_method_def.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s13_newline_before_and_at_statement_level.groovy +13 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s14_newline_before_and_in_closure_body.groovy +15 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s15_expression_continued_by_if.groovy +13 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s16_unclosed_list_in_method.groovy +8 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s17_bad_token_in_class_body.groovy +7 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s18_bad_token_in_switch.groovy +17 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s19_bad_for_header.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s20_label_colon_on_next_line.groovy +16 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s21_unterminated_slashy_string.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s22_unterminated_dollar_slashy_string.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s23_try_without_catch.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s24_list_and_map_mixed.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s25_unclosed_generic_type.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s26_dollar_paren_in_gstring.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s27_dollar_digit_in_gstring.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/s28_no_break_space.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v01_minimal.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v02_full_featured.groovy +106 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v03_matrix.groovy +37 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v04_nested_stages.groovy +22 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v05_groovy_heavy.groovy +91 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v06_comments_unicode.groovy +16 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v07_crlf.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v08_agent_variants.groovy +38 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v09_when_variants.groovy +17 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v10_stage_level_directives.groovy +17 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v11_libraries_directive.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v12_env_expressions.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v14_post_in_parallel_and_matrix.groovy +22 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v15_input_top_options.groovy +15 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v18_same_name_under_two_parents.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v19_same_name_parent_child.groovy +8 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v20_same_name_in_parallel_branches.groovy +11 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v21_same_name_matrix_and_top.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v22_same_name_parallel_and_parent.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v23_multi_assign.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v24_multi_assign_multiline.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v25_multi_assign_def.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v26_multi_assign_typed.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v27_paren_expression_statement.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v28_newline_before_and_in_parens.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v29_newline_in_if_condition.groovy +15 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v30_newline_in_call_args.groovy +13 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v31_newline_in_list.groovy +13 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v32_newline_ternary_in_parens.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v33_closure_in_call_args.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v34_newline_in_index.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v35_newline_between_named_args.groovy +13 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v36_newline_before_comma.groovy +13 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v37_axis_name_bare_word.groovy +19 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v38_axis_name_double_quoted.groovy +19 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v39_double_quoted_stage_name.groovy +6 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v40_empty_block_in_step.groovy +21 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v41_spread_map_in_call_args.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v42_command_call_on_class.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v43_slashy_string_in_interpolation.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v44_line_continuation_crlf.groovy +13 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v45_stage_level_failfast.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v46_env_signed_number.groovy +13 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v47_env_parenthesized_value.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v48_env_concat_with_constant.groovy +15 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v49_label_on_own_line.groovy +36 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v50_closure_parameters.groovy +26 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v51_cast_forms.groovy +20 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v52_agent_node_retries.groovy +13 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v53_stage_bare_word_name.groovy +8 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v54_shared_lib_pipeline_in_step_block.groovy +12 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v55_parallel_step.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v56_agent_parameters.groovy +39 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v57_shift_operators.groovy +18 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v58_number_literals.groovy +19 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v59_typed_declarations.groovy +18 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v60_arrays_and_loops.groovy +26 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v61_method_definitions.groovy +21 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v62_dollar_in_other_strings.groovy +17 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v63_parenthesized_stage_name.groovy +8 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v64_closure_as_named_argument.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/v65_pipeline_in_helper_method.groovy +22 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/x01_scripted_pipeline.groovy +5 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/x02_empty.groovy +0 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/x03_comment_only.groovy +1 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/x04_shared_lib_vars.groovy +5 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/x05_plain_groovy_class.groovy +7 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/x06_build_plugin.groovy +4 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/x07_bom_minimal.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/x08_tabs_minimal.groovy +10 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/x09_scripted_with_error_word.groovy +5 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/x10_class_with_modifiers.groovy +14 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/x11_pipeline_in_if_else.groovy +19 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/x12_pipeline_in_closure_variable.groovy +15 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/x13_shared_lib_other_pipeline_block.groovy +8 -0
- jenkinsfilelint_engine-0.1.0/tests/jenkins/x14_pipeline_in_non_call_method.groovy +10 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "jenkinsfilelint-engine"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
description = "Check Jenkinsfile syntax and Declarative Pipeline structure without a Jenkins controller"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
repository = "https://github.com/jenkinsci/jenkinsfilelint"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
keywords = ["jenkins", "jenkinsfile", "lint", "pipeline", "groovy"]
|
|
10
|
+
categories = ["command-line-utilities", "development-tools"]
|
|
11
|
+
|
|
12
|
+
[dependencies]
|
|
13
|
+
|
|
14
|
+
[profile.release]
|
|
15
|
+
lto = true
|
|
16
|
+
strip = true
|
|
17
|
+
codegen-units = 1
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Offline mode: design notes
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
`jenkinsfilelint` checks a Jenkinsfile by sending it to a Jenkins
|
|
6
|
+
controller, either an existing one or a container started with `--local`.
|
|
7
|
+
Both are accurate, but both need a controller: credentials or Docker, a
|
|
8
|
+
JVM, and seconds to minutes of start-up. That keeps the hook out of many
|
|
9
|
+
pre-commit setups and most editors.
|
|
10
|
+
|
|
11
|
+
GitHub Actions has `actionlint`, a single binary that catches workflow
|
|
12
|
+
mistakes offline. Jenkins has nothing like it. The closest prior work:
|
|
13
|
+
|
|
14
|
+
- `jenkinsfile-runner lint` embeds Jenkins itself, so it still needs a JVM
|
|
15
|
+
and a large download.
|
|
16
|
+
- `jdp` (Rust, 2020) parsed the declarative grammar offline but is
|
|
17
|
+
unmaintained and skipped Groovy.
|
|
18
|
+
- `npm-groovy-lint` checks Groovy style, not pipeline structure.
|
|
19
|
+
|
|
20
|
+
## Goal
|
|
21
|
+
|
|
22
|
+
A binary that runs in milliseconds, needs nothing installed, and agrees
|
|
23
|
+
with the official validator wherever the answer does not depend on
|
|
24
|
+
plugins. Where it does depend on plugins, stay silent or warn, never fail
|
|
25
|
+
a valid file.
|
|
26
|
+
|
|
27
|
+
## Why Rust
|
|
28
|
+
|
|
29
|
+
Both Go and Rust produce small static binaries. Rust won on three points:
|
|
30
|
+
|
|
31
|
+
1. **Python packaging.** Existing users install with `pip` and run the
|
|
32
|
+
pre-commit hook with `language: python`. `maturin` (used by ruff and uv)
|
|
33
|
+
puts a Rust binary into a platform wheel, so those users get the offline
|
|
34
|
+
mode with no config change.
|
|
35
|
+
2. **Parser work.** No off-the-shelf Groovy parser handles Jenkins idioms:
|
|
36
|
+
tree-sitter-groovy failed on 42 of the 293 official valid samples,
|
|
37
|
+
mostly on `sh script: 'x', returnStdout: true` and `@Library('x') _`.
|
|
38
|
+
A hand-written parser is needed in either language, and Rust's enums and
|
|
39
|
+
pattern matching suit syntax trees and diagnostics.
|
|
40
|
+
3. **Web playground later.** A paste-your-Jenkinsfile page is the easiest
|
|
41
|
+
way to show the tool; Rust compiles to a small WebAssembly module.
|
|
42
|
+
|
|
43
|
+
## Architecture
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
src/lexer.rs tokens; all Groovy string forms; newline tracking
|
|
47
|
+
src/parser.rs recursive-descent parser -> small AST (ast.rs)
|
|
48
|
+
src/validate.rs declarative structure checks, official message wording
|
|
49
|
+
src/main.rs CLI: text or JSON output, exit codes
|
|
50
|
+
python/ jenkinsfilelint_engine: finds the binary installed by the wheel
|
|
51
|
+
scripts/corpus_check.py agreement test against the plugin's own samples
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The parser is strict where Jenkins users write code every day (command
|
|
55
|
+
calls, named arguments, closures, GStrings, maps, lists) and lenient where
|
|
56
|
+
declarative validation never looks (class bodies, `switch`, `for` headers),
|
|
57
|
+
where it only checks that brackets balance.
|
|
58
|
+
|
|
59
|
+
Messages are copied from the plugin's `Messages.properties`, so a user sees
|
|
60
|
+
the same text offline and online.
|
|
61
|
+
|
|
62
|
+
## Measuring accuracy
|
|
63
|
+
|
|
64
|
+
`scripts/corpus_check.py` clones the plugin at a pinned commit and runs the
|
|
65
|
+
linter over its test resources:
|
|
66
|
+
|
|
67
|
+
- every file outside `errors/` must produce no error (287/287 today),
|
|
68
|
+
- every file in `errors/` whose expectation does not need plugins must be
|
|
69
|
+
caught (90/90) with the expected message (90/90).
|
|
70
|
+
|
|
71
|
+
Real-world check: 37 Jenkinsfiles from Apache (HBase, Hadoop, Cassandra,
|
|
72
|
+
Camel, ZooKeeper, Maven) and Jenkins projects pass clean, and injected
|
|
73
|
+
mistakes in them are all caught.
|
|
74
|
+
|
|
75
|
+
## Next steps
|
|
76
|
+
|
|
77
|
+
1. **Step catalog (warnings).** Generate a list of steps and their
|
|
78
|
+
parameters from the public Pipeline Steps Reference, ship it inside the
|
|
79
|
+
binary, and warn on unknown steps or parameters. Let users declare
|
|
80
|
+
shared-library steps in a config file.
|
|
81
|
+
2. **Distribution.** Done: this crate is published to PyPI as
|
|
82
|
+
`jenkinsfilelint-engine`, maturin binary wheels (`bindings = "bin"`,
|
|
83
|
+
like ruff) for Linux, macOS and Windows plus an sdist. `jenkinsfilelint`
|
|
84
|
+
stays pure Python, depends on the engine pinned to the exact version, and
|
|
85
|
+
runs it for `--offline`, the `jenkinsfilelint-offline` pre-commit hook,
|
|
86
|
+
and whenever no Jenkins server is configured. Keeping the root package pure Python matters because pre-commit
|
|
87
|
+
installs hooks from source: a maturin-built root package would make every
|
|
88
|
+
pre-commit user compile Rust. The dependency is limited to platforms with
|
|
89
|
+
a wheel, so other platforms keep the remote and Docker modes. GitHub
|
|
90
|
+
Releases and Homebrew later.
|
|
91
|
+
3. **Editor and web.** JSON output already exists for editors; add a
|
|
92
|
+
WebAssembly build for a web playground.
|
|
93
|
+
4. **Groovy coverage.** Keep adding real-world Jenkinsfiles to the test set
|
|
94
|
+
and fix any parse gaps they reveal.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jenkinsfilelint-engine
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Programming Language :: Python :: 3
|
|
5
|
+
Classifier: Programming Language :: Rust
|
|
6
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Summary: Offline engine of jenkinsfilelint: checks Jenkinsfile syntax and Declarative Pipeline structure without a Jenkins controller
|
|
9
|
+
Keywords: jenkins,jenkinsfile,lint,pipeline,groovy
|
|
10
|
+
Author-email: Xianpeng Shen <xianpeng.shen@gmail.com>
|
|
11
|
+
License: MIT
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
14
|
+
Project-URL: Homepage, https://github.com/jenkinsci/jenkinsfilelint
|
|
15
|
+
|
|
16
|
+
# jenkinsfilelint-engine
|
|
17
|
+
|
|
18
|
+
Check a Jenkinsfile without a Jenkins controller: no server, no Docker, no
|
|
19
|
+
JVM. One ~500 KB binary that checks Groovy syntax and Declarative Pipeline
|
|
20
|
+
structure, and reports errors with the same wording as Jenkins's own
|
|
21
|
+
validator.
|
|
22
|
+
|
|
23
|
+
This is the offline engine of `jenkinsfilelint`: it runs for `--offline`, the
|
|
24
|
+
`jenkinsfilelint-offline` pre-commit hook, and whenever no Jenkins server is
|
|
25
|
+
configured. Most people want
|
|
26
|
+
[jenkinsfilelint](https://github.com/jenkinsci/jenkinsfilelint) itself, which
|
|
27
|
+
installs this package. The remote and Docker modes of `jenkinsfilelint` stay
|
|
28
|
+
the exact check; this one is the fast one. See [DESIGN.md](DESIGN.md).
|
|
29
|
+
|
|
30
|
+
```console
|
|
31
|
+
$ jenkinsfilelint-engine Jenkinsfile
|
|
32
|
+
Jenkinsfile:2:5: error: Not a valid section definition: "agent". Some extra configuration is required.
|
|
33
|
+
Jenkinsfile:9:9: error: Expected one of "steps", "stages", or "parallel" for stage "Test"
|
|
34
|
+
Jenkinsfile:10:13: error: Unknown stage section "step". Starting with version 0.5, steps in a stage must be in a ‘steps’ block.
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install jenkinsfilelint-engine
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
PyPI has prebuilt wheels for Linux (x86_64, aarch64, i686, armv7; glibc and
|
|
44
|
+
musl), macOS (x86_64, arm64) and Windows (x86_64, x86), for any Python 3.10+. The wheel puts the
|
|
45
|
+
`jenkinsfilelint-engine` binary in the environment's scripts directory;
|
|
46
|
+
`python -m jenkinsfilelint_engine` runs it too, and
|
|
47
|
+
`jenkinsfilelint_engine.find_bin()` returns its path. On other platforms pip
|
|
48
|
+
builds it from the sdist, which needs a [Rust toolchain](https://rustup.rs).
|
|
49
|
+
|
|
50
|
+
## Build and run
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
cd crates/jenkinsfilelint
|
|
54
|
+
cargo build --release
|
|
55
|
+
./target/release/jenkinsfilelint-engine path/to/Jenkinsfile [more files...]
|
|
56
|
+
./target/release/jenkinsfilelint-engine --format json Jenkinsfile
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Exit code is `0` when no file has an error, `1` when any does, and `2` for
|
|
60
|
+
usage errors. Warnings do not fail the run.
|
|
61
|
+
|
|
62
|
+
`--format json` prints one object per file:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
[{"file": "Jenkinsfile", "declarative": true, "diagnostics": [
|
|
66
|
+
{"line": 2, "column": 5, "severity": "error", "message": "Not a valid section definition: ..."}]},
|
|
67
|
+
{"file": "vars/notify.groovy", "declarative": false, "diagnostics": []},
|
|
68
|
+
{"file": "missing", "error": "No such file or directory (os error 2)"}]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`declarative` is `false` when the file has no `pipeline` block (a Scripted
|
|
72
|
+
Pipeline, a shared-library step, plain Groovy): its Groovy syntax was checked,
|
|
73
|
+
but there was no Declarative structure to check.
|
|
74
|
+
|
|
75
|
+
## What it checks
|
|
76
|
+
|
|
77
|
+
- **Groovy syntax**, including every string form (`'...'`, `"${...}"`,
|
|
78
|
+
triple-quoted, slashy, dollar-slashy), command calls with named arguments
|
|
79
|
+
(`sh script: 'ls', returnStdout: true`), trailing closures, `@Library(...) _`,
|
|
80
|
+
method and class definitions.
|
|
81
|
+
- **Declarative structure**: required `agent` and `stages`; allowed and
|
|
82
|
+
duplicate sections; each stage has exactly one of `steps`, `stages`,
|
|
83
|
+
`parallel` or `matrix`; no nested `parallel`/`matrix`; `agent` forms and
|
|
84
|
+
built-in agent parameters; `environment` keys and values; `options`,
|
|
85
|
+
`triggers`, `parameters`, `tools`, `libraries`, `input`; `when` conditions
|
|
86
|
+
and their nesting; `post` conditions; `matrix` axes and excludes; steps that
|
|
87
|
+
are blocked in Declarative (`stage`, `properties`, mixed `parallel`);
|
|
88
|
+
`pipeline {}` inside the block of another step (`node { pipeline { } }`).
|
|
89
|
+
|
|
90
|
+
## What it cannot check
|
|
91
|
+
|
|
92
|
+
Anything that depends on the plugins installed on a controller:
|
|
93
|
+
|
|
94
|
+
- whether a step exists and takes the given parameters,
|
|
95
|
+
- agent types added by plugins (reported as a warning, not an error),
|
|
96
|
+
- tool installations configured on the controller,
|
|
97
|
+
- script-security sandbox rules.
|
|
98
|
+
|
|
99
|
+
Use the remote or `--local` Docker mode of `jenkinsfilelint` for those.
|
|
100
|
+
|
|
101
|
+
## How close is it to the official validator?
|
|
102
|
+
|
|
103
|
+
The [pipeline-model-definition plugin](https://github.com/jenkinsci/pipeline-model-definition-plugin)
|
|
104
|
+
ships the test Jenkinsfiles for Jenkins's own validator. Running the offline
|
|
105
|
+
linter over them:
|
|
106
|
+
|
|
107
|
+
| | Result |
|
|
108
|
+
|---|---|
|
|
109
|
+
| Valid files with no false errors | 287 / 287 |
|
|
110
|
+
| Invalid files caught | 90 / 90 |
|
|
111
|
+
| ... with the same message as Jenkins | 90 / 90 |
|
|
112
|
+
| Invalid files that need plugins or a controller to judge | 33 (not counted above) |
|
|
113
|
+
|
|
114
|
+
Reproduce with:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
cargo build --release
|
|
118
|
+
python3 scripts/corpus_check.py # clones the plugin at a pinned commit
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Development
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
cargo fmt --check
|
|
125
|
+
cargo clippy --all-targets -- -D warnings
|
|
126
|
+
cargo test
|
|
127
|
+
python3 scripts/corpus_check.py
|
|
128
|
+
pip install . # builds the wheel with maturin and installs it
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
When the engine changes, bump `version` in `Cargo.toml` and the
|
|
132
|
+
`jenkinsfilelint-engine==` pin in the root `pyproject.toml` together.
|
|
133
|
+
|
|
134
|
+
`cargo test` also lints every case in `tests/jenkins/` and compares the
|
|
135
|
+
result with `tests/jenkins/expected.txt`, which records what Jenkins's own
|
|
136
|
+
validator said about the same file and explains each known difference.
|
|
137
|
+
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# jenkinsfilelint-engine
|
|
2
|
+
|
|
3
|
+
Check a Jenkinsfile without a Jenkins controller: no server, no Docker, no
|
|
4
|
+
JVM. One ~500 KB binary that checks Groovy syntax and Declarative Pipeline
|
|
5
|
+
structure, and reports errors with the same wording as Jenkins's own
|
|
6
|
+
validator.
|
|
7
|
+
|
|
8
|
+
This is the offline engine of `jenkinsfilelint`: it runs for `--offline`, the
|
|
9
|
+
`jenkinsfilelint-offline` pre-commit hook, and whenever no Jenkins server is
|
|
10
|
+
configured. Most people want
|
|
11
|
+
[jenkinsfilelint](https://github.com/jenkinsci/jenkinsfilelint) itself, which
|
|
12
|
+
installs this package. The remote and Docker modes of `jenkinsfilelint` stay
|
|
13
|
+
the exact check; this one is the fast one. See [DESIGN.md](DESIGN.md).
|
|
14
|
+
|
|
15
|
+
```console
|
|
16
|
+
$ jenkinsfilelint-engine Jenkinsfile
|
|
17
|
+
Jenkinsfile:2:5: error: Not a valid section definition: "agent". Some extra configuration is required.
|
|
18
|
+
Jenkinsfile:9:9: error: Expected one of "steps", "stages", or "parallel" for stage "Test"
|
|
19
|
+
Jenkinsfile:10:13: error: Unknown stage section "step". Starting with version 0.5, steps in a stage must be in a ‘steps’ block.
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install jenkinsfilelint-engine
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
PyPI has prebuilt wheels for Linux (x86_64, aarch64, i686, armv7; glibc and
|
|
29
|
+
musl), macOS (x86_64, arm64) and Windows (x86_64, x86), for any Python 3.10+. The wheel puts the
|
|
30
|
+
`jenkinsfilelint-engine` binary in the environment's scripts directory;
|
|
31
|
+
`python -m jenkinsfilelint_engine` runs it too, and
|
|
32
|
+
`jenkinsfilelint_engine.find_bin()` returns its path. On other platforms pip
|
|
33
|
+
builds it from the sdist, which needs a [Rust toolchain](https://rustup.rs).
|
|
34
|
+
|
|
35
|
+
## Build and run
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
cd crates/jenkinsfilelint
|
|
39
|
+
cargo build --release
|
|
40
|
+
./target/release/jenkinsfilelint-engine path/to/Jenkinsfile [more files...]
|
|
41
|
+
./target/release/jenkinsfilelint-engine --format json Jenkinsfile
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Exit code is `0` when no file has an error, `1` when any does, and `2` for
|
|
45
|
+
usage errors. Warnings do not fail the run.
|
|
46
|
+
|
|
47
|
+
`--format json` prints one object per file:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
[{"file": "Jenkinsfile", "declarative": true, "diagnostics": [
|
|
51
|
+
{"line": 2, "column": 5, "severity": "error", "message": "Not a valid section definition: ..."}]},
|
|
52
|
+
{"file": "vars/notify.groovy", "declarative": false, "diagnostics": []},
|
|
53
|
+
{"file": "missing", "error": "No such file or directory (os error 2)"}]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`declarative` is `false` when the file has no `pipeline` block (a Scripted
|
|
57
|
+
Pipeline, a shared-library step, plain Groovy): its Groovy syntax was checked,
|
|
58
|
+
but there was no Declarative structure to check.
|
|
59
|
+
|
|
60
|
+
## What it checks
|
|
61
|
+
|
|
62
|
+
- **Groovy syntax**, including every string form (`'...'`, `"${...}"`,
|
|
63
|
+
triple-quoted, slashy, dollar-slashy), command calls with named arguments
|
|
64
|
+
(`sh script: 'ls', returnStdout: true`), trailing closures, `@Library(...) _`,
|
|
65
|
+
method and class definitions.
|
|
66
|
+
- **Declarative structure**: required `agent` and `stages`; allowed and
|
|
67
|
+
duplicate sections; each stage has exactly one of `steps`, `stages`,
|
|
68
|
+
`parallel` or `matrix`; no nested `parallel`/`matrix`; `agent` forms and
|
|
69
|
+
built-in agent parameters; `environment` keys and values; `options`,
|
|
70
|
+
`triggers`, `parameters`, `tools`, `libraries`, `input`; `when` conditions
|
|
71
|
+
and their nesting; `post` conditions; `matrix` axes and excludes; steps that
|
|
72
|
+
are blocked in Declarative (`stage`, `properties`, mixed `parallel`);
|
|
73
|
+
`pipeline {}` inside the block of another step (`node { pipeline { } }`).
|
|
74
|
+
|
|
75
|
+
## What it cannot check
|
|
76
|
+
|
|
77
|
+
Anything that depends on the plugins installed on a controller:
|
|
78
|
+
|
|
79
|
+
- whether a step exists and takes the given parameters,
|
|
80
|
+
- agent types added by plugins (reported as a warning, not an error),
|
|
81
|
+
- tool installations configured on the controller,
|
|
82
|
+
- script-security sandbox rules.
|
|
83
|
+
|
|
84
|
+
Use the remote or `--local` Docker mode of `jenkinsfilelint` for those.
|
|
85
|
+
|
|
86
|
+
## How close is it to the official validator?
|
|
87
|
+
|
|
88
|
+
The [pipeline-model-definition plugin](https://github.com/jenkinsci/pipeline-model-definition-plugin)
|
|
89
|
+
ships the test Jenkinsfiles for Jenkins's own validator. Running the offline
|
|
90
|
+
linter over them:
|
|
91
|
+
|
|
92
|
+
| | Result |
|
|
93
|
+
|---|---|
|
|
94
|
+
| Valid files with no false errors | 287 / 287 |
|
|
95
|
+
| Invalid files caught | 90 / 90 |
|
|
96
|
+
| ... with the same message as Jenkins | 90 / 90 |
|
|
97
|
+
| Invalid files that need plugins or a controller to judge | 33 (not counted above) |
|
|
98
|
+
|
|
99
|
+
Reproduce with:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
cargo build --release
|
|
103
|
+
python3 scripts/corpus_check.py # clones the plugin at a pinned commit
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Development
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
cargo fmt --check
|
|
110
|
+
cargo clippy --all-targets -- -D warnings
|
|
111
|
+
cargo test
|
|
112
|
+
python3 scripts/corpus_check.py
|
|
113
|
+
pip install . # builds the wheel with maturin and installs it
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
When the engine changes, bump `version` in `Cargo.toml` and the
|
|
117
|
+
`jenkinsfilelint-engine==` pin in the root `pyproject.toml` together.
|
|
118
|
+
|
|
119
|
+
`cargo test` also lints every case in `tests/jenkins/` and compares the
|
|
120
|
+
result with `tests/jenkins/expected.txt`, which records what Jenkins's own
|
|
121
|
+
validator said about the same file and explains each known difference.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# The offline engine of jenkinsfilelint, published to PyPI as prebuilt wheels
|
|
2
|
+
# that put the jenkinsfilelint-engine binary on PATH. The jenkinsfilelint
|
|
3
|
+
# package depends on it, so its users never need a Rust toolchain.
|
|
4
|
+
[build-system]
|
|
5
|
+
requires = ["maturin>=1.7,<2.0"]
|
|
6
|
+
build-backend = "maturin"
|
|
7
|
+
|
|
8
|
+
[project]
|
|
9
|
+
name = "jenkinsfilelint-engine"
|
|
10
|
+
# Taken from Cargo.toml. jenkinsfilelint pins this version exactly.
|
|
11
|
+
dynamic = ["version"]
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Xianpeng Shen", email = "xianpeng.shen@gmail.com"},
|
|
14
|
+
]
|
|
15
|
+
description = "Offline engine of jenkinsfilelint: checks Jenkinsfile syntax and Declarative Pipeline structure without a Jenkins controller"
|
|
16
|
+
license = {text = "MIT"}
|
|
17
|
+
readme = "README.md"
|
|
18
|
+
requires-python = ">=3.10"
|
|
19
|
+
keywords = ["jenkins", "jenkinsfile", "lint", "pipeline", "groovy"]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Rust",
|
|
23
|
+
"License :: OSI Approved :: MIT License",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/jenkinsci/jenkinsfilelint"
|
|
29
|
+
|
|
30
|
+
[tool.maturin]
|
|
31
|
+
bindings = "bin"
|
|
32
|
+
python-source = "python"
|
|
33
|
+
module-name = "jenkinsfilelint_engine"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Locate the jenkinsfilelint-engine binary installed with this package."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import shutil
|
|
5
|
+
import sys
|
|
6
|
+
import sysconfig
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
BINARY = "jenkinsfilelint-engine" + (".exe" if sys.platform == "win32" else "")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def find_bin() -> str:
|
|
13
|
+
"""Return the path of the jenkinsfilelint-engine binary.
|
|
14
|
+
|
|
15
|
+
The wheel installs it into the scripts directory of the environment the
|
|
16
|
+
package was installed into, which is not always on PATH.
|
|
17
|
+
|
|
18
|
+
Raises:
|
|
19
|
+
FileNotFoundError: if the binary cannot be found.
|
|
20
|
+
"""
|
|
21
|
+
candidates = [
|
|
22
|
+
sysconfig.get_path("scripts"),
|
|
23
|
+
sysconfig.get_path("scripts", sysconfig.get_preferred_scheme("user")),
|
|
24
|
+
# pip install --target puts scripts in bin/ next to the package.
|
|
25
|
+
str(Path(__file__).resolve().parent.parent / "bin"),
|
|
26
|
+
]
|
|
27
|
+
for directory in candidates:
|
|
28
|
+
path = os.path.join(directory, BINARY)
|
|
29
|
+
if os.path.isfile(path):
|
|
30
|
+
return path
|
|
31
|
+
|
|
32
|
+
path = shutil.which(BINARY)
|
|
33
|
+
if path:
|
|
34
|
+
return path
|
|
35
|
+
|
|
36
|
+
raise FileNotFoundError(f"{BINARY} not found in {', '.join(candidates)} or PATH")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
max_width = 140
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Check the version of the engine: its pin, and that it changes with the engine.
|
|
3
|
+
|
|
4
|
+
1. pyproject.toml must pin jenkinsfilelint-engine to the version in
|
|
5
|
+
crates/jenkinsfilelint/Cargo.toml.
|
|
6
|
+
2. The engine must not have changed since the last release while its
|
|
7
|
+
version stayed the same.
|
|
8
|
+
|
|
9
|
+
A release uploads jenkinsfilelint-engine only if its version is not on PyPI
|
|
10
|
+
yet. So when the engine's code changes and its version stays the same, the
|
|
11
|
+
release is green, nothing new is uploaded, and `pip install jenkinsfilelint`
|
|
12
|
+
keeps installing the old engine.
|
|
13
|
+
|
|
14
|
+
For the second check, this script compares the files that go into the engine
|
|
15
|
+
with the last release tag. If they differ, the version in Cargo.toml must
|
|
16
|
+
differ too.
|
|
17
|
+
|
|
18
|
+
Usage:
|
|
19
|
+
python3 crates/jenkinsfilelint/scripts/check_engine_version.py [--base TAG]
|
|
20
|
+
|
|
21
|
+
Without --base, the base is the last `v*` tag before HEAD. It needs the
|
|
22
|
+
repository's history and tags (`fetch-depth: 0` in GitHub Actions); without
|
|
23
|
+
them it fails rather than pass without comparing anything.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
import argparse
|
|
27
|
+
import re
|
|
28
|
+
import subprocess
|
|
29
|
+
import sys
|
|
30
|
+
from pathlib import Path
|
|
31
|
+
from typing import List, Optional
|
|
32
|
+
|
|
33
|
+
CRATE = "crates/jenkinsfilelint"
|
|
34
|
+
CARGO_TOML = f"{CRATE}/Cargo.toml"
|
|
35
|
+
PYPROJECT_TOML = "pyproject.toml"
|
|
36
|
+
|
|
37
|
+
# What is built into the wheels. Tests, scripts and documents are not.
|
|
38
|
+
ENGINE_PATHS = [
|
|
39
|
+
f"{CRATE}/src",
|
|
40
|
+
f"{CRATE}/python",
|
|
41
|
+
f"{CRATE}/Cargo.toml",
|
|
42
|
+
f"{CRATE}/Cargo.lock",
|
|
43
|
+
f"{CRATE}/pyproject.toml",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def git(repo: Path, *args: str) -> "subprocess.CompletedProcess[str]":
|
|
48
|
+
return subprocess.run(
|
|
49
|
+
["git", *args],
|
|
50
|
+
cwd=repo,
|
|
51
|
+
capture_output=True,
|
|
52
|
+
text=True,
|
|
53
|
+
encoding="utf-8",
|
|
54
|
+
check=False,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def cargo_version(text: str) -> str:
|
|
59
|
+
"""The version in the text of crates/jenkinsfilelint/Cargo.toml."""
|
|
60
|
+
match = re.search(r'^version = "([^"]+)"', text, re.MULTILINE)
|
|
61
|
+
if not match:
|
|
62
|
+
raise ValueError(f"no version in {CARGO_TOML}")
|
|
63
|
+
return match.group(1)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def pinned_version(text: str) -> str:
|
|
67
|
+
"""The jenkinsfilelint-engine version that the text of pyproject.toml pins."""
|
|
68
|
+
match = re.search(r"jenkinsfilelint-engine==([^;\s\"]+)", text)
|
|
69
|
+
if not match:
|
|
70
|
+
raise ValueError(f"no jenkinsfilelint-engine== pin in {PYPROJECT_TOML}")
|
|
71
|
+
return match.group(1)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def check_pin(repo: Path) -> List[str]:
|
|
75
|
+
"""Like check(): the pin in pyproject.toml against Cargo.toml."""
|
|
76
|
+
version = cargo_version((repo / CARGO_TOML).read_text(encoding="utf-8"))
|
|
77
|
+
pin = pinned_version((repo / PYPROJECT_TOML).read_text(encoding="utf-8"))
|
|
78
|
+
if pin != version:
|
|
79
|
+
return [
|
|
80
|
+
f"error: {PYPROJECT_TOML} pins jenkinsfilelint-engine=={pin}, "
|
|
81
|
+
f"but {CARGO_TOML} says {version}."
|
|
82
|
+
]
|
|
83
|
+
return [f"{PYPROJECT_TOML} pins jenkinsfilelint-engine=={pin}, as in {CARGO_TOML}."]
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def last_release_tag(repo: Path) -> Optional[str]:
|
|
87
|
+
"""The last `v*` tag before HEAD, or None when there is none.
|
|
88
|
+
|
|
89
|
+
Before HEAD, not at HEAD: when HEAD is the commit being released, the
|
|
90
|
+
engine has to be compared with the release before it.
|
|
91
|
+
"""
|
|
92
|
+
for commit in ("HEAD^", "HEAD"):
|
|
93
|
+
described = git(
|
|
94
|
+
repo, "describe", "--tags", "--abbrev=0", "--match", "v*", commit
|
|
95
|
+
)
|
|
96
|
+
if described.returncode == 0:
|
|
97
|
+
return described.stdout.strip()
|
|
98
|
+
return None
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def check(repo: Path, base: Optional[str] = None) -> List[str]:
|
|
102
|
+
"""Return what to tell the user: one line when all is well, or the
|
|
103
|
+
error, which starts with "error:"."""
|
|
104
|
+
base = base or last_release_tag(repo)
|
|
105
|
+
if base is None:
|
|
106
|
+
shallow = git(repo, "rev-parse", "--is-shallow-repository").stdout.strip()
|
|
107
|
+
why = (
|
|
108
|
+
"this is a shallow clone" if shallow == "true" else "no v* tag is reachable"
|
|
109
|
+
)
|
|
110
|
+
return [
|
|
111
|
+
f"error: no release tag to compare the engine with ({why}).",
|
|
112
|
+
"Fetch the history and tags (fetch-depth: 0 in GitHub Actions), "
|
|
113
|
+
"or name the release to compare with: --base TAG.",
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
released = git(repo, "show", f"{base}:{CARGO_TOML}")
|
|
117
|
+
if released.returncode != 0:
|
|
118
|
+
return [f"{base} has no engine: nothing to compare with."]
|
|
119
|
+
released_version = cargo_version(released.stdout)
|
|
120
|
+
version = cargo_version((repo / CARGO_TOML).read_text(encoding="utf-8"))
|
|
121
|
+
|
|
122
|
+
# Compares the working tree, so that it also works before committing.
|
|
123
|
+
diff = git(repo, "diff", "--name-only", base, "--", *ENGINE_PATHS)
|
|
124
|
+
if diff.returncode != 0:
|
|
125
|
+
raise RuntimeError(diff.stderr.strip())
|
|
126
|
+
changed = diff.stdout.split()
|
|
127
|
+
untracked = git(
|
|
128
|
+
repo, "ls-files", "--others", "--exclude-standard", "--", *ENGINE_PATHS
|
|
129
|
+
)
|
|
130
|
+
changed += untracked.stdout.split()
|
|
131
|
+
|
|
132
|
+
if not changed:
|
|
133
|
+
return [f"The engine is the same as in {base} ({version})."]
|
|
134
|
+
if version != released_version:
|
|
135
|
+
return [f"The engine changed since {base}: {released_version} -> {version}."]
|
|
136
|
+
return [
|
|
137
|
+
f"error: the engine changed since {base}, but its version is still {version}.",
|
|
138
|
+
"Changed: " + ", ".join(changed),
|
|
139
|
+
f"A release would keep jenkinsfilelint-engine {version} from PyPI, without these changes.",
|
|
140
|
+
f'Bump "version" in {CARGO_TOML} and the jenkinsfilelint-engine pin in pyproject.toml.',
|
|
141
|
+
]
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def main(argv: Optional[List[str]] = None) -> int:
|
|
145
|
+
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
|
146
|
+
parser.add_argument(
|
|
147
|
+
"--base",
|
|
148
|
+
help="tag or commit to compare with (default: the last v* tag before HEAD)",
|
|
149
|
+
)
|
|
150
|
+
args = parser.parse_args(argv)
|
|
151
|
+
|
|
152
|
+
repo = Path(__file__).resolve().parents[3]
|
|
153
|
+
failed = False
|
|
154
|
+
for lines in (check_pin(repo), check(repo, args.base)):
|
|
155
|
+
error = lines[0].startswith("error:")
|
|
156
|
+
failed |= error
|
|
157
|
+
print("\n".join(lines), file=sys.stderr if error else sys.stdout)
|
|
158
|
+
return 1 if failed else 0
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
if __name__ == "__main__":
|
|
162
|
+
sys.exit(main())
|