Skip to content

Commit

Permalink
Initial commit prior to open sourcing
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
11 people committed Feb 28, 2024
0 parents commit d0c2bc5
Show file tree
Hide file tree
Showing 494 changed files with 64,194 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DATABASE_URL=postgres://<username-and-password>@localhost/registry
GITHUB_CLIENT_ID=xxx
GITHUB_CLIENT_SECRET=xxx
GCS_ENDPOINT=http://localhost:4080
OTLP_ENDPOINT=http://localhost:4317
MODULES_BUCKET=modules
PUBLISHING_BUCKET=publishing
DOCS_BUCKET=docs
NPM_BUCKET=npm
REGISTRY_URL=http://jsr.test
NPM_URL=http://npm.jsr.test

241 changes: 241 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
name: ci
on:
push:
branches:
- main
pull_request:
branches:
- "**"

env:
TERRAFORM_VERSION: "1.4.2"

jobs:
frontend:
runs-on: ubuntu-22.04
permissions:
contents: read
id-token: write
steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install Deno
uses: denoland/setup-deno@v1
with:
deno-version: 1.x

- name: Check license headers
run: deno task lint:license

- name: Format
run: deno fmt --check
working-directory: frontend

- name: Lint
run: deno lint
working-directory: frontend

- name: Typecheck
run: deno check main.ts
working-directory: frontend

- name: Build Fresh
run: deno task build
working-directory: frontend

test:
runs-on: ubuntu-22.04
steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install Rust
uses: dsherret/rust-toolchain-file@v1

- uses: Swatinem/rust-cache@v2

- name: Setup postgres for tests
run: docker-compose up -d

- name: Build
run: cargo build --all-targets --tests
working-directory: api

- name: Test
run: cargo test
working-directory: api

- uses: taiki-e/cache-cargo-install-action@v1
with:
tool: [email protected]

# If it's not up to date, run `cargo sqlx prepare` locally and commit the
# changes. You may have to run `cargo install sqlx-cli` first.
- name: Check sqlx metadata is up to date
run: |
cargo sqlx migrate run
cargo sqlx prepare --check
working-directory: api
env:
DATABASE_URL: postgres://user:password@localhost/registry

- name: Lint
run: cargo clippy --all-targets --all-features -- -D warnings
working-directory: api

- name: Format
run: cargo fmt --all -- --check
working-directory: api

docker-images:
runs-on: ubuntu-22.04
permissions:
contents: read
id-token: write
env:
API_IMAGE_ID_BASE: us-central1-docker.pkg.dev/deno-registry3-infra/registry/api
FRONTEND_IMAGE_ID_BASE: us-central1-docker.pkg.dev/deno-registry3-infra/registry/frontend
outputs:
api_image_id: ${{ steps.api_image_id.outputs.image_id }}
frontend_image_id: ${{ steps.frontend_image_id.outputs.image_id }}
steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Authenticate with GCP
id: gcp_auth
uses: google-github-actions/auth@v2
with:
project_id: deno-registry3-infra
token_format: access_token
workload_identity_provider: projects/289615555261/locations/global/workloadIdentityPools/github-actions/providers/github-actions
service_account: [email protected]

- uses: docker/login-action@v3
with:
registry: us-central1-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.gcp_auth.outputs.access_token }}

- name: Set up docker buildx
uses: docker/setup-buildx-action@v3

- name: Copy Cargo.lock
run: cp Cargo.lock api/Cargo.lock

- name: Build and push api docker image
uses: docker/build-push-action@v5
id: api_push
with:
context: api
push: true
tags: ${{ env.API_IMAGE_ID_BASE }}:${{ github.sha }}
cache-from: type=gha,scope=docker-api
cache-to: type=gha,mode=max,scope=docker-api

- name: Build and push frontend docker image
uses: docker/build-push-action@v5
id: frontend_push
with:
context: frontend
push: true
tags: ${{ env.FRONTEND_IMAGE_ID_BASE }}:${{ github.sha }}
cache-from: type=gha,scope=docker-frontend
cache-to: type=gha,mode=max,scope=docker-frontend

- name: Set api_image_id output
id: api_image_id
run: echo "image_id=${{ env.API_IMAGE_ID_BASE }}@${{ steps.api_push.outputs.imageid }}" >> $GITHUB_OUTPUT

- name: Set frontend_image_id output
id: frontend_image_id
run: echo "image_id=${{ env.FRONTEND_IMAGE_ID_BASE }}@${{ steps.frontend_push.outputs.imageid }}" >> $GITHUB_OUTPUT

staging:
runs-on: ubuntu-22.04
needs: docker-images
environment:
name: staging
url: https://deno-registry-staging.net
permissions:
contents: read
id-token: write
steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}

