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

added support for Attachments (aka Embedddings) #623

Merged
merged 14 commits into from
May 28, 2024
Merged

added support for Attachments (aka Embedddings) #623

merged 14 commits into from
May 28, 2024

Conversation

Johnlon
Copy link
Member

@Johnlon Johnlon commented May 8, 2024

🤔 What's changed?

The cucumber and events formatters support the inclusion of Attachments.

The proposed API is demonstrated in the tests as ...

func stepWithAttachment(ctx context.Context) (context.Context, error) {
    ctxOut := godog.Attach(ctx,
	godog.Attachment{Body: []byte("TheData1"), FileName: "TheFilename1", MediaType: "text/plain"},
	godog.Attachment{Body: []byte("TheData2"), FileName: "TheFilename2", MediaType: "text/plain"},
    )

    return ctxOut, nil
}

⚡️ What's your motivation?

#617

Want support for Attachments from steps.
This PR proposes to use the context.Context object as a means to attach content from the step.

🏷️ What kind of change is this?

  • ⚡ New feature (non-breaking change which adds new behaviour)

♻️ Anything particular you want feedback on?

This change involves minimal changes to patterns of use of godog API's.

I added tests for the cuke and events formats but the coverage isn't being recorded even on some lines I didn't modify.

fmt_output_test.go now has a normalise() fn that eliminates some extraneous diffs in the actual/expected files such as line endings and also line numbers so that the tests are easier to maintain and cross platform,

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

Copy link

codecov bot commented May 8, 2024

Codecov Report

Attention: Patch coverage is 88.70968% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 79.69%. Comparing base (153db4e) to head (9de0ee7).
Report is 8 commits behind head on main.

Files Patch % Lines
suite.go 81.25% 5 Missing and 1 partial ⚠️
internal/models/results.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #623      +/-   ##
==========================================
- Coverage   83.21%   79.69%   -3.52%     
==========================================
  Files          28       40      +12     
  Lines        3413     3113     -300     
==========================================
- Hits         2840     2481     -359     
- Misses        458      513      +55     
- Partials      115      119       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Johnlon and others added 9 commits May 16, 2024 17:43
… formats - done by sneaking the attachment into the context.Context object (but not letting that context value propagate into the next step, so it's kinda bending the context.Context purpose)
@mattwynne
Copy link
Member

@Johnlon thanks for this, it looks great!

Are you able to take a look at why the build is failing? It seems to be just some noise from go fmt, maybe your editor has added some whitespace or something?

@mattwynne
Copy link
Member

@Johnlon it would help the other maintainers if you could add an entry to the changelog as part of this PR. You can use this tool if you like, or just copy and adapt other existing entries.

@Johnlon
Copy link
Member Author

Johnlon commented May 27, 2024

@mattwynne thanks - will do.
Still confused by the coverage problems.
Any ideas?
Cheers John

@Johnlon
Copy link
Member Author

Johnlon commented May 27, 2024

@Johnlon thanks for this, it looks great!

Are you able to take a look at why the build is failing? It seems to be just some noise from go fmt, maybe your editor has added some whitespace or something?

At go fmt sorry .
Hmm will see if I can reverse??

@Johnlon Johnlon merged commit 201e526 into cucumber:main May 28, 2024
6 of 7 checks passed
@Johnlon
Copy link
Member Author

Johnlon commented May 28, 2024

@MattWynn Err Matt - I fixed the fmt issue and added the CHANGELOG - but it looks like I also merged to main (which wasn't my intention). Apols - please give it the once over. John

I see a put the CHANGELOG entry in the wrong please - please review this fix - #626

@mattwynne
Copy link
Member

Hey @Johnlon no worries, looks like the build on main is green which is the main thing I was worried about, so all good.

As I said in the other thread, we favour Ship/Show/Ask in the Cucumber org, so feel free to merge your own PRs if you feel you've had enough feedback. Try and do it on purpose though! 😆

@mattwynne
Copy link
Member

I really appreciate the work you've put into this, thanks!

Copy link
Member

@vearutop vearutop left a comment

Choose a reason for hiding this comment

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

Thank you! Sorry, I'm late to the party, but probably we can consider/apply a few changes on top of this PR (with a new PR) before we tag a new version (to avoid backwards compatibility concerns).

internal/formatters/fmt_cucumber.go Show resolved Hide resolved
suite.go Show resolved Hide resolved
internal/models/results.go Show resolved Hide resolved
internal/models/results.go Show resolved Hide resolved
suite.go Show resolved Hide resolved
@Johnlon
Copy link
Member Author

Johnlon commented May 29, 2024

No prob happy to help
How do releases work?
I mean is there some governance or Star chamber who decide?
Or do I DIY here?
Thanks

@iaroslav-ciupin iaroslav-ciupin removed their request for review May 29, 2024 17:04
@mattwynne
Copy link
Member

First things first, before thinking about a release, if you can make another PR with the changes @vearutop has suggested, then we'll have the code in the best shape we can get it.

@Johnlon
Copy link
Member Author

Johnlon commented May 30, 2024

@vearutop Hi - Take a look at my responses to your suggestions.
PR raised here : #628

Johnlon added a commit that referenced this pull request May 30, 2024
… (#628)

* support multiple calls to the Attach() function from a single step

* run_progress_test.go changed so it's not sensitive to the name of the clone target directory

* applied code review comments also added _example/attachments

* applied code review comments also added _example/attachments

* applied code review comments also added _example/attachments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants