-
Notifications
You must be signed in to change notification settings - Fork 1
247 lines (208 loc) · 7.96 KB
/
ci.yaml
File metadata and controls
247 lines (208 loc) · 7.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
name: CI
on:
push:
branches:
- main
tags:
- 'v*.*.*'
- 'v*.*.*-dev.*'
pull_request:
branches:
- main
permissions:
contents: write
packages: write
id-token: write # Required for OIDC authentication to npm
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install esbuild
run: npm install -g esbuild
- name: Install Node.js dependencies
run: npm ci
- name: Create temp directory for tests
run: mkdir -p .tmp
- name: Install Python dependencies
working-directory: docker
run: uv sync --all-extras
- name: Run Python tests
working-directory: docker
run: uv run pytest -v -m "not local"
- name: Run Node.js tests
run: npm run test:ci
- name: Upload TypeScript coverage
uses: codecov/codecov-action@v5
with:
files: ./coverage/lcov.info
flags: typescript
name: typescript-coverage
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Build package
run: npm run build
docker:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: test
if: startsWith(github.ref, 'refs/tags/')
outputs:
image_uri: ${{ steps.image.outputs.IMAGE_URI }}
version: ${{ steps.version.outputs.VERSION }}
tag: ${{ steps.version.outputs.TAG }}
is_prerelease: ${{ steps.version.outputs.IS_PRERELEASE }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install Python dependencies
working-directory: docker
run: uv sync --all-extras
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v5
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64
- name: Ensure ECR repository exists
run: |
REPO_NAME="quiltdata/benchling"
if ! aws ecr describe-repositories --repository-names "$REPO_NAME" --region us-east-1 >/dev/null 2>&1; then
echo "Creating ECR repository: $REPO_NAME"
aws ecr create-repository --repository-name "$REPO_NAME" --region us-east-1
else
echo "ECR repository already exists: $REPO_NAME"
fi
- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
TAG=${GITHUB_REF#refs/tags/}
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "TAG=$TAG" >> $GITHUB_OUTPUT
# Check if this is a prerelease (contains timestamp, -dev, -alpha, -beta, -rc)
if [[ "$VERSION" =~ -[0-9]{8}T[0-9]{6}Z$ ]] || [[ "$VERSION" =~ -(dev|alpha|beta|rc) ]]; then
echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT
echo "This is a prerelease: $TAG"
else
echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT
echo "This is a production release: $TAG"
fi
- name: Build and push Docker image
working-directory: docker
run: make push-ci VERSION=${{ steps.version.outputs.VERSION }}
env:
DOCKER_DEFAULT_PLATFORM: linux/amd64
AWS_REGION: us-east-1
- name: Get Docker image URI
id: image
run: |
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
IMAGE_URI="${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/quiltdata/benchling:${{ steps.version.outputs.VERSION }}"
echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_OUTPUT
echo "Docker Image: $IMAGE_URI"
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: docker
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
# No registry-url needed for OIDC publishing
# npm publish --provenance uses OIDC directly without tokens
- name: Install Node.js dependencies
run: npm ci
- name: Generate release notes
id: release_notes
run: |
VERSION="${{ needs.docker.outputs.version }}"
IMAGE_URI="${{ needs.docker.outputs.image_uri }}"
IS_PRERELEASE="${{ needs.docker.outputs.is_prerelease }}"
PACKAGE_NAME=$(jq -r '.name' package.json)
npm run deploy:notes -- "$VERSION" "$IMAGE_URI" "$IS_PRERELEASE" "$PACKAGE_NAME" > /tmp/release_notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ needs.docker.outputs.tag }}
body_path: /tmp/release_notes.md
draft: false
prerelease: ${{ needs.docker.outputs.is_prerelease == 'true' }}
generate_release_notes: true
files: |
docker/app-manifest.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update package.json version for pre-releases
if: needs.docker.outputs.is_prerelease == 'true'
run: |
VERSION="${{ needs.docker.outputs.version }}"
echo "Temporarily updating package.json version to $VERSION for pre-release publish"
jq --arg version "$VERSION" '.version = $version' package.json > package.json.tmp
mv package.json.tmp package.json
echo "Updated version: $(jq -r .version package.json)"
- name: Publish to NPM
run: |
echo "=== NPM Configuration Debug ==="
echo "Registry: $(npm config get registry)"
echo "Package version: $(jq -r .version package.json)"
echo "Checking authentication..."
npm whoami || echo "npm whoami failed"
cat $NPM_CONFIG_USERCONFIG || echo "No .npmrc found"
echo "==============================="
if [ "${{ needs.docker.outputs.is_prerelease }}" == "true" ]; then
echo "Publishing pre-release to npm with 'dev' tag"
npm publish --provenance --access public --tag dev
else
echo "Publishing production release to npm with 'latest' tag"
npm publish --provenance --access public --tag latest
fi
- name: Summary
run: |
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ needs.docker.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "**Type:** ${{ needs.docker.outputs.is_prerelease == 'true' && 'Pre-release' || 'Production Release' }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Docker Image:**" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "${{ needs.docker.outputs.image_uri }}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**NPM Package:** https://www.npmjs.com/package/@quiltdata/benchling-webhook" >> $GITHUB_STEP_SUMMARY