You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Cloudflare Workers testing to GitHub Actions matrix
- Add comprehensive CI workflow with Cloudflare Workers testing
- Add dedicated Cloudflare Workers test workflow
- Include edge environment testing with memory constraints
- Add health check endpoint to worker example
- Create test script for Cloudflare Workers compatibility
- Test both CommonJS and ESM builds in Workers environment
- Add documentation for setting up Cloudflare Workers testing
This addresses issues that may only occur in Cloudflare Node.js compact environments by ensuring the SDK is tested in those specific conditions.
This directory contains GitHub Actions workflows for testing the Nylas Node.js SDK in various environments, including Cloudflare Workers.
4
+
5
+
## Workflows
6
+
7
+
### `ci.yml`
8
+
Comprehensive CI workflow that tests the SDK across:
9
+
- Multiple Node.js versions (16, 18, 20, 22)
10
+
- Cloudflare Workers environment
11
+
- Edge-like environments with memory constraints
12
+
- Different module formats (CommonJS, ESM, CJS wrapper)
13
+
- Security audits
14
+
15
+
### `cloudflare-workers-test.yml`
16
+
Focused workflow for testing Cloudflare Workers compatibility:
17
+
- Tests SDK in Cloudflare Workers environment
18
+
- Validates optional types work correctly
19
+
- Tests both CommonJS and ESM builds
20
+
- Optional deployment testing (requires secrets)
21
+
22
+
## Cloudflare Workers Testing Setup
23
+
24
+
### Required Secrets
25
+
26
+
To enable full Cloudflare Workers testing (including deployment), add these secrets to your GitHub repository:
27
+
28
+
1.**CLOUDFLARE_API_TOKEN**: Your Cloudflare API token
29
+
- Go to [Cloudflare Dashboard](https://dash.cloudflare.com/) → My Profile → API Tokens
30
+
- Create a token with "Edit Cloudflare Workers" permissions
31
+
- Copy the token value
32
+
33
+
2.**CLOUDFLARE_ACCOUNT_ID**: Your Cloudflare account ID
34
+
- Find this in your Cloudflare dashboard under "Overview"
35
+
36
+
### Setting Up Secrets
37
+
38
+
1. Go to your GitHub repository
39
+
2. Navigate to Settings → Secrets and variables → Actions
40
+
3. Click "New repository secret"
41
+
4. Add both `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID`
42
+
43
+
### Testing Without Secrets
44
+
45
+
The workflows will still run and test Cloudflare Workers compatibility even without these secrets. The deployment step will be skipped, but all local testing will still occur.
46
+
47
+
### Local Testing
48
+
49
+
You can also test Cloudflare Workers compatibility locally:
50
+
51
+
```bash
52
+
# Install dependencies
53
+
npm ci
54
+
55
+
# Build the SDK
56
+
npm run build
57
+
58
+
# Test in the edge environment
59
+
cd examples/edge-environment
60
+
npm install
61
+
npm run dev # Start local development server
62
+
```
63
+
64
+
## What Gets Tested
65
+
66
+
### Cloudflare Workers Environment
67
+
- SDK can be imported in Cloudflare Workers context
68
+
- Optional types work correctly (no TypeScript errors)
69
+
- Both CommonJS and ESM builds are compatible
70
+
- Client creation works without errors
71
+
- Memory constraints are handled properly
72
+
73
+
### Edge-like Environments
74
+
- Tests with reduced memory limits (64MB, 128MB)
75
+
- Optimized Node.js settings for compact environments
76
+
- Verifies SDK works in constrained environments
77
+
78
+
### Module Format Compatibility
79
+
- CommonJS (`require()`)
80
+
- ESM (`import`)
81
+
- CJS wrapper for better compatibility
82
+
83
+
## Troubleshooting
84
+
85
+
### Common Issues
86
+
87
+
1.**Worker deployment fails**: Check that your Cloudflare API token has the correct permissions
88
+
2.**Type errors in Workers**: Ensure optional types are properly defined in the SDK
89
+
3.**Memory issues**: The edge environment tests help identify memory-related problems
90
+
91
+
### Debugging
92
+
93
+
- Check the workflow logs for specific error messages
94
+
- Test locally using the edge environment example
95
+
- Verify your Cloudflare account has Workers enabled
0 commit comments