Skip to content

feat: add Generator to edge functions #2019

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

Merged
merged 38 commits into from
Apr 19, 2023
Merged

feat: add Generator to edge functions #2019

merged 38 commits into from
Apr 19, 2023

Conversation

taty2010
Copy link
Contributor

@taty2010 taty2010 commented Mar 28, 2023

Summary

This PR inputs the runtime version into the new generator field within edge-functions to aid in observability.

Test plan

  1. Visit the Deploy Preview (insert link to specific page) ...

Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal

Standard checks:

  • Check the Deploy Preview's Demo site for your PR's functionality
  • Add docs when necessary

🧪 Once merged, make sure to update the version if needed and that it was published correctly.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
🔨 Latest commit bc9dae5
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/64400ed826391c0008477beb
😎 Deploy Preview https://deploy-preview-2019--netlify-plugin-nextjs-static-root-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!

Name Link
🔨 Latest commit bc9dae5
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/64400ed8e25cc3000771deb0
😎 Deploy Preview https://deploy-preview-2019--netlify-plugin-nextjs-nx-monorepo-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
🔨 Latest commit bc9dae5
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/64400ed8bbce660008ace904
😎 Deploy Preview https://deploy-preview-2019--netlify-plugin-nextjs-export-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Mar 28, 2023
@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
🔨 Latest commit a522350
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/642320de6beedb0007fdaea2
😎 Deploy Preview https://deploy-preview-2019--next-plugin-edge-middleware.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit a522350
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/642320de7343680008a885df
😎 Deploy Preview https://deploy-preview-2019--next-plugin-canary.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
🔨 Latest commit a522350
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/642320de0c282c00081a8a0c
😎 Deploy Preview https://deploy-preview-2019--netlify-plugin-nextjs-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
🔨 Latest commit a522350
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/642320dee4fef3000804f010
😎 Deploy Preview https://deploy-preview-2019--nextjs-plugin-custom-routes-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit a522350
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/642320de6809910008399006
😎 Deploy Preview https://deploy-preview-2019--next-i18next-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit a522350
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/642320deefb1a20008267b85
😎 Deploy Preview https://deploy-preview-2019--netlify-plugin-nextjs-next-auth-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit bc9dae5
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/64400ed84e501e00086dace4
😎 Deploy Preview https://deploy-preview-2019--next-i18next-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit bc9dae5
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/64400ed84e33f90008cd4e63
😎 Deploy Preview https://deploy-preview-2019--next-plugin-canary.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
🔨 Latest commit bc9dae5
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/64400ed8fe4403000893d54a
😎 Deploy Preview https://deploy-preview-2019--next-plugin-edge-middleware.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit bc9dae5
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/64400ed8aa285f0008e3f0ca
😎 Deploy Preview https://deploy-preview-2019--netlify-plugin-nextjs-next-auth-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
🔨 Latest commit bc9dae5
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/64400ed8bb54130008568923
😎 Deploy Preview https://deploy-preview-2019--nextjs-plugin-custom-routes-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented Mar 28, 2023

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
🔨 Latest commit bc9dae5
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/64400ed837bf160008d38cca
😎 Deploy Preview https://deploy-preview-2019--netlify-plugin-nextjs-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@taty2010 taty2010 marked this pull request as ready for review April 3, 2023 14:52
@taty2010 taty2010 requested a review from a team April 3, 2023 14:52
Copy link

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

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

This is looking great! Left some comments and change requests.

Copy link

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

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

Forgot to mark this as Request changes

@taty2010
Copy link
Contributor Author

Ended up having to sort the manifest data so that the snapshots would match.

Copy link

@LekoArts LekoArts left a comment

Choose a reason for hiding this comment

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

Some smaller comments, not blocking

Copy link

@LekoArts LekoArts left a comment

Choose a reason for hiding this comment

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

const manifestPath = await readJson(path.resolve('.netlify/edge-functions/manifest.json'))
const manifest = manifestPath.functions.sort()

expect(manifest).toMatchSnapshot()
Copy link

@LekoArts LekoArts Apr 18, 2023

Choose a reason for hiding this comment

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

I think we're overusing snapshots in most of our tests, for me it's typically the last resort.

I'd use this instead:

expect(manifest).toEqual(
  expect.arrayContaining([
    expect.objectContaining({
      generator: '@netlify/[email protected]'
    })
  ])
)

This way it's instantly clear what we want to assert + you don't have to look at a snapshot file + you don't need to worry about other properties on the objects (which should be tested somewhere already)

Applies also to the test below.

You then can also drop the sort() as the order is not relevant anymore.

Some reading: https://www.emgoto.com/jest-partial-match/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is really helpful, thanks Lennart!!

@taty2010 taty2010 requested a review from nickytonline April 19, 2023 16:25
Copy link

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

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

:shipit:

@kodiakhq kodiakhq bot merged commit b341938 into main Apr 19, 2023
@kodiakhq kodiakhq bot deleted the tn/generator-edgeFunc branch April 19, 2023 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants