@quiltdata/benchling-webhook 0.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +226 -0
- package/CHANGELOG.md +91 -0
- package/LICENSE +201 -0
- package/README.benchling.md +77 -0
- package/README.md +53 -0
- package/bin/benchling-webhook.ts +172 -0
- package/bin/check-logs.js +231 -0
- package/bin/cli-auth.sh +74 -0
- package/bin/get-env.js +564 -0
- package/bin/publish-manual.js +211 -0
- package/bin/release-notes.sh +82 -0
- package/bin/release.js +118 -0
- package/bin/send-event.js +203 -0
- package/bin/sync-version.js +72 -0
- package/bin/test-invalid-signature.js +125 -0
- package/bin/version.js +178 -0
- package/cdk.context.json +58 -0
- package/cdk.json +85 -0
- package/doc/NPM_OIDC_SETUP.md +95 -0
- package/doc/PARAMETERS.md +203 -0
- package/doc/RELEASE.md +297 -0
- package/doc/RELEASE_NOTES.md +64 -0
- package/env.template +67 -0
- package/jest.config.js +14 -0
- package/lib/README.md +50 -0
- package/lib/index.ts +31 -0
- package/lib/oauth-tester.json +35 -0
- package/package.json +79 -0
- package/tsconfig.json +34 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# CloudFormation Parameters
|
|
2
|
+
|
|
3
|
+
This stack supports runtime-configurable parameters that can be updated without redeploying the entire stack.
|
|
4
|
+
|
|
5
|
+
## Available Parameters
|
|
6
|
+
|
|
7
|
+
### Security and Configuration
|
|
8
|
+
|
|
9
|
+
#### WebhookAllowList
|
|
10
|
+
|
|
11
|
+
- **Type**: String (comma-separated IP addresses)
|
|
12
|
+
- **Description**: List of IP addresses allowed to send webhooks
|
|
13
|
+
- **Default**: Value from `WEBHOOK_ALLOW_LIST` environment variable (or empty to allow all IPs)
|
|
14
|
+
- **Example**: `34.216.192.90,34.217.183.162`
|
|
15
|
+
|
|
16
|
+
#### QuiltCatalog
|
|
17
|
+
|
|
18
|
+
- **Type**: String
|
|
19
|
+
- **Description**: Quilt catalog URL for package links
|
|
20
|
+
- **Default**: `open.quiltdata.com`
|
|
21
|
+
- **Example**: `catalog.example.com`
|
|
22
|
+
|
|
23
|
+
### Infrastructure Parameters
|
|
24
|
+
|
|
25
|
+
#### BucketName
|
|
26
|
+
|
|
27
|
+
- **Type**: String
|
|
28
|
+
- **Description**: S3 bucket name for storing packages (your data bucket)
|
|
29
|
+
- **Default**: Value from `QUILT_USER_BUCKET` environment variable
|
|
30
|
+
- **Example**: `my-packages-bucket`
|
|
31
|
+
|
|
32
|
+
#### PackagePrefix
|
|
33
|
+
|
|
34
|
+
- **Type**: String
|
|
35
|
+
- **Description**: Prefix for package names (no slashes allowed)
|
|
36
|
+
- **Default**: Value from `PREFIX` environment variable
|
|
37
|
+
- **Example**: `benchling` or `my-org`
|
|
38
|
+
|
|
39
|
+
#### QueueName
|
|
40
|
+
|
|
41
|
+
- **Type**: String
|
|
42
|
+
- **Description**: SQS queue name for package notifications
|
|
43
|
+
- **Default**: Value from `QUEUE_NAME` environment variable
|
|
44
|
+
- **Example**: `my-packager-queue`
|
|
45
|
+
|
|
46
|
+
**Note**: Benchling credentials (CLIENT_ID, CLIENT_SECRET, TENANT) are **not** parameters because they're used to create AWS resources at deployment time and contain sensitive information.
|
|
47
|
+
|
|
48
|
+
## Updating Parameters
|
|
49
|
+
|
|
50
|
+
### Using AWS CLI
|
|
51
|
+
|
|
52
|
+
Update parameters without redeploying the stack:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Update webhook allow list only
|
|
56
|
+
aws cloudformation update-stack \
|
|
57
|
+
--stack-name BenchlingWebhookStack \
|
|
58
|
+
--use-previous-template \
|
|
59
|
+
--parameters \
|
|
60
|
+
ParameterKey=WebhookAllowList,ParameterValue="1.2.3.4,5.6.7.8" \
|
|
61
|
+
ParameterKey=QuiltCatalog,UsePreviousValue=true \
|
|
62
|
+
ParameterKey=BucketName,UsePreviousValue=true \
|
|
63
|
+
ParameterKey=PackagePrefix,UsePreviousValue=true \
|
|
64
|
+
ParameterKey=QueueName,UsePreviousValue=true
|
|
65
|
+
|
|
66
|
+
# Update multiple parameters
|
|
67
|
+
aws cloudformation update-stack \
|
|
68
|
+
--stack-name BenchlingWebhookStack \
|
|
69
|
+
--use-previous-template \
|
|
70
|
+
--parameters \
|
|
71
|
+
ParameterKey=WebhookAllowList,ParameterValue="34.216.192.90,34.217.183.162" \
|
|
72
|
+
ParameterKey=QuiltCatalog,ParameterValue="my-catalog.quiltdata.com" \
|
|
73
|
+
ParameterKey=BucketName,ParameterValue="new-bucket-name" \
|
|
74
|
+
ParameterKey=PackagePrefix,UsePreviousValue=true \
|
|
75
|
+
ParameterKey=QueueName,UsePreviousValue=true
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Using AWS Console
|
|
79
|
+
|
|
80
|
+
1. Go to CloudFormation in AWS Console
|
|
81
|
+
2. Select the `BenchlingWebhookStack` stack
|
|
82
|
+
3. Click **Update**
|
|
83
|
+
4. Select **Use current template**
|
|
84
|
+
5. Click **Next**
|
|
85
|
+
6. Update the parameter values as needed:
|
|
86
|
+
- **WebhookAllowList**: Comma-separated IP addresses
|
|
87
|
+
- **QuiltCatalog**: Catalog URL
|
|
88
|
+
- **BucketName**: S3 bucket name
|
|
89
|
+
- **PackagePrefix**: Package prefix
|
|
90
|
+
- **QueueName**: SQS queue name
|
|
91
|
+
7. Click **Next** through the remaining screens
|
|
92
|
+
8. Click **Update stack**
|
|
93
|
+
|
|
94
|
+
### Using CDK
|
|
95
|
+
|
|
96
|
+
Parameters are automatically created during CDK deployment. The initial values come from environment variables, but subsequent updates can be done via CloudFormation (as shown above) without redeploying via CDK.
|
|
97
|
+
|
|
98
|
+
## Benefits
|
|
99
|
+
|
|
100
|
+
- **No Code Deployment**: Update security settings (IP allowlist) without redeploying code
|
|
101
|
+
- **Fast Updates**: CloudFormation parameter updates are much faster than full stack updates
|
|
102
|
+
- **Zero Downtime**: Parameter updates don't require Lambda redeployment
|
|
103
|
+
- **Audit Trail**: All parameter changes are tracked in CloudFormation change sets
|
|
104
|
+
|
|
105
|
+
## Implementation Details
|
|
106
|
+
|
|
107
|
+
### Architecture
|
|
108
|
+
|
|
109
|
+
1. **CloudFormation Parameters**: Defined at stack level
|
|
110
|
+
2. **Lambda Environment Variables**: Automatically updated from parameters
|
|
111
|
+
3. **API Gateway Resource Policy**: Automatically updated from parameters
|
|
112
|
+
|
|
113
|
+
### How It Works
|
|
114
|
+
|
|
115
|
+
The stack uses a hybrid approach:
|
|
116
|
+
|
|
117
|
+
- **Initial Deployment**: Uses environment variable values from `bin/benchling-webhook.ts`
|
|
118
|
+
- **Subsequent Updates**: Uses CloudFormation parameter values
|
|
119
|
+
- **Lambda Environment**: Automatically reflects parameter changes via CloudFormation
|
|
120
|
+
|
|
121
|
+
When you update a parameter via CloudFormation:
|
|
122
|
+
|
|
123
|
+
1. CloudFormation updates the Lambda function's environment variables
|
|
124
|
+
2. CloudFormation updates the API Gateway Resource Policy
|
|
125
|
+
3. Lambda automatically picks up the new values on next invocation (no cold start required)
|
|
126
|
+
4. API Gateway immediately enforces the new IP allowlist
|
|
127
|
+
|
|
128
|
+
## Examples
|
|
129
|
+
|
|
130
|
+
### Add a new IP to the allowlist
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Current IPs: 34.216.192.90,34.217.183.162
|
|
134
|
+
# Adding new IP: 203.0.113.10
|
|
135
|
+
|
|
136
|
+
aws cloudformation update-stack \
|
|
137
|
+
--stack-name BenchlingWebhookStack \
|
|
138
|
+
--use-previous-template \
|
|
139
|
+
--parameters \
|
|
140
|
+
ParameterKey=WebhookAllowList,ParameterValue="34.216.192.90,34.217.183.162,203.0.113.10" \
|
|
141
|
+
ParameterKey=QuiltCatalog,UsePreviousValue=true \
|
|
142
|
+
ParameterKey=BucketName,UsePreviousValue=true \
|
|
143
|
+
ParameterKey=PackagePrefix,UsePreviousValue=true \
|
|
144
|
+
ParameterKey=QueueName,UsePreviousValue=true
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Switch to a different S3 bucket
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
aws cloudformation update-stack \
|
|
151
|
+
--stack-name BenchlingWebhookStack \
|
|
152
|
+
--use-previous-template \
|
|
153
|
+
--parameters \
|
|
154
|
+
ParameterKey=WebhookAllowList,UsePreviousValue=true \
|
|
155
|
+
ParameterKey=QuiltCatalog,UsePreviousValue=true \
|
|
156
|
+
ParameterKey=BucketName,ParameterValue="new-packages-bucket" \
|
|
157
|
+
ParameterKey=PackagePrefix,UsePreviousValue=true \
|
|
158
|
+
ParameterKey=QueueName,UsePreviousValue=true
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Change package prefix
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
aws cloudformation update-stack \
|
|
165
|
+
--stack-name BenchlingWebhookStack \
|
|
166
|
+
--use-previous-template \
|
|
167
|
+
--parameters \
|
|
168
|
+
ParameterKey=WebhookAllowList,UsePreviousValue=true \
|
|
169
|
+
ParameterKey=QuiltCatalog,UsePreviousValue=true \
|
|
170
|
+
ParameterKey=BucketName,UsePreviousValue=true \
|
|
171
|
+
ParameterKey=PackagePrefix,ParameterValue="my-new-prefix" \
|
|
172
|
+
ParameterKey=QueueName,UsePreviousValue=true
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Allow all IPs (remove IP filtering)
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
aws cloudformation update-stack \
|
|
179
|
+
--stack-name BenchlingWebhookStack \
|
|
180
|
+
--use-previous-template \
|
|
181
|
+
--parameters \
|
|
182
|
+
ParameterKey=WebhookAllowList,ParameterValue="" \
|
|
183
|
+
ParameterKey=QuiltCatalog,UsePreviousValue=true \
|
|
184
|
+
ParameterKey=BucketName,UsePreviousValue=true \
|
|
185
|
+
ParameterKey=PackagePrefix,UsePreviousValue=true \
|
|
186
|
+
ParameterKey=QueueName,UsePreviousValue=true
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Troubleshooting
|
|
190
|
+
|
|
191
|
+
### Parameter update fails
|
|
192
|
+
|
|
193
|
+
If the CloudFormation update fails, check:
|
|
194
|
+
|
|
195
|
+
- IP addresses are valid (no spaces, proper CIDR notation if needed)
|
|
196
|
+
- Catalog URL is a valid hostname
|
|
197
|
+
- You're using `--use-previous-template` flag
|
|
198
|
+
|
|
199
|
+
### Changes not taking effect
|
|
200
|
+
|
|
201
|
+
- API Gateway Resource Policy updates are immediate
|
|
202
|
+
- Lambda environment variable updates require the Lambda to be invoked again
|
|
203
|
+
- Check CloudFormation Events tab for update status
|
package/doc/RELEASE.md
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# Release Process
|
|
2
|
+
|
|
3
|
+
This document describes how to create releases for the benchling-webhook project.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The project uses an automated CI/CD pipeline that:
|
|
8
|
+
|
|
9
|
+
1. Runs tests on all pushes and pull requests
|
|
10
|
+
2. Builds and pushes Docker images when tags are created
|
|
11
|
+
3. Creates GitHub releases with auto-generated release notes
|
|
12
|
+
4. Publishes to NPM and GitHub Packages
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
### Create a Development Release (for testing)
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm run version:dev
|
|
20
|
+
# This creates version 0.4.8-dev.0 (or bumps existing dev version)
|
|
21
|
+
# Then push the tag:
|
|
22
|
+
git push origin v0.4.8-dev.0
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Create a Production Release
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# For patch releases (0.4.7 -> 0.4.8)
|
|
29
|
+
npm run version:patch
|
|
30
|
+
|
|
31
|
+
# For minor releases (0.4.7 -> 0.5.0)
|
|
32
|
+
npm run version:minor
|
|
33
|
+
|
|
34
|
+
# For major releases (0.4.7 -> 1.0.0)
|
|
35
|
+
npm run version:major
|
|
36
|
+
|
|
37
|
+
# Then push the tag:
|
|
38
|
+
git push origin v0.4.8
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Detailed Workflow
|
|
42
|
+
|
|
43
|
+
### 1. Prepare Your Release
|
|
44
|
+
|
|
45
|
+
Before creating a release:
|
|
46
|
+
|
|
47
|
+
1. **Ensure all changes are committed and pushed**
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
git status # Should show "nothing to commit, working tree clean"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
2. **Update CHANGELOG.md** (optional but recommended)
|
|
54
|
+
|
|
55
|
+
```markdown
|
|
56
|
+
## [0.4.8] - 2025-10-27
|
|
57
|
+
|
|
58
|
+
### Added
|
|
59
|
+
- New feature description
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
- Updated component behavior
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
- Bug fix description
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
3. **Ensure you're on the main branch**
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
git checkout main
|
|
72
|
+
git pull origin main
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 2. Create a Release
|
|
76
|
+
|
|
77
|
+
#### Development Releases (for testing)
|
|
78
|
+
|
|
79
|
+
Development releases are marked as "pre-release" in GitHub and are NOT published to NPM.
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Create a new dev release
|
|
83
|
+
npm run version:dev
|
|
84
|
+
|
|
85
|
+
# Or bump an existing dev release
|
|
86
|
+
npm run version:dev-bump
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
This will:
|
|
90
|
+
|
|
91
|
+
- Update `package.json` with the new version
|
|
92
|
+
- Commit the version change
|
|
93
|
+
- Create a git tag (e.g., `v0.4.8-dev.0`)
|
|
94
|
+
- Show instructions for pushing the tag
|
|
95
|
+
|
|
96
|
+
#### Production Releases
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Choose the appropriate bump type:
|
|
100
|
+
npm run version:patch # For bug fixes (0.4.7 -> 0.4.8)
|
|
101
|
+
npm run version:minor # For new features (0.4.7 -> 0.5.0)
|
|
102
|
+
npm run version:major # For breaking changes (0.4.7 -> 1.0.0)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 3. Push the Tag
|
|
106
|
+
|
|
107
|
+
After creating the tag, push it to trigger the CI/CD pipeline:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
git push origin v0.4.8 # Replace with your actual tag
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 4. Monitor the Release
|
|
114
|
+
|
|
115
|
+
1. **Watch the GitHub Actions workflow**: <https://github.com/quiltdata/benchling-webhook/actions>
|
|
116
|
+
2. **Check the workflow progress**:
|
|
117
|
+
- Test job runs first (Python + Node.js tests)
|
|
118
|
+
- Docker job runs after tests pass (builds and pushes image)
|
|
119
|
+
- Release job creates GitHub release and publishes packages
|
|
120
|
+
|
|
121
|
+
3. **Verify the release**:
|
|
122
|
+
- GitHub Release: <https://github.com/quiltdata/benchling-webhook/releases>
|
|
123
|
+
- Docker Image in ECR: `{account-id}.dkr.ecr.us-east-1.amazonaws.com/quiltdata/benchling:{version}`
|
|
124
|
+
- NPM Package: <https://www.npmjs.com/package/quilt-benchling-webhook>
|
|
125
|
+
- GitHub Package: <https://github.com/quiltdata/benchling-webhook/pkgs/npm/quilt-benchling-webhook>
|
|
126
|
+
|
|
127
|
+
## CI/CD Pipeline Details
|
|
128
|
+
|
|
129
|
+
### Workflow Triggers
|
|
130
|
+
|
|
131
|
+
The CI workflow (`.github/workflows/ci.yaml`) is triggered by:
|
|
132
|
+
|
|
133
|
+
- **Push to main**: Runs tests only
|
|
134
|
+
- **Pull requests**: Runs tests only
|
|
135
|
+
- **Tags matching `v*.*.*`**: Runs tests, builds Docker, creates release
|
|
136
|
+
- **Tags matching `v*.*.*-dev.*`**: Same as above, but marks as pre-release
|
|
137
|
+
|
|
138
|
+
### Jobs
|
|
139
|
+
|
|
140
|
+
1. **test** (always runs)
|
|
141
|
+
- Sets up Node.js 22 and Python 3.12
|
|
142
|
+
- Installs dependencies
|
|
143
|
+
- Runs Python tests (pytest)
|
|
144
|
+
- Runs Node.js tests (jest)
|
|
145
|
+
- Builds the package
|
|
146
|
+
|
|
147
|
+
2. **docker** (only on tags, after test passes)
|
|
148
|
+
- Builds Docker image using `make push-ci`
|
|
149
|
+
- Pushes to ECR with version tag and `latest` tag
|
|
150
|
+
- Outputs image URI for release notes
|
|
151
|
+
|
|
152
|
+
3. **release** (only on tags, after docker completes)
|
|
153
|
+
- Generates release notes from CHANGELOG.md
|
|
154
|
+
- Creates GitHub release (pre-release for dev tags)
|
|
155
|
+
- Publishes to NPM (production releases only)
|
|
156
|
+
- Publishes to GitHub Packages
|
|
157
|
+
|
|
158
|
+
## Version Management Script
|
|
159
|
+
|
|
160
|
+
The `bin/version.js` script handles version bumping and tagging:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# View current version and help
|
|
164
|
+
npm run release
|
|
165
|
+
|
|
166
|
+
# Bump versions
|
|
167
|
+
npm run version:major # 0.4.7 -> 1.0.0
|
|
168
|
+
npm run version:minor # 0.4.7 -> 0.5.0
|
|
169
|
+
npm run version:patch # 0.4.7 -> 0.4.8
|
|
170
|
+
npm run version:dev # 0.4.7 -> 0.4.8-dev.0 or 0.4.8-dev.0 -> 0.4.8-dev.1
|
|
171
|
+
npm run version:dev-bump # 0.4.8-dev.0 -> 0.4.8-dev.1
|
|
172
|
+
|
|
173
|
+
# Update version without creating tag
|
|
174
|
+
node bin/version.js patch --no-tag
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Docker Images
|
|
178
|
+
|
|
179
|
+
Docker images are automatically built and pushed to ECR with:
|
|
180
|
+
|
|
181
|
+
- Version tag: `quiltdata/benchling:0.4.8`
|
|
182
|
+
- Latest tag: `quiltdata/benchling:latest`
|
|
183
|
+
|
|
184
|
+
To pull and run:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
docker pull {account-id}.dkr.ecr.us-east-1.amazonaws.com/quiltdata/benchling:0.4.8
|
|
188
|
+
docker run -p 5000:5000 --env-file .env {account-id}.dkr.ecr.us-east-1.amazonaws.com/quiltdata/benchling:0.4.8
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Troubleshooting
|
|
192
|
+
|
|
193
|
+
### Tag already exists
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Delete local tag
|
|
197
|
+
git tag -d v0.4.8
|
|
198
|
+
|
|
199
|
+
# Delete remote tag (if pushed)
|
|
200
|
+
git push origin :refs/tags/v0.4.8
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Workflow failed
|
|
204
|
+
|
|
205
|
+
1. Check the GitHub Actions logs
|
|
206
|
+
2. Common issues:
|
|
207
|
+
- Tests failing: Fix tests and create a new tag
|
|
208
|
+
- Docker build failing: Check `docker/` directory and Makefile
|
|
209
|
+
- AWS credentials: Verify secrets are configured
|
|
210
|
+
- ECR repository doesn't exist: Run `make -C docker docker-ecr-create`
|
|
211
|
+
|
|
212
|
+
### Need to re-release
|
|
213
|
+
|
|
214
|
+
1. Delete the tag (locally and remotely)
|
|
215
|
+
2. Delete the GitHub release
|
|
216
|
+
3. Create a new tag with the same or different version
|
|
217
|
+
|
|
218
|
+
## Manual NPM Publishing
|
|
219
|
+
|
|
220
|
+
In cases where you need to manually publish to NPM (e.g., CI/CD is unavailable, emergency hotfix, or testing), you can use the manual publish script:
|
|
221
|
+
|
|
222
|
+
### Prerequisites
|
|
223
|
+
|
|
224
|
+
1. **NPM Access Token**: You need an NPM access token with publish permissions
|
|
225
|
+
- Visit: <https://www.npmjs.com/settings/[your-username]/tokens>
|
|
226
|
+
- Click "Generate New Token"
|
|
227
|
+
- Choose "Automation" (for CI/CD) or "Publish" (for manual use)
|
|
228
|
+
- Copy the token (it starts with `npm_`)
|
|
229
|
+
|
|
230
|
+
### Usage
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# Test the publish process (dry-run)
|
|
234
|
+
NPM_TOKEN=npm_xxxxx npm run publish:manual -- --dry-run
|
|
235
|
+
|
|
236
|
+
# Publish to NPM
|
|
237
|
+
NPM_TOKEN=npm_xxxxx npm run publish:manual
|
|
238
|
+
|
|
239
|
+
# Publish with a specific dist-tag
|
|
240
|
+
NPM_TOKEN=npm_xxxxx npm run publish:manual -- --tag beta
|
|
241
|
+
|
|
242
|
+
# View help
|
|
243
|
+
npm run publish:manual -- --help
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### How It Works
|
|
247
|
+
|
|
248
|
+
The script:
|
|
249
|
+
1. Validates your NPM token
|
|
250
|
+
2. Checks for uncommitted changes (with confirmation prompt)
|
|
251
|
+
3. Creates a temporary `.npmrc` file with your token
|
|
252
|
+
4. Runs `npm publish --access public`
|
|
253
|
+
5. Cleans up the temporary `.npmrc` file
|
|
254
|
+
6. Restores any existing `.npmrc` backup
|
|
255
|
+
|
|
256
|
+
### Security Notes
|
|
257
|
+
|
|
258
|
+
- The script creates `.npmrc` with restricted permissions (0600)
|
|
259
|
+
- Your token is never committed to git (`.npmrc` is in `.gitignore`)
|
|
260
|
+
- The temporary `.npmrc` is automatically cleaned up, even on errors
|
|
261
|
+
- Always use `--dry-run` first to test before publishing
|
|
262
|
+
|
|
263
|
+
## NPM Scripts Reference
|
|
264
|
+
|
|
265
|
+
| Script | Description |
|
|
266
|
+
|--------|-------------|
|
|
267
|
+
| `npm run release` | Show current version and help |
|
|
268
|
+
| `npm run version:major` | Bump major version (breaking changes) |
|
|
269
|
+
| `npm run version:minor` | Bump minor version (new features) |
|
|
270
|
+
| `npm run version:patch` | Bump patch version (bug fixes) |
|
|
271
|
+
| `npm run version:dev` | Create or bump dev version |
|
|
272
|
+
| `npm run version:dev-bump` | Bump dev counter only |
|
|
273
|
+
| `npm run docker-push` | Build and push Docker image locally |
|
|
274
|
+
| `npm run docker-check` | Validate Docker images in registry |
|
|
275
|
+
| `npm run publish:manual` | Manually publish to NPM using access token |
|
|
276
|
+
|
|
277
|
+
## Best Practices
|
|
278
|
+
|
|
279
|
+
1. **Always test before releasing**: Run `npm test` and manual testing
|
|
280
|
+
2. **Use dev releases for testing**: Test the CI/CD pipeline with dev tags first
|
|
281
|
+
3. **Update CHANGELOG.md**: Document changes before releasing
|
|
282
|
+
4. **Follow semantic versioning**:
|
|
283
|
+
- Major: Breaking changes
|
|
284
|
+
- Minor: New features (backward compatible)
|
|
285
|
+
- Patch: Bug fixes (backward compatible)
|
|
286
|
+
5. **Review the release**: Check GitHub release notes and test the published packages
|
|
287
|
+
6. **Coordinate with team**: Communicate releases in team channels
|
|
288
|
+
|
|
289
|
+
## Migration Notes
|
|
290
|
+
|
|
291
|
+
The previous release process using `bin/create-release.sh` and separate `release.yaml` workflow has been replaced with this integrated CI/CD pipeline. Key changes:
|
|
292
|
+
|
|
293
|
+
- **Single workflow**: All release steps are now in `.github/workflows/ci.yaml`
|
|
294
|
+
- **Automated**: No manual Docker builds or release note creation needed
|
|
295
|
+
- **Tag-based**: Simply push a tag to trigger the release
|
|
296
|
+
- **Pre-release support**: Dev tags are automatically marked as pre-releases
|
|
297
|
+
- **Integrated testing**: Docker images are only built after tests pass
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Benchling Webhook Integration for Quilt
|
|
2
|
+
|
|
3
|
+
Connects Benchling lab notebook entries to Quilt data packages via webhooks.
|
|
4
|
+
|
|
5
|
+
## Quick Install
|
|
6
|
+
|
|
7
|
+
**Prerequisites:** AWS account, Node.js 18+, Docker, existing Quilt deployment
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# 1. Clone and install
|
|
11
|
+
git clone https://github.com/quiltdata/benchling-webhook.git
|
|
12
|
+
cd benchling-webhook
|
|
13
|
+
npm install
|
|
14
|
+
|
|
15
|
+
# 2. Configure (auto-infer from Quilt catalog)
|
|
16
|
+
npm run get-env -- https://quilt-catalog.yourcompany.com --write
|
|
17
|
+
cp env.inferred .env
|
|
18
|
+
# Edit .env to add Benchling credentials
|
|
19
|
+
|
|
20
|
+
# 3. Deploy
|
|
21
|
+
source .env
|
|
22
|
+
npx cdk bootstrap aws://$CDK_DEFAULT_ACCOUNT/$CDK_DEFAULT_REGION # first time only
|
|
23
|
+
npm run deploy
|
|
24
|
+
|
|
25
|
+
# 4. Configure Benchling app
|
|
26
|
+
# - Create app from app-manifest.yaml
|
|
27
|
+
# - Set webhook URL from .env.deploy
|
|
28
|
+
# - Install and activate
|
|
29
|
+
|
|
30
|
+
# 5. Verify
|
|
31
|
+
source .env.deploy
|
|
32
|
+
curl $WEBHOOK_ENDPOINT/health
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
1. Create entry in Benchling
|
|
38
|
+
2. Insert Canvas → "Quilt Integration"
|
|
39
|
+
3. Click "Create" to make package
|
|
40
|
+
4. Add files and click "Update package"
|
|
41
|
+
|
|
42
|
+
## Documentation
|
|
43
|
+
|
|
44
|
+
- [AGENTS.md](AGENTS.md) - Complete deployment guide, architecture, configuration
|
|
45
|
+
- [docker/README.md](docker/README.md) - Development workflows
|
|
46
|
+
- [doc/RELEASE.md](doc/RELEASE.md) - Release process
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
Apache-2.0
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Docker Images (for custom deployments)
|
|
55
|
+
|
|
56
|
+
**Latest Release (v0.4.12):**
|
|
57
|
+
- Production: `public.ecr.aws/quiltdata/benchling:0.4.12`
|
|
58
|
+
- Latest: `public.ecr.aws/quiltdata/benchling:latest`
|
|
59
|
+
|
|
60
|
+
Pull and run:
|
|
61
|
+
```bash
|
|
62
|
+
docker pull public.ecr.aws/quiltdata/benchling:0.4.12
|
|
63
|
+
docker run -p 5000:5000 --env-file .env public.ecr.aws/quiltdata/benchling:0.4.12
|
|
64
|
+
```
|
package/env.template
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# ==============================================================================
|
|
2
|
+
# REQUIRED USER VALUES
|
|
3
|
+
# ==============================================================================
|
|
4
|
+
# These are the ONLY values you need to provide. Everything else is inferred
|
|
5
|
+
# from your Quilt catalog configuration at deployment time.
|
|
6
|
+
|
|
7
|
+
# ==============================================================================
|
|
8
|
+
# Quilt Configuration
|
|
9
|
+
# ==============================================================================
|
|
10
|
+
|
|
11
|
+
# Your Quilt catalog URL (just the domain, without https://)
|
|
12
|
+
QUILT_CATALOG=quilt-catalog.yourcompany.com
|
|
13
|
+
|
|
14
|
+
# The S3 bucket where you want to store Benchling exports
|
|
15
|
+
# This is YOUR data bucket, not the Quilt system buckets
|
|
16
|
+
QUILT_USER_BUCKET=your-data-bucket
|
|
17
|
+
|
|
18
|
+
# ==============================================================================
|
|
19
|
+
# Benchling Configuration
|
|
20
|
+
# ==============================================================================
|
|
21
|
+
# BENCHLING_TENANT: Use XXX if you login to Benchling at XXX.benchling.com
|
|
22
|
+
|
|
23
|
+
BENCHLING_TENANT=your-tenant
|
|
24
|
+
BENCHLING_APP_DEFINITION_ID=appdef_your_id_here
|
|
25
|
+
BENCHLING_CLIENT_ID=your-client-id
|
|
26
|
+
BENCHLING_CLIENT_SECRET=your-client-secret
|
|
27
|
+
|
|
28
|
+
# BENCHLING_API_KEY=your-api-key # not currently used
|
|
29
|
+
|
|
30
|
+
# ==============================================================================
|
|
31
|
+
# OPTIONAL VALUES (Override defaults if needed)
|
|
32
|
+
# ==============================================================================
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# Package Configuration
|
|
36
|
+
PKG_PREFIX=benchling # Prefix for Quilt package names (e.g., "benchling/my-experiment")
|
|
37
|
+
PKG_KEY=experiment_id # Metadata key used to link Benchling entries to packages
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# Webhook Security
|
|
41
|
+
ENABLE_WEBHOOK_VERIFICATION=true # Set to false ONLY for local development
|
|
42
|
+
|
|
43
|
+
# Logging (optional - defaults to INFO)
|
|
44
|
+
# LOG_LEVEL=DEBUG # Options: DEBUG, INFO, WARNING, ERROR, CRITICAL
|
|
45
|
+
|
|
46
|
+
# Test Configuration (for running tests)
|
|
47
|
+
BENCHLING_TEST_ENTRY=etr_123456789
|
|
48
|
+
|
|
49
|
+
# Ngrok Configuration (optional - for local development)
|
|
50
|
+
# Get your authtoken from: https://dashboard.ngrok.com/get-started/your-authtoken
|
|
51
|
+
# NGROK_AUTHTOKEN=your_ngrok_authtoken_here
|
|
52
|
+
# NGROK_DOMAIN=your-subdomain.ngrok-free.app
|
|
53
|
+
|
|
54
|
+
# ==============================================================================
|
|
55
|
+
# AUTOMATICALLY INFERRED VALUES
|
|
56
|
+
# ==============================================================================
|
|
57
|
+
# The following values are automatically inferred from your Quilt catalog
|
|
58
|
+
# at deployment time via bin/get-env.js:
|
|
59
|
+
#
|
|
60
|
+
# - CDK_DEFAULT_ACCOUNT (from AWS STS)
|
|
61
|
+
# - CDK_DEFAULT_REGION (from catalog config)
|
|
62
|
+
# - QUEUE_NAME (from Quilt stack outputs)
|
|
63
|
+
# - SQS_QUEUE_URL (from Quilt stack outputs)
|
|
64
|
+
# - QUILT_DATABASE (from Quilt stack outputs)
|
|
65
|
+
#
|
|
66
|
+
# You do NOT need to set these unless you want to override the inferred values.
|
|
67
|
+
# ==============================================================================
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
testEnvironment: 'node',
|
|
3
|
+
roots: ['<rootDir>/test'],
|
|
4
|
+
testMatch: ['**/*.test.ts'],
|
|
5
|
+
transform: {
|
|
6
|
+
'^.+\\.tsx?$': ['ts-jest', {
|
|
7
|
+
tsconfig: {
|
|
8
|
+
module: 'node20',
|
|
9
|
+
resolveJsonModule: true
|
|
10
|
+
}
|
|
11
|
+
}]
|
|
12
|
+
},
|
|
13
|
+
cacheDirectory: '<rootDir>/.jest-cache'
|
|
14
|
+
};
|
package/lib/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Benchling Webhook Stack Architecture
|
|
2
|
+
|
|
3
|
+
This directory contains the core CDK infrastructure code split across multiple files for better organization:
|
|
4
|
+
|
|
5
|
+
## Core Components
|
|
6
|
+
|
|
7
|
+
### benchling-webhook-stack.ts
|
|
8
|
+
|
|
9
|
+
The main stack file that orchestrates the entire infrastructure. It:
|
|
10
|
+
|
|
11
|
+
- Creates the S3 bucket reference
|
|
12
|
+
- Sets up the Benchling OAuth connection
|
|
13
|
+
- Instantiates the state machine and API gateway
|
|
14
|
+
- Manages stack outputs
|
|
15
|
+
|
|
16
|
+
### state-machine.ts
|
|
17
|
+
|
|
18
|
+
Contains the Step Functions state machine definition that:
|
|
19
|
+
|
|
20
|
+
- Processes incoming webhook events
|
|
21
|
+
- Stores event data in S3
|
|
22
|
+
- Fetches entry details from Benchling API
|
|
23
|
+
- Sends notifications to SQS
|
|
24
|
+
|
|
25
|
+
### api-gateway.ts
|
|
26
|
+
|
|
27
|
+
Handles the API Gateway configuration including:
|
|
28
|
+
|
|
29
|
+
- REST API setup with logging
|
|
30
|
+
- IAM roles and permissions
|
|
31
|
+
- Webhook endpoints for different event types
|
|
32
|
+
- Integration with Step Functions
|
|
33
|
+
|
|
34
|
+
## Flow
|
|
35
|
+
|
|
36
|
+
1. API Gateway receives webhook POST requests
|
|
37
|
+
2. Requests trigger Step Functions execution
|
|
38
|
+
3. State machine:
|
|
39
|
+
- Stores raw event in S3
|
|
40
|
+
- Fetches entry details from Benchling
|
|
41
|
+
- Stores entry data in S3
|
|
42
|
+
- Sends notification to SQS
|
|
43
|
+
|
|
44
|
+
## Key Features
|
|
45
|
+
|
|
46
|
+
- Modular architecture for maintainability
|
|
47
|
+
- Separation of concerns between components
|
|
48
|
+
- Reusable constructs
|
|
49
|
+
- Proper error handling
|
|
50
|
+
- Comprehensive logging
|