Skip to content

Commit d0c2bc5

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 d0c2bc5

File tree

494 files changed

+64194
-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

+64194
-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

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

.github/workflows/orama_deploy.yml

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

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.DS_Store
2+
3+
# rust
4+
target/
5+
6+
# terraform
7+
.terraform/
8+
*.tfplan
9+
*.tfstate*
10+
11+
**/.env
12+
13+
frontend/node_modules
14+
frontend/dist
15+
16+
.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)