Skip to content

Commit 8827cb9

Browse files
lucacasonatocrowlKatsrymarvinhagemeisterbartlomieju
committed
Initial commit prior to open sourcing
This commit is a squash of all commits in the private repository prior to Feb 28th. The committer stats at this time are as follows: - @lucacasonato: 174 commits - @crowlKats: 110 commits - @ry: 68 commits - @marvinhagemeister: 42 commits - @bartlomieju: 26 commits - @josh-collinsworth: 17 commits - @kwhinnery: 7 commits - @dsherret: 7 commits - @littledivy: 5 commits - @donjo: 4 commits - @kt3k: 1 commit Co-authored-by: Leo Kettmeir <[email protected]> Co-authored-by: Ryan Dahl <[email protected]> Co-authored-by: Marvin Hagemeister <[email protected]> Co-authored-by: Bartek Iwańczuk <[email protected]> Co-authored-by: Josh Collinsworth <[email protected]> Co-authored-by: Kevin Whinnery <[email protected]> Co-authored-by: David Sherret <[email protected]> Co-authored-by: Divy Srivastava <[email protected]> Co-authored-by: John Donmoyer <[email protected]> Co-authored-by: Yoshiya Hinosawa <[email protected]>
0 parents  commit 8827cb9

File tree

494 files changed

+64213
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

494 files changed

+64213
-0
lines changed

.env.example

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
DATABASE_URL=postgres://<username-and-password>@localhost/registry
2+
GITHUB_CLIENT_ID=xxx
3+
GITHUB_CLIENT_SECRET=xxx
4+
GCS_ENDPOINT=http://localhost:4080
5+
OTLP_ENDPOINT=http://localhost:4317
6+
MODULES_BUCKET=modules
7+
PUBLISHING_BUCKET=publishing
8+
DOCS_BUCKET=docs
9+
NPM_BUCKET=npm
10+
REGISTRY_URL=http://jsr.test
11+
NPM_URL=http://npm.jsr.test
12+

.github/workflows/ci.yml

