Skip to content

Commit

Permalink
Merge branch 'byczong/sc-25983/add-namerank-to-monorepo' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
BanaSeba committed Jan 2, 2025
2 parents 5d4cb81 + baf12ea commit 5c6900f
Show file tree
Hide file tree
Showing 87 changed files with 2,412,729 additions and 170 deletions.
1 change: 0 additions & 1 deletion .github/workflows/nameguard-api-lambda-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ jobs:
cd terraform
chmod +x ./deploy_lambda.sh
./deploy_lambda.sh $STAGE $AWS_REGION $DOMAIN_NAME $CERTIFICATE_NAME $HOSTED_ZONE_NAME
working-directory: apps/api.nameguard.io

notify:
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/nameguard-python-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: NameGuard Python - Lint
on:
push:
branches:
- main
paths:
- "packages/nameguard-python/**"
pull_request:
branches: ["main", "staging"]
paths:
- "packages/nameguard-python/**"

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout NameKit repo
uses: actions/checkout@v4

- name: Ruff Check
uses: chartboost/ruff-action@v1
with:
version: 0.6.7
src: "./packages/nameguard-python"

- name: Ruff Format
uses: chartboost/ruff-action@v1
with:
version: 0.6.7
args: "format --check"
src: "./packages/nameguard-python"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: NameGuard API - PyPI Package Release
name: NameGuard Python - PyPI Package Release

on:
release:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nameguard-python-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: NameGuard API - Unit Tests
name: NameGuard Python - Unit Tests
on:
schedule:
- cron: '0 5 * * 0'
Expand Down
138 changes: 138 additions & 0 deletions .github/workflows/namerank-api-lambda-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: NameRank API - Lambda Deploy

on:
push:
branches:
- main
- staging
paths:
- "packages/namerank-python/**"
- "apps/api.namerank.io/**"
- ".github/workflows/namerank-api-lambda-deploy.yml"
workflow_dispatch:

permissions:
# `id-token: write` is required for the auth to AWS
id-token: write
contents: read

concurrency:
group: ${{ github.workflow }}
# `cancel-in-progress: false` creates a queue for workflow runs, such that
# only one instance of this workflow runs at a time.
cancel-in-progress: false

