Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX-2042: Ensure that includes are used where possible #1714

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

asbjornu
Copy link
Contributor

@asbjornu asbjornu commented Feb 8, 2023

In this PR, some effort has been made to create an RSpec which ensures that where we have includes, they are used. The spec works as following:

  1. Find all field and event includes and map them to their corresponding JSON and JavaScript fields.
  2. For each line in every .md file in the portal, find all lines that look like a table row.
  3. For each table row line, check whether a field from step 1 is found.
  4. If a field is found, see whether the line contains the corresponding include file.
  5. If an include is not found on the line, create a GitHub code review comment to the pull request.
  6. If creating a code review comment fails, make a regular RSpec assertion, failing the test suite.

The spec mostly works, but needs tweaking to exclude false positives where there is a match on the field but the corresponding include is for a similarly named field in another request or response model. The creation of the GitHub code review also fails, due to the following error:

POST https://api.github.com/repos/SwedbankPay/developer.swedbankpay.com/pulls/1711/reviews: 422 - Unprocessable Entity
Error summary: Pull request review thread position is invalid and Pull request review thread diff hunk can't be blank // See: https://docs.github.com/rest/reference/pulls#create-a-review-for-a-pull-request

@probot-autolabeler probot-autolabeler bot added config development documentation Improvements or additions to documentation labels Feb 8, 2023
@asbjornu asbjornu force-pushed the feature/dx-2042_include_spec branch from 6440957 to 1fc2448 Compare February 10, 2023 23:03
Add a spec that ensures includes are used where possible, using Octokit
to post code review comments to files that should be using an include,
but doesn't.
@asbjornu asbjornu force-pushed the feature/dx-2042_include_spec branch from 1fc2448 to 29aec90 Compare February 13, 2023 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config development documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant