Skip to content

Commit f1e3709

Browse files
authored
Merge branch 'main' into fix/eslint-v10-get-source-code
2 parents d3523ba + 6fd8106 commit f1e3709

File tree

23 files changed

+756
-50
lines changed

23 files changed

+756
-50
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build
22

33
on:
44
push:
5-
branches: ["main"]
5+
branches: ["main", "v1.x"]
66
pull_request:
7-
branches: ["main"]
7+
branches: ["main", "v1.x"]
88

99
permissions:
1010
contents: read # This is required for actions/checkout
@@ -64,6 +64,8 @@ jobs:
6464

6565
integration-tests:
6666
needs: build
67+
# Skip integration tests for PRs from forked repos (no access to secrets)
68+
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
6769
permissions:
6870
contents: read
6971
id-token: write

docs/FORKED_PR_REVIEW_GUIDE.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Handling Pull Requests from Forked Repositories
2+
3+
This guide outlines the process for reviewing and testing PRs from forked repositories, which require special handling due to security restrictions.
4+
5+
## Security Considerations
6+
7+
⚠️ **CRITICAL: Security Review Required**
8+
9+
Before approving any workflows for forked PRs, carefully review the code changes for:
10+
11+
- **Secret exposure attempts**: Code that tries to print, log, or transmit environment variables, secrets, or credentials
12+
- **Malicious network requests**: Unauthorized API calls or data exfiltration attempts
13+
- **File system access**: Attempts to read sensitive files or configuration
14+
- **Process execution**: Suspicious shell commands or script execution
15+
- **Dependency injection**: New dependencies that could contain malicious code
16+
17+
**Never approve workflows without thorough code review first.**
18+
19+
## Review Process
20+
21+
### 1. Code Security Review
22+
23+
1. Carefully examine all changed files
24+
2. Look for any attempts to access `process.env`, `secrets.*`, or `vars.*`
25+
3. Check for suspicious network requests or file operations
26+
4. Verify new dependencies are legitimate and necessary
27+
5. Ensure no code attempts to expose or steal secrets
28+
29+
### 2. Approve Unit Tests
30+
31+
Once security review is complete:
32+
33+
1. Go to the PR's "Checks" tab
34+
2. Click "Approve and run" for unit tests only
35+
3. Wait for unit tests to pass before proceeding
36+
37+
### 3. Run Integration Tests Locally
38+
39+
Since integration tests are automatically skipped for forked PRs (they require AWS secrets), you must run them locally.
40+
41+
#### Prerequisites
42+
43+
```bash
44+
# Install dependencies
45+
npm ci
46+
47+
# Build the project
48+
npm run build
49+
```
50+
51+
#### AWS Setup
52+
53+
Configure AWS credentials with permissions for:
54+
55+
- Lambda functions (create, invoke, delete)
56+
- CloudWatch Logs (create, delete log groups)
57+
- IAM role for Lambda execution
58+
59+
```bash
60+
# Option 1: AWS CLI
61+
aws configure
62+
63+
# Option 2: Environment variables
64+
export AWS_ACCESS_KEY_ID=your_key
65+
export AWS_SECRET_ACCESS_KEY=your_secret
66+
export AWS_REGION=us-east-1
67+
```
68+
69+
#### Pull and Test the PR
70+
71+
```bash
72+
# Fetch the PR branch
73+
git fetch origin pull/PR_NUMBER/head:pr-branch-name
74+
git checkout pr-branch-name
75+
76+
# Rebuild with PR changes
77+
npm run build
78+
79+
# Run integration tests
80+
node .github/workflows/scripts/integration-test/integration-test.js --runtime 22.x
81+
82+
# Or run step by step:
83+
# 1. Deploy functions
84+
node .github/workflows/scripts/integration-test/integration-test.js --deploy-only --runtime 22.x
85+
86+
# 2. Run tests
87+
node .github/workflows/scripts/integration-test/integration-test.js --test-only --runtime 22.x
88+
89+
# 3. Cleanup (important!)
90+
node .github/workflows/scripts/integration-test/integration-test.js --cleanup-only --runtime 22.x
91+
```
92+
93+
#### Alternative: Examples Package Tests
94+
95+
```bash
96+
cd packages/aws-durable-execution-sdk-js-examples
97+
npm run test:integration
98+
```
99+
100+
### 4. Approval Decision
101+
102+
Only approve the PR if:
103+
104+
- ✅ Security review passed (no malicious code)
105+
- ✅ Unit tests passed
106+
- ✅ Integration tests passed locally
107+
- ✅ Code quality meets project standards
108+
109+
## Why This Process Exists
110+
111+
GitHub Actions automatically restricts access to repository secrets for PRs from forked repositories. This prevents:
112+
113+
- Malicious actors from accessing AWS credentials
114+
- Accidental exposure of sensitive information
115+
- Unauthorized resource usage
116+
117+
Our CI automatically skips integration tests for forked PRs using this condition:
118+
119+
```yaml
120+
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
121+
```

packages/aws-durable-execution-sdk-js-examples/scripts/deploy-lambda.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ async function createFunction(
305305
LoggingConfig: {
306306
LogGroup: logGroupName,
307307
},
308+
TenancyConfig: exampleConfig.handler.includes("tenant-target")
309+
? { TenantIsolationMode: "PER_TENANT" }
310+
: undefined,
308311
};
309312

310313
const command = new CreateFunctionCommand(createParams);
@@ -365,6 +368,9 @@ async function updateFunction(
365368
},
366369
}
367370
: undefined,
371+
TenancyConfig: exampleConfig.handler.includes("tenant-target")
372+
? { TenantIsolationMode: "PER_TENANT" }
373+
: undefined,
368374
};
369375

370376
// Check if DurableConfig needs updating
@@ -479,12 +485,25 @@ async function main(): Promise<void> {
479485
functionExists = false;
480486
}
481487

488+
// Check if tenancy configuration needs to change
489+
const needsTenancy = exampleConfig.handler.includes("tenant-target");
490+
const hasTenancy = !!currentConfig.TenancyConfig;
491+
if (needsTenancy !== hasTenancy) {
492+
console.log(
493+
"Deleting function since tenancy configuration changed",
494+
);
495+
functionExists = false;
496+
}
497+
482498
if (!functionExists) {
483499
await lambdaClient.send(
484500
new DeleteFunctionCommand({
485501
FunctionName: functionName,
486502
}),
487503
);
504+
// Wait for function to be fully deleted
505+
console.log("Waiting for function deletion to complete...");
506+
await new Promise((resolve) => setTimeout(resolve, 5000));
488507
}
489508
}
490509

0 commit comments

Comments
 (0)