-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: [sc-25983] Prepare NameRank for transition into Monorepo #513
Merged
lightwalker-eth
merged 10 commits into
main
from
byczong/sc-25983/add-namerank-to-monorepo
Jan 3, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
054131f
extend pre-commit for namerank
Byczong c8c8102
copy namerank repo; adjust github workflows
Byczong 7ec8fe9
fix ruff action version
Byczong e9a905b
add ruff, pytest cache to gitignore
Byczong 25b68d0
rename workflows
Byczong 9d81fa6
add lambda deploy for namerank
Byczong baf12ea
Fixed env variables (#522)
BanaSeba a765aa9
add license for namerank
Byczong f8f8701
rename extra name to lambda in pyproj
Byczong eda136b
fix testing without mangum; fix docker
Byczong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 --extras "lambda" | ||
|
||
- name: Run tests | ||
working-directory: ./apps/api.namerank.io | ||
run: poetry run pytest -vv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ __pycache__ | |
.turbo | ||
.next | ||
.vercel | ||
.pytest_cache | ||
.ruff_cache | ||
|
||
*storybook.log | ||
storybook-static | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"credsStore": "ecr-login" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 .[lambda] | ||
CMD [ "namerank.root_api.handler" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 NameHash | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make sense to move the responsibility of setting
arm64
to the deployment script.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we ever using any other platform than arm64? I would expect that any testing/deployment for this lambda will be done only for arm64