- name: Authenticate with GCP
id: gcp_auth
uses: google-github-actions/auth@v2
with:
project_id: deno-registry3-staging
workload_identity_provider: projects/1067420915575/locations/global/workloadIdentityPools/github-actions/providers/github-actions
service_account: [email protected]

- name: terraform plan
run: |
make staging-init
terraform version
make staging-plan
env:
API_IMAGE_ID: ${{ needs.docker-images.outputs.api_image_id }}
FRONTEND_IMAGE_ID: ${{ needs.docker-images.outputs.frontend_image_id }}
GH_CLIENT_ID: ${{ secrets.GH_CLIENT_ID }}
GH_CLIENT_SECRET: ${{ secrets.GH_CLIENT_SECRET }}
POSTMARK_TOKEN: ${{ secrets.POSTMARK_TOKEN }}
ORAMA_PRIVATE_API_KEY: ${{ secrets.ORAMA_PRIVATE_API_KEY }}
ORAMA_INDEX_ID: ${{ secrets.ORAMA_INDEX_ID }}

- name: terraform apply
if: github.event.pull_request.draft == false
run: make staging-apply

prod:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
needs: docker-images
environment:
name: prod
url: https://jsr.io
permissions:
contents: read
id-token: write
steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}

- name: Authenticate with GCP
id: gcp_auth
uses: google-github-actions/auth@v2
with:
project_id: deno-registry3-prod
workload_identity_provider: projects/614736529383/locations/global/workloadIdentityPools/github-actions/providers/github-actions
service_account: [email protected]

- name: terraform plan
run: |
make prod-init
terraform version
make prod-plan
env:
API_IMAGE_ID: ${{ needs.docker-images.outputs.api_image_id }}
FRONTEND_IMAGE_ID: ${{ needs.docker-images.outputs.frontend_image_id }}
GH_CLIENT_ID: ${{ secrets.GH_CLIENT_ID }}
GH_CLIENT_SECRET: ${{ secrets.GH_CLIENT_SECRET }}
POSTMARK_TOKEN: ${{ secrets.POSTMARK_TOKEN }}
ORAMA_PRIVATE_API_KEY: ${{ secrets.ORAMA_PRIVATE_API_KEY }}
ORAMA_INDEX_ID: ${{ secrets.ORAMA_INDEX_ID }}

- name: terraform apply
run: make prod-apply
23 changes: 23 additions & 0 deletions .github/workflows/orama_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Orama Deploy

on:
schedule:
- cron: "*/15 * * * *"

jobs:
orama:
runs-on: ubuntu-22.04
strategy:
matrix:
environment: ["prod", "staging"]
environment:
name: ${{ matrix.environment }}
steps:
- name: Deploy ${{ matrix.environment }}
env:
ORAMA_INDEX_ID: ${{ secrets.ORAMA_INDEX_ID }}
ORAMA_PRIVATE_API_KEY: ${{ secrets.ORAMA_PRIVATE_API_KEY }}
run: |
curl https://api.oramasearch.com/api/v1/webhooks/$ORAMA_INDEX_ID/deploy \
-X POST \
-H "Authorization: Bearer $ORAMA_PRIVATE_API_KEY"
27 changes: 27 additions & 0 deletions .github/workflows/orama_reindex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Orama Reindex

on:
workflow_dispatch:
inputs:
environment:
description: 'Environment for deployment'
type: choice
options:
- prod
- staging
required: true

jobs:
reindex_orama:
runs-on: ubuntu-22.04
environment:
name: ${{ github.event.inputs.environment }}
steps:
- uses: actions/checkout@v2
- uses: denoland/setup-deno@v1
- name: Deploy
env:
ORAMA_INDEX_ID: ${{ secrets.ORAMA_INDEX_ID }}
ORAMA_PRIVATE_API_KEY: ${{ secrets.ORAMA_PRIVATE_API_KEY }}
JSR_URL: ${{ vars.ENVIRONMENT_URL }}
run: deno task tools:orama:reindex
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.DS_Store

# rust
target/

# terraform
.terraform/
*.tfplan
*.tfstate*

**/.env

frontend/node_modules
frontend/dist

.gcs
12 changes: 12 additions & 0 deletions .licenserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"**/*.{ts,tsx,rs,tf}": "// Copyright 2024 the JSR authors. All rights reserved. MIT license.",
"ignore": [
"api/testdata/",
"frontend/_fresh/",
"frontend/node_modules/",
"target/",
".gcs/",
"terraform/.terraform/",
".git/"
]
}
24 changes: 24 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"rust-analyzer.cargo.features": [],
"deno.enable": true,
"deno.config": "./frontend/deno.json",
"[typescriptreact]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[javascriptreact]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[javascript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[markdown]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[terraform]": {
"editor.defaultFormatter": "hashicorp.terraform"
},
"css.customData": [".vscode/tailwind.json"]
}
Loading

0 comments on commit d0c2bc5

Please sign in to comment.