Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

fix: support using gherkin-lint args #723

Merged
merged 2 commits into from
Sep 15, 2020
Merged

fix: support using gherkin-lint args #723

merged 2 commits into from
Sep 15, 2020

Conversation

mdelapenya
Copy link
Contributor

@mdelapenya mdelapenya commented Sep 14, 2020

What does this PR do?

We are mapping the existing flags so that we are able to get the arguments passed by a pre-commit hook consumer in the "args" element of its configuration.

We are using positional parameters from shell, shifting when needed. We are building a new array for the files, and the arguments as a string. We will pass the arguments to the docker image.

Why is it important?

The e2e-testing is disabling some configurations, and they are still reported because the hook was not reading the arguments passed by pre-commit in the args element in the configuration (See https://github.com/elastic/e2e-testing/blob/master/.pre-commit-config.yaml#L39)

Related issues

How to test this

To see existing flags

docker run --rm -t -v "$(pwd)":/src -w "/src" gherkin/lint --help
Usage: gherkin_language [files]
    -v, --[no-]verbose               Run verbosely
        --enable [CHECKS]            Enabled checks. Separated by ","
        --disable [CHECKS]           Disabled checks. Separated by ","
    -f, --filepath [file/s]          File path where features are located

Run with a disabled configuration, multiple files

# download a gherkin file
$ curl https://raw.githubusercontent.com/elastic/e2e-testing/master/e2e/_suites/ingest-manager/features/agent_endpoint_integration.feature -o agent_endpoint_integration.feature
# run the checks
$ ./.ci/scripts/gherkin-lint.sh --disable TooLongStep --verbose agent_endpoint_integration.feature agent_endpoint_integration.feature
Running gherkin-lint with arguments: ' --disable TooLongStep --verbose'
TooManyDifferentTags - Used 6 Tags within single Feature
  agent_endpoint_integration.feature (2): Agent Endpoint Integration
ERROR: gherkin-lint failed for the file 'agent_endpoint_integration.feature'. Arguments:  --disable TooLongStep --verbose
TooManyDifferentTags - Used 6 Tags within single Feature
  agent_endpoint_integration.feature (2): Agent Endpoint Integration
ERROR: gherkin-lint failed for the file 'agent_endpoint_integration.feature'. Arguments:  --disable TooLongStep --verbose

Run with success, multiple files

# download a gherkin file
$ curl https://raw.githubusercontent.com/elastic/e2e-testing/master/e2e/_suites/ingest-manager/features/agent_endpoint_integration.feature -o agent_endpoint_integration.feature
# run the checks
$ ./.ci/scripts/gherkin-lint.sh --disable TooManyDifferentTags,TooLongStep --verbose agent_endpoint_integration.feature agent_endpoint_integration.feature
Running gherkin-lint with arguments: ' --disable TooLongStep --verbose'

We are mapping the existing flags so that we are able to get the arguments
passed by a pre-commit hook consumer in the "args" element of its
configuration
@mdelapenya mdelapenya self-assigned this Sep 14, 2020
@mdelapenya mdelapenya requested a review from a team September 14, 2020 17:11

## Iterate for each file without failing fast.
for file in "${files[@]}"; do
# shellcheck disable=SC2086
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm disabling double-quoting the ${arguments} and ${file} variables because otherwise they won't be passed to the docker container properly.

@mdelapenya mdelapenya marked this pull request as ready for review September 14, 2020 17:13
@apmmachine
Copy link
Contributor

apmmachine commented Sep 14, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #723 updated]

  • Start Time: 2020-09-15T09:57:32.562+0000

  • Duration: 8 min 36 sec

Test stats 🧪

Test Results
Failed 0
Passed 771
Skipped 18
Total 789

Steps errors

Expand to view the steps failures

  • Name: Archive JUnit-formatted test results
    • Description: [2020-09-15T10:00:22.592Z] Recording test results
      [2020-09-15T10:00:22.914Z] Failed to read /var/li

    • Duration: 0 min 0 sec

    • Start Time: 2020-09-15T10:00:22.587+0000

    • log

@mdelapenya mdelapenya merged commit 2bdb5d8 into elastic:master Sep 15, 2020
@mdelapenya
Copy link
Contributor Author

We'd need to release a new version of our lovely library ❤️

v1v referenced this pull request in v1v/apm-pipeline-library-backup Sep 15, 2020
* upstream/master:
  Remove folder jobdsl reference (#725)
  docs: update CHANGELOG.md
  [maven-release-plugin] prepare for next development iteration
  [maven-release-plugin] prepare release v1.1.138
  Allow withGoEnv to accept an OS override arg (#724)
  fix: support using gherkin-lint args (#723)
  [test-infra] fix pytests with multimodule (#722)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gherkin-lint pre-commit stage does not support exclussions
5 participants