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

Create plugin: CI workflow improvements #890

Merged
merged 9 commits into from
May 27, 2024
Merged

Conversation

sunker
Copy link
Contributor

@sunker sunker commented Apr 24, 2024

What this PR does / why we need it:
This PR is making a few changes to the e2e related workflow bits:

  • Use the right snippet in the article that walks through how to run e2e tests in ci
  • Not doing a sparse checkout of the repo anymore in the e2e test job. Doing a sparse checkout have little benefits, and may cause confusion when contributors wants to go beyond the basic steps in the workflow. See this thread for example.
  • Adds step that uploads Playwright report to GCS in case org is Grafana. Please note that even though someone were to falsely specify grafana as the org, this step would still not work for them as it requires access to id-tokens that are only available for repos within the grafana org.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

📦 Published PR as canary version: Canary Versions

✨ Test out this PR locally via:

npm install @grafana/create-plugin@4.7.1-canary.890.babb00f.0
npm install @grafana/plugin-e2e@1.1.2-canary.890.babb00f.0
# or 
yarn add @grafana/create-plugin@4.7.1-canary.890.babb00f.0
yarn add @grafana/plugin-e2e@1.1.2-canary.890.babb00f.0

@sunker sunker added patch Increment the patch version when merged release Create a release when this pr is merged labels Apr 24, 2024
Copy link

github-actions bot commented Apr 24, 2024

Hello! 👋 This repository uses Auto for releasing packages using PR labels.

✨ This PR can be merged and will trigger a new patch release.
NOTE: When merging a PR with the release label please avoid merging another PR. For further information see here.

@sunker sunker marked this pull request as ready for review April 24, 2024 13:05
@sunker sunker requested a review from a team as a code owner April 24, 2024 13:05
@sunker sunker requested review from mckn and removed request for a team April 24, 2024 13:05
Copy link
Collaborator

@mckn mckn left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines 16 to 18
{{#if_eq orgName "grafana"}}
id-token: write
{{/if_eq}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure we want to introduce Grafana specific code to create-plugin?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am kind of leaning towards what Jack says, and try to keep this more generic (not introducing internal plugin development related knowledge in the templates).

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess I can see your worries. It is easy it becomes a slippery slope with lots of Grafana internal specific logic added to the template. On the other hand, we are creating lots of pluggins internally so it might be worth having some of this stuff added via the template. I'm a bit torn 🙈

Copy link
Collaborator

Choose a reason for hiding this comment

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

so what is the alternative? Another separate workflow for internal devs?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep my biggest concern here isn't so much this single addition but that we open the door for a community tool to become peppered with our own internal teams "needs". I would vote that we create separate workflows for our internal teams. From what I've gathered they each have their own ideas and would be good to pool those folk together to create something that they can share internally. I'm pretty sure most of them edit/delete this workflow anyhow.

Additionally this template variable is based on user input. If I want my plugin to be called grafana-awesome-panel I might (through trial and error) come to the conclusion that to do that I need to use grafana as the org name when I scaffoled. Eventually I submit my plugin for review and I'm asked to change the org name unaware that my plugin was scaffolded with specifics used by Grafanas own plugin teams.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I agree adding Grafana specific code here is not ideal. I'm happy to move this to Braintank or wiki.


{{#if_eq orgName "grafana"}}
# Repos in the grafana Github org can publish the report to GCS so that they can be browsed without having to download them.
# This will make the report public on the Internet, so beware to skip this step if the report contains sensitive information.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What sort of sensitive information could this expose? Could having it as a default be rather risky?

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, I'm starting to think that a better approach would be to upload artifacts to github instead (if we want to enable this functionality). Then it would work for all users regarding if it is within the grafana org or not.

Copy link
Collaborator

Choose a reason for hiding this comment

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

uploading to github would not give you a possibility to link to it - you would have to download the report artifact in a zip file and run npx playwright show-report

uploading to GCS gives you a way to share a link with someone who doesnt want to download unzip and run report locally - so kind of a convenience feature.

Example: grafana/grafana#86835 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

What sort of sensitive information could this expose? Could having it as a default be rather risky?

Same as any e2e test report more or less - it contains your browser state, screenshots of the execution, etc. and if you have something sensitive in there it will be in the report. Since it is quite impossible to automatically know about what could theoretically be sensitive on the screen there is no automated solution to this - microsoft/playwright#19992

Hence the guidance in the comments above the action - if you are for some reason using real credentials or have sensitive information in the flow - you have to handle it yourself or not publish it to a public bucket. For most of the plugin devs in grafana org that are just testing with mocks and dummy data it is absolutely fine and even more convenient to share reports via GCS Bucket / URL (same as we do in grafana/grafana).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, and the same security concern applies when uploading artifacts to GH as the report becomes public on the Internet. Playwright docs have example workflows where reports are being uploaded to GH artifacts, bit they don't mention security concerns.

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 rather safe than sorry - let's comment out the upload artifacts step.

Comment on lines 16 to 18
{{#if_eq orgName "grafana"}}
id-token: write
{{/if_eq}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am kind of leaning towards what Jack says, and try to keep this more generic (not introducing internal plugin development related knowledge in the templates).

@sunker
Copy link
Contributor Author

sunker commented May 22, 2024

Thanks for the review folks. Have removed the grafana specific bits and commented out the report uploading step (see this commit). Let me know what you think.

@sunker sunker merged commit dc2ba55 into main May 27, 2024
13 checks passed
@sunker sunker deleted the create-plugin/fix-ci-workflow branch May 27, 2024 05:40
@grafana-plugins-platform-bot
Copy link

🚀 PR was released in @grafana/create-plugin@4.10.6 🚀

@grafana-plugins-platform-bot grafana-plugins-platform-bot bot added the released This issue/pull request has been released. label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged release Create a release when this pr is merged released This issue/pull request has been released.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

5 participants