+253
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
name: ci
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- "**"
9+
merge_group:
10+
11+
env:
12+
TERRAFORM_VERSION: "1.4.2"
13+
14+
jobs:
15+
frontend:
16+
runs-on: ubuntu-22.04
17+
permissions:
18+
contents: read
19+
id-token: write
20+
steps:
21+
- name: Clone repository
22+
uses: actions/checkout@v4
23+
24+
- name: Install Deno
25+
uses: denoland/setup-deno@v1
26+
with:
27+
deno-version: 1.x
28+
29+
- name: Check license headers
30+
run: deno task lint:license
31+
32+
- name: Format
33+
run: deno fmt --check
34+
working-directory: frontend
35+
36+
- name: Lint
37+
run: deno lint
38+
working-directory: frontend
39+
40+
- name: Typecheck
41+
run: deno check main.ts
42+
working-directory: frontend
43+
44+
- name: Build Fresh
45+
run: deno task build
46+
working-directory: frontend
47+
48+
test:
49+
runs-on: ubuntu-22.04
50+
steps:
51+
- name: Clone repository
52+
uses: actions/checkout@v4
53+
54+
- name: Install Rust
55+
uses: dsherret/rust-toolchain-file@v1
56+
57+
- uses: Swatinem/rust-cache@v2
58+
59+
- name: Setup postgres for tests
60+
run: docker-compose up -d
61+
62+
- name: Build
63+
run: cargo build --all-targets --tests
64+
working-directory: api
65+
66+
- name: Test
67+
run: cargo test
68+
working-directory: api
69+
70+
- uses: taiki-e/cache-cargo-install-action@v1
71+
with:
72+
73+
74+
# If it's not up to date, run `cargo sqlx prepare` locally and commit the
75+
# changes. You may have to run `cargo install sqlx-cli` first.
76+
- name: Check sqlx metadata is up to date
77+
run: |
78+
cargo sqlx migrate run
79+
cargo sqlx prepare --check
80+
working-directory: api
81+
env:
82+
DATABASE_URL: postgres://user:password@localhost/registry
83+
84+
- name: Lint
85+
run: cargo clippy --all-targets --all-features -- -D warnings
86+
working-directory: api
87+
88+
- name: Format
89+
run: cargo fmt --all -- --check
90+
working-directory: api
91+
92+
docker-images:
93+
if: github.event_name == 'merge_group' || github.ref == 'refs/heads/main'
94+
runs-on: ubuntu-22.04
95+
permissions:
96+
contents: read
97+
id-token: write
98+
env:
99+
API_IMAGE_ID_BASE: us-central1-docker.pkg.dev/deno-registry3-infra/registry/api
100+
FRONTEND_IMAGE_ID_BASE: us-central1-docker.pkg.dev/deno-registry3-infra/registry/frontend
101+
outputs:
102+
api_image_id: ${{ steps.api_image_id.outputs.image_id }}
103+
frontend_image_id: ${{ steps.frontend_image_id.outputs.image_id }}
104+
steps:
105+
- name: Clone repository
106+
uses: actions/checkout@v4
107+
108+
- name: Authenticate with GCP
109+
id: gcp_auth
110+
uses: google-github-actions/auth@v2
111+
with:
112+
project_id: deno-registry3-infra
113+
token_format: access_token
114+
workload_identity_provider: projects/289615555261/locations/global/workloadIdentityPools/github-actions/providers/github-actions
115+
service_account: [email protected]
116+
117+
- uses: docker/login-action@v3
118+
with:
119+
registry: us-central1-docker.pkg.dev
120+
username: oauth2accesstoken
121+
password: ${{ steps.gcp_auth.outputs.access_token }}
122+
123+
- name: Set up docker buildx
124+
uses: docker/setup-buildx-action@v3
125+
126+
- name: Copy Cargo.lock
127+
run: cp Cargo.lock api/Cargo.lock
128+
129+
- name: Build and push api docker image
130+
uses: docker/build-push-action@v5
131+
id: api_push
132+
with:
133+
context: api
134+
push: true
135+
tags: ${{ env.API_IMAGE_ID_BASE }}:${{ github.sha }}
136+
cache-from: type=gha,scope=docker-api
137+
cache-to: type=gha,mode=max,scope=docker-api
138+
139+
- name: Build and push frontend docker image
140+
uses: docker/build-push-action@v5
141+
id: frontend_push
142+
with:
143+
context: frontend
144+
push: true
145+
tags: ${{ env.FRONTEND_IMAGE_ID_BASE }}:${{ github.sha }}
146+
cache-from: type=gha,scope=docker-frontend
147+
cache-to: type=gha,mode=max,scope=docker-frontend
148+
149+
- name: Set api_image_id output
150+
id: api_image_id
151+
run: echo "image_id=${{ env.API_IMAGE_ID_BASE }}@${{ steps.api_push.outputs.imageid }}" >> $GITHUB_OUTPUT
152+
153+
- name: Set frontend_image_id output
154+
id: frontend_image_id
155+
run: echo "image_id=${{ env.FRONTEND_IMAGE_ID_BASE }}@${{ steps.frontend_push.outputs.imageid }}" >> $GITHUB_OUTPUT
156+
157+
staging:
158+
if: github.event_name == 'merge_group' || github.ref == 'refs/heads/main'
159+
runs-on: ubuntu-22.04
160+
needs: docker-images
161+
environment:
162+
name: staging
163+
url: https://deno-registry-staging.net
164+
permissions:
165+
contents: read
166+
id-token: write
167+
steps:
168+
- name: Clone repository
169+
uses: actions/checkout@v4
170+
171+
- name: Install Deno
172+
uses: denoland/setup-deno@v1
173+
with:
174+
deno-version: 1.x
175+
176+
- name: Install terraform
177+
uses: hashicorp/setup-terraform@v3
178+
with:
179+
terraform_version: ${{ env.TERRAFORM_VERSION }}
180+
181+
- name: Authenticate with GCP
182+
id: gcp_auth
183+
uses: google-github-actions/auth@v2
184+
with:
185+
project_id: deno-registry3-staging
186+
workload_identity_provider: projects/1067420915575/locations/global/workloadIdentityPools/github-actions/providers/github-actions
187+
service_account: [email protected]
188+
189+
- name: terraform plan
190+
run: |
191+
touch terraform/staging.secret.tfvars
192+
deno task tf:staging:init
193+
terraform version
194+
deno task tf:staging:plan
195+
env:
196+
API_IMAGE_ID: ${{ needs.docker-images.outputs.api_image_id }}
197+
FRONTEND_IMAGE_ID: ${{ needs.docker-images.outputs.frontend_image_id }}
198+
TF_VAR_github_client_secret: ${{ secrets.GH_CLIENT_SECRET }}
199+
TF_VAR_postmark_token: ${{ secrets.POSTMARK_TOKEN }}
200+
TF_VAR_orama_index_id: ${{ secrets.ORAMA_INDEX_ID }}
201+
TF_VAR_orama_private_api_key: ${{ secrets.ORAMA_PRIVATE_API_KEY }}
202+
203+
- name: terraform apply
204+
run: deno task tf:staging:apply
205+
206+
prod:
207+
if: github.ref == 'refs/heads/main'
208+
runs-on: ubuntu-22.04
209+
needs: docker-images
210+
environment:
211+
name: prod
212+
url: https://jsr.io
213+
permissions:
214+
contents: read
215+
id-token: write
216+
steps:
217+
- name: Clone repository
218+
uses: actions/checkout@v4
219+
220+
- name: Install Deno
221+
uses: denoland/setup-deno@v1
222+
with:
223+
deno-version: 1.x
224+
225+
- name: Install terraform
226+
uses: hashicorp/setup-terraform@v3
227+
with:
228+
terraform_version: ${{ env.TERRAFORM_VERSION }}
229+
230+
- name: Authenticate with GCP
231+
id: gcp_auth
232+
uses: google-github-actions/auth@v2
233+
with:
234+
project_id: deno-registry3-prod
235+
workload_identity_provider: projects/614736529383/locations/global/workloadIdentityPools/github-actions/providers/github-actions
236+
service_account: [email protected]
237+
238+
- name: terraform plan
239+
run: |
240+
touch terraform/prod.secret.tfvars
241+
deno task tf:prod:init
242+
terraform version
243+
deno task tf:prod:plan
244+
env:
245+
API_IMAGE_ID: ${{ needs.docker-images.outputs.api_image_id }}
246+
FRONTEND_IMAGE_ID: ${{ needs.docker-images.outputs.frontend_image_id }}
247+
TF_VAR_github_client_secret: ${{ secrets.GH_CLIENT_SECRET }}
248+
TF_VAR_postmark_token: ${{ secrets.POSTMARK_TOKEN }}
249+
TF_VAR_orama_index_id: ${{ secrets.ORAMA_INDEX_ID }}
250+
TF_VAR_orama_private_api_key: ${{ secrets.ORAMA_PRIVATE_API_KEY }}
251+
252+
- name: terraform apply
253+
run: deno task tf:prod:apply

