-
Notifications
You must be signed in to change notification settings - Fork 298
Add CI Tests to prevent environment variable/browser objects in actions-shared and actions-core #3526
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3526 +/- ##
==========================================
+ Coverage 80.01% 80.35% +0.34%
==========================================
Files 1249 1320 +71
Lines 23127 26200 +3073
Branches 4607 5481 +874
==========================================
+ Hits 18505 21054 +2549
- Misses 3760 4257 +497
- Partials 862 889 +27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Tested here in #3527 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request introduces comprehensive automated testing and linting rules to enforce environment-agnostic code in the actions-core and actions-shared packages. The changes add Jest-based tests that recursively scan source files to detect browser-specific globals (window, document, etc.), Node.js-specific globals (process, Buffer, etc.), and unsafe import patterns. Additionally, ESLint rules are configured to prevent these patterns during development.
Changes:
- Added environment-specific code detection tests for actions-core package
- Added environment-specific code detection tests for actions-shared package
- Extended ESLint configuration with restricted globals and imports rules
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 12 comments.
| File | Description |
|---|---|
| packages/core/src/tests/no-environment-specific-code.test.ts | New test suite for detecting browser/Node.js-specific code in actions-core, including checks for globals, imports, and unsafe environment detection patterns |
| packages/actions-shared/src/tests/no-environment-specific-code.test.ts | New test suite for detecting browser/Node.js-specific code in actions-shared, with similar checks but missing the environment detection patterns test |
| .eslintrc.js | Extended ESLint configuration with no-restricted-globals and no-restricted-imports rules for actions-core and actions-shared packages, with specific file exclusions |
packages/core/src/__tests__/no-environment-specific-code.test.ts
Outdated
Show resolved
Hide resolved
packages/actions-shared/src/__tests__/no-environment-specific-code.test.ts
Show resolved
Hide resolved
packages/actions-shared/src/__tests__/no-environment-specific-code.test.ts
Outdated
Show resolved
Hide resolved
packages/actions-shared/src/__tests__/no-environment-specific-code.test.ts
Outdated
Show resolved
Hide resolved
packages/core/src/__tests__/no-environment-specific-code.test.ts
Outdated
Show resolved
Hide resolved
packages/actions-shared/src/__tests__/no-environment-specific-code.test.ts
Outdated
Show resolved
Hide resolved
packages/core/src/__tests__/no-environment-specific-code.test.ts
Outdated
Show resolved
Hide resolved
packages/actions-shared/src/__tests__/no-environment-specific-code.test.ts
Show resolved
Hide resolved
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@itsarijitray I've opened a new pull request, #3537, to work on those changes. Once the pull request is ready, I'll request review from you. |
…ection coverage (#3537) * Initial plan * Address review feedback: improve test consistency and fix comment detection --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

This pull request introduces comprehensive automated tests to ensure that the
actions-sharedandactions-corepackages remain environment-agnostic. The new tests recursively scan source files to detect accidental usage of browser-specific or Node.js-specific globals, as well as unsafe import patterns. This helps maintain cross-environment compatibility and prevents regressions as the codebase evolves.I have written tests and lint rules. However those have some exceptions as there are some pre-existing environment specific code like:
processin isDestinationActionService.ts in actions-shared which is used in actions-personas-messaging-sendgridBufferin MessageSendPerformer.ts in actions-shared which is used in actions-personas-messaging-sendgridprocess, globalThis & events in actions-coreTesting
Include any additional information about the testing you have completed to
ensure your changes behave as expected. For a speedy review, please check
any of the tasks you completed below during your testing.
Security Review
Please ensure sensitive data is properly protected in your integration.
type: 'password'