Skip to content

Commit

Permalink
Implement gherkin linter in GH action
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Oct 27, 2024
1 parent cf7bfa5 commit 09dcf18
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 1 deletion.
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tests
.distignore
.editorconfig
.eslintrc.js
.gherkin-lintrc
.gitattributes
.gitignore
.nvmrc
Expand Down
26 changes: 26 additions & 0 deletions .gherkin-lintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"indentation": [
"on",
{
"Feature": 0,
"Background": 2,
"Scenario": 2,
"Examples": 4,
"Step": 4,
"given": 4,
"example": 6,
"and": 4
}
],
"no-dupe-feature-names": "on",
"no-dupe-scenario-names": "off",
"no-empty-file": "on",
"no-files-without-scenarios": "on",
"no-multiple-empty-lines": "on",
"no-partially-commented-tag-lines": "on",
"no-trailing-spaces": "on",
"no-unnamed-features": "on",
"no-unnamed-scenarios": "on",
"no-scenario-outlines-without-examples": "on",
"use-and": "on"
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

/.editorconfig export-ignore
/.eslintrc.js export-ignore
/.gherkin-lintrc export-ignore
/.nvmrc export-ignore
/.wp-env.json export-ignore
/composer.lock export-ignore
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/gherkin-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Gherkin Linting

on:
push:
branches:
- trunk
- 'release/**'
# Only run if PHP-related files changed.
paths:
- '.github/workflows/behat-test.yml'
- '**.php'
- '**.feature'
- 'behat.yml'
- 'composer.json'
- 'composer.lock'
pull_request:
branches:
- trunk
- 'release/**'
- 'feature/**'
# Only run if PHP-related files changed.
paths:
- '.github/workflows/behat-test.yml'
- '**.php'
- '**.feature'
- 'behat.yml'
- 'composer.json'
- 'composer.lock'
types:
- opened
- reopened
- synchronize

jobs:
gherkin-lint:
name: Lint Gherkin Feature files
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4

- name: Run lint
run: npx --yes gherkin-lint
3 changes: 2 additions & 1 deletion tests/behat/features/plugin-check.feature
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,8 @@ Feature: Test that the WP-CLI command works.
ExampleRuntimeCheck.ForbiddenScript,WARNING
"""

Scenario: Check custom single file plugin that has no errors or warnings

Scenario: Check custom single file plugin without errors or warnings
Given a WP install with the Plugin Check plugin
And a wp-content/plugins/foo-single.php file:
"""
Expand Down

0 comments on commit 09dcf18

Please sign in to comment.