diff --git a/.drone.star b/.drone.star index 01c8bc58dd..9d0b21c601 100644 --- a/.drone.star +++ b/.drone.star @@ -272,6 +272,7 @@ def main(ctx): test_pipelines = \ codestyle(ctx) + \ + checkGherkinLint(ctx) + \ checkTestSuitesInExpectedFailures(ctx) + \ buildWebCache(ctx) + \ getGoBinForTesting(ctx) + \ @@ -732,6 +733,28 @@ def checkTestSuitesInExpectedFailures(ctx): }, }] +def checkGherkinLint(ctx): + return [{ + "kind": "pipeline", + "type": "docker", + "name": "check-gherkin-standard", + "steps": [ + { + "name": "lint-feature-files", + "image": OC_CI_NODEJS % DEFAULT_NODEJS_VERSION, + "commands": [ + "npm install -g @gherlint/gherlint@1.1.0", + "make test-gherkin-lint", + ], + }, + ], + "trigger": { + "ref": [ + "refs/pull/**", + ], + }, + }] + def codestyle(ctx): pipelines = [] diff --git a/Makefile b/Makefile index 7628606840..156cb56a13 100644 --- a/Makefile +++ b/Makefile @@ -112,6 +112,10 @@ help: @echo -e "\tmake test-php-style\t\t${BLUE}run PHP code style checks${RESET}" @echo -e "\tmake test-php-style-fix\t\t${BLUE}run PHP code style checks and fix any issues found${RESET}" @echo + @echo -e "${GREEN}Tools for linting gherkin feature files:\n${RESET}" + @echo -e "\tmake test-gherkin-lint\t\t${BLUE}run lint checks on Gherkin feature files${RESET}" + @echo -e "\tmake test-gherkin-lint-fix\t${BLUE}apply lint fixes to gherkin feature files${RESET}" + @echo .PHONY: clean-tests clean-tests: @@ -235,6 +239,14 @@ golangci-lint-fix: $(MAKE) --no-print-directory -C $$mod golangci-lint-fix; \ done +.PHONY: test-gherkin-lint +test-gherkin-lint: + gherlint tests/acceptance/features -c tests/acceptance/config/.gherlintrc.json + +.PHONY: test-gherkin-lint-fix +test-gherkin-lint-fix: + gherlint --fix tests/acceptance/features -c tests/acceptance/config/.gherlintrc.json + .PHONY: bingo-update bingo-update: $(BINGO) $(BINGO) get -l -v diff --git a/tests/acceptance/config/.gherlintrc.json b/tests/acceptance/config/.gherlintrc.json new file mode 100644 index 0000000000..b9b0607ceb --- /dev/null +++ b/tests/acceptance/config/.gherlintrc.json @@ -0,0 +1,14 @@ +{ + "rules": { + "indentation": "error", + "no_repetitive_step_keyword": "error", + "require_step": "error", + "no_trailing_whitespace": "error", + "require_scenario": "error", + "no_then_as_first_step": "error", + "only_given_step_in_background": "error", + "newline_before_scenario": ["error", 2, true], + "lowercase_title": "off", + "no_but_in_given_when": "error" + } +}