.github/workflows/orama_deploy.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Orama Deploy
2+
3+
4+
on:
5+
# Temporarily disabled
6+
# schedule:
7+
# - cron: "*/15 * * * *"
8+
workflow_dispatch:
9+
10+
11+
jobs:
12+
orama:
13+
runs-on: ubuntu-22.04
14+
strategy:
15+
matrix:
16+
environment: ["prod", "staging"]
17+
environment:
18+
name: ${{ matrix.environment }}
19+
steps:
20+
- name: Deploy ${{ matrix.environment }}
21+
env:
22+
ORAMA_INDEX_ID: ${{ secrets.ORAMA_INDEX_ID }}
23+
ORAMA_PRIVATE_API_KEY: ${{ secrets.ORAMA_PRIVATE_API_KEY }}
24+
run: |
25+
curl https://api.oramasearch.com/api/v1/webhooks/$ORAMA_INDEX_ID/deploy \
26+
-X POST \
27+
-H "Authorization: Bearer $ORAMA_PRIVATE_API_KEY"

.github/workflows/orama_reindex.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Orama Reindex
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
environment:
7+
description: 'Environment for deployment'
8+
type: choice
9+
options:
10+
- prod
11+
- staging
12+
required: true
13+
14+
jobs:
15+
reindex_orama:
16+
runs-on: ubuntu-22.04
17+
environment:
18+
name: ${{ github.event.inputs.environment }}
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: denoland/setup-deno@v1
22+
- name: Deploy
23+
env:
24+
ORAMA_INDEX_ID: ${{ secrets.ORAMA_INDEX_ID }}
25+
ORAMA_PRIVATE_API_KEY: ${{ secrets.ORAMA_PRIVATE_API_KEY }}
26+
JSR_URL: ${{ vars.ENVIRONMENT_URL }}
27+
run: deno task tools:orama:reindex

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.DS_Store
2+
3+
# rust
4+
target/
5+
6+
# terraform
7+
.terraform/
8+
*.tfplan
9+
*.tfstate*
10+
*.secret.tfvars
11+
12+
**/.env
13+
14+
frontend/node_modules
15+
frontend/dist
16+
17+
.gcs

.licenserc.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"**/*.{ts,tsx,rs,tf}": "// Copyright 2024 the JSR authors. All rights reserved. MIT license.",
3+
"ignore": [
4+
"api/testdata/",
5+
"frontend/_fresh/",
6+
"frontend/node_modules/",
7+
"target/",
8+
".gcs/",
9+
"terraform/.terraform/",
10+
".git/"
11+
]
12+
}

.vscode/settings.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"rust-analyzer.cargo.features": [],
3+
"deno.enable": true,
4+
"deno.config": "./frontend/deno.json",
5+
"[typescriptreact]": {
6+
"editor.defaultFormatter": "denoland.vscode-deno"
7+
},
8+
"[typescript]": {
9+
"editor.defaultFormatter": "denoland.vscode-deno"
10+
},
11+
"[javascriptreact]": {
12+
"editor.defaultFormatter": "denoland.vscode-deno"
13+
},
14+
"[javascript]": {
15+
"editor.defaultFormatter": "denoland.vscode-deno"
16+
},
17+
"[markdown]": {
18+
"editor.defaultFormatter": "denoland.vscode-deno"
19+
},
20+
"[terraform]": {
21+
"editor.defaultFormatter": "hashicorp.terraform"
22+
},
23+
"css.customData": [".vscode/tailwind.json"]
24+
}

0 commit comments

Comments
 (0)