jobs:
build-image-deploy:
name: Build and deploy NameRank API Lambda
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE}}
aws-region: ${{ secrets.AWS_REGION }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64

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

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: "1.5.7"
terraform_wrapper: false


- name: Build and deploy lambda
env:
PROVIDER_URI_MAINNET: ${{ secrets.PROVIDER_URI_MAINNET }}
PROVIDER_URI_SEPOLIA: ${{ secrets.PROVIDER_URI_SEPOLIA }}
ALCHEMY_URI_MAINNET: ${{ secrets.ALCHEMY_URI_MAINNET }}
ALCHEMY_URI_SEPOLIA: ${{ secrets.ALCHEMY_URI_SEPOLIA }}
ENS_SUBGRAPH_URL_MAINNET: ${{ secrets.ENS_SUBGRAPH_URL_MAINNET }}
ENS_SUBGRAPH_URL_SEPOLIA: ${{ secrets.ENS_SUBGRAPH_URL_SEPOLIA }}
AWS_REGION: ${{ secrets.AWS_REGION }}
CERTIFICATE_NAME: ${{ secrets.NAMERANK_CERTIFICATE_NAME }}
HOSTED_ZONE_NAME: ${{ secrets.NAMERANK_HOSTED_ZONE_NAME }}
run: |
if [[ ${{ github.ref }} == 'refs/heads/main' ]]; then
STAGE="prod"
DOMAIN_NAME=${{ secrets.NAMERANK_PROD_DOMAIN_NAME }}
elif [[ ${{ github.ref }} == 'refs/heads/staging' ]]; then
STAGE="staging"
DOMAIN_NAME=${{ secrets.NAMERANK_STAGING_DOMAIN_NAME }}
else
echo "Deployment is only supported for main and staging branches"
exit 1
fi
cd terraform
chmod +x ./deploy_lambda.sh
./deploy_lambda.sh $STAGE $AWS_REGION $DOMAIN_NAME $CERTIFICATE_NAME $HOSTED_ZONE_NAME
working-directory: apps/api.namerank.io

notify:
name: Send Slack deployment event notification
needs: [build-image-deploy]
runs-on: ubuntu-latest
steps:
- name: Output status on deployment success
if: ${{ needs.build-image-deploy.result == 'success'}}
run: |
echo "STATUS=Success :rocket:" >> $GITHUB_ENV
echo "TEXT=Lambda NameRank deployed successfully! :white_check_mark:" >> $GITHUB_ENV
echo "COLOR=good" >> $GITHUB_ENV
- name: Output status on deployment failed
if: ${{ needs.build-image-deploy.result == 'failure' }}
run: |
echo "STATUS=Failure :x:" >> $GITHUB_ENV
echo "TEXT=Lambda NameRank deployment failed! :rotating_light:" >> $GITHUB_ENV
echo "COLOR=danger" >> $GITHUB_ENV
- name: Output status on deployment cancellation
if: ${{ needs.build-image-deploy.result == 'cancelled' }}
run: |
echo "STATUS=Cancelled :no_entry_sign:" >> $GITHUB_ENV
echo "TEXT=Lambda NameRank deployment was cancelled. :warning:" >> $GITHUB_ENV
echo "COLOR=warning" >> $GITHUB_ENV
- name: Send deployment status Slack notification
uses: 8398a7/action-slack@v3
with:
status: custom
fields: commit,workflow,repo
custom_payload: |
{
attachments: [{
color: '${{ env.COLOR }}',
title: 'Lambda NameRank deployment.',
text: '${{ env.TEXT }}',
fields: [
{
title: 'Repository',
value: `${process.env.AS_REPO}`,
short: true
},
{
title: 'Status',
value: '${{ env.STATUS }}',
short: true
},
{
title: 'Workflow',
value: `${process.env.AS_WORKFLOW}`,
short: true
}
]
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL}}
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: NameGuard API - Lint
name: NameRank Python - Lint
on:
push:
branches:
- main
paths:
- "apps/api.namerank.io/**"
pull_request:
branches: ["main", "staging"]
paths:
- "apps/api.namerank.io/**"

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -15,10 +20,12 @@ jobs:
- name: Ruff Check
uses: chartboost/ruff-action@v1
with:
version: 0.1.8
version: 0.6.7
src: "./apps/api.namerank.io"

- name: Ruff Format
uses: chartboost/ruff-action@v1
with:
version: 0.1.8
version: 0.6.7
args: "format --check"
src: "./apps/api.namerank.io"
44 changes: 44 additions & 0 deletions .github/workflows/namerank-python-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: NameRank Python - Unit Tests

on:
push:
branches:
- main
paths:
- "apps/api.namerank.io/**"
pull_request:
branches:
- main
- staging
paths:
- "apps/api.namerank.io/**"

jobs:
test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.10", "3.11", "3.12"]

steps:
- name: Checkout NameKit repo
uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "poetry"

- name: Install dependencies
working-directory: ./apps/api.namerank.io
run: poetry install

- name: Run tests
working-directory: ./apps/api.namerank.io
run: poetry run pytest -vv
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ __pycache__
.turbo
.next
.vercel
.pytest_cache
.ruff_cache

*storybook.log
storybook-static
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ repos:
hooks:
- id: ruff
args: [ --fix ]
files: '^packages/nameguard-python/.*\.py'
files: '^(packages/nameguard-python|apps/api.namerank.io)/.*\.py'
- id: ruff-format
files: '^packages/nameguard-python/.*\.py'
files: '^(packages/nameguard-python|apps/api.namerank.io)/.*\.py'
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,3 @@ We use [Storybook](https://storybook.namekit.io/) to preview components across o
- `@namehash/ens-webfont`
- `@namehash/ui`
- These components are mostly internal and not intended for public use, but they are used across our packages.

## Tailwind Configuration

When configuring Tailwind CSS for use with this project, please note the following:

If you're using the `@tailwindcss/forms` plugin in your `tailwind.config.ts`, you may encounter some styling conflicts with our components. To resolve this, you should use the plugin with the class strategy applied. Here's an example of how to configure it: https://github.com/tailwindlabs/tailwindcss-forms?tab=readme-ov-file#using-only-global-styles-or-only-classes
3 changes: 3 additions & 0 deletions apps/api.namerank.io/.docker/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"credsStore": "ecr-login"
}
21 changes: 21 additions & 0 deletions apps/api.namerank.io/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Provider URIs (can be any Ethereum node, e.g. Infura, Alchemy, your own node, etc.).
# The following example values are rate limited.
# Sign up for your own node provider (e.g. Infura, Alchemy, etc.) to remove rate limits.
PROVIDER_URI_MAINNET=https://rpc.ankr.com/eth
PROVIDER_URI_SEPOLIA=https://rpc.ankr.com/eth_sepolia

# Alchemy API URIs (needed for their NFT API for NameGuard's fake ENS NFT checks)
# Replace [YOUR_ALCHEMY_API_KEY] with your actual Alchemy API key).
# Sign up for a free account at https://www.alchemy.com/
ALCHEMY_URI_MAINNET=https://eth-mainnet.g.alchemy.com/v2/[YOUR_ALCHEMY_API_KEY]
ALCHEMY_URI_SEPOLIA=https://eth-sepolia.g.alchemy.com/v2/[YOUR_ALCHEMY_API_KEY]

# ENS Subgraph URLs
# The following example values are rate limited.
# You're highly encouraged to sign up for your own API key.
# For more details, see:
# - https://docs.ens.domains/web/subgraph
# - https://discuss.ens.domains/t/ens-subgraph-migration-to-the-decentralised-version/19183
# - https://thegraph.com/explorer/subgraphs/5XqPmWe6gjyrJtFn9cLy237i4cWw2j9HcUJEXsP5qGtH?view=Query&chain=arbitrum-one
ENS_SUBGRAPH_URL_MAINNET=https://api.thegraph.com/subgraphs/name/ensdomains/ens
ENS_SUBGRAPH_URL_SEPOLIA=https://api.studio.thegraph.com/query/49574/enssepolia/version/latest
7 changes: 7 additions & 0 deletions apps/api.namerank.io/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM --platform=linux/arm64 public.ecr.aws/lambda/python:3.11
WORKDIR /app
RUN yum install gcc -y
COPY pyproject.toml poetry.lock LICENSE README.md ./
COPY namerank ./namerank/
RUN pip install --no-cache-dir .[namerank]
CMD [ "namerank.root_api.handler" ]
1 change: 1 addition & 0 deletions apps/api.namerank.io/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO
Loading

0 comments on commit 5c6900f

Please sign in to comment.