Skip to content

Commit

Permalink
Merge branch 'sebastianbana/sc-26082/adopt-ci-cd-process-to-namerank-…
Browse files Browse the repository at this point in the history
…nameai-rebrand' into staging
  • Loading branch information
BanaSeba committed Jan 10, 2025
2 parents 15e9d2d + 43e661a commit 4281aab
Show file tree
Hide file tree
Showing 60 changed files with 205 additions and 207 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: NameRank API - Lambda Deploy
name: NameAI API - Lambda Deploy

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

permissions:
Expand All @@ -24,7 +24,7 @@ concurrency:

jobs:
build-image-deploy:
name: Build and deploy NameRank API Lambda
name: Build and deploy NameAI API Lambda
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
Expand Down Expand Up @@ -60,23 +60,23 @@ jobs:
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 }}
CERTIFICATE_NAME: ${{ secrets.NAMEAI_CERTIFICATE_NAME }}
HOSTED_ZONE_NAME: ${{ secrets.NAMEAI_HOSTED_ZONE_NAME }}
run: |
if [[ ${{ github.ref }} == 'refs/heads/main' ]]; then
STAGE="prod"
DOMAIN_NAME=${{ secrets.NAMERANK_PROD_DOMAIN_NAME }}
DOMAIN_NAME=${{ secrets.NAMEAI_PROD_DOMAIN_NAME }}
elif [[ ${{ github.ref }} == 'refs/heads/staging' ]]; then
STAGE="staging"
DOMAIN_NAME=${{ secrets.NAMERANK_STAGING_DOMAIN_NAME }}
DOMAIN_NAME=${{ secrets.NAMEAI_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
working-directory: apps/api.nameai.dev

notify:
name: Send Slack deployment event notification
Expand All @@ -87,21 +87,21 @@ jobs:
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 "TEXT=Lambda NameAI 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 "TEXT=Lambda NameAI 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 "TEXT=Lambda NameAI deployment was cancelled. :warning:" >> $GITHUB_ENV
echo "COLOR=warning" >> $GITHUB_ENV
- name: Send deployment status Slack notification
Expand All @@ -113,7 +113,7 @@ jobs:
{
attachments: [{
color: '${{ env.COLOR }}',
title: 'Lambda NameRank deployment.',
title: 'Lambda NameAI deployment.',
text: '${{ env.TEXT }}',
fields: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: NameRank Python - Lint
name: NameAI Python - Lint
on:
push:
branches:
- main
paths:
- "apps/api.namerank.io/**"
- "apps/api.nameai.dev/**"
pull_request:
branches: ["main", "staging"]
paths:
- "apps/api.namerank.io/**"
- "apps/api.nameai.dev/**"

jobs:
lint:
Expand All @@ -21,11 +21,11 @@ jobs:
uses: chartboost/ruff-action@v1
with:
version: 0.6.7
src: "./apps/api.namerank.io"
src: "./apps/api.nameai.dev"

- name: Ruff Format
uses: chartboost/ruff-action@v1
with:
version: 0.6.7
args: "format --check"
src: "./apps/api.namerank.io"
src: "./apps/api.nameai.dev"
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: NameRank Python - Unit Tests
name: NameAI Python - Unit Tests

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

jobs:
test:
Expand All @@ -36,9 +36,9 @@ jobs:
cache: "poetry"

- name: Install dependencies
working-directory: ./apps/api.namerank.io
working-directory: ./apps/api.nameai.dev
run: poetry install --extras "lambda"

- name: Run tests
working-directory: ./apps/api.namerank.io
working-directory: ./apps/api.nameai.dev
run: poetry run pytest -vv
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|apps/api.namerank.io)/.*\.py'
files: '^(packages/nameguard-python|apps/api.nameai.dev)/.*\.py'
- id: ruff-format
files: '^(packages/nameguard-python|apps/api.namerank.io)/.*\.py'
files: '^(packages/nameguard-python|apps/api.nameai.dev)/.*\.py'
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ 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/
COPY nameai ./nameai/
RUN pip install --no-cache-dir .[lambda]
CMD [ "namerank.root_api.handler" ]
CMD [ "nameai.root_api.handler" ]
File renamed without changes.
18 changes: 9 additions & 9 deletions apps/api.namerank.io/README.md → apps/api.nameai.dev/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# NameRank
# NameAI

## API
The API extends the NameGuard API and is fully compatible with it.

NameRank-specific endpoints are under the [api.namerank.io/namerank](https://www.api.namerank.io/namerank) path prefix.
NameAI-specific endpoints are under the [api.nameai.dev/nameai](https://www.api.nameai.dev/nameai) path prefix.

API documentation is available at [api.namerank.io/namerank/docs](https://api.namerank.io/namerank/docs) and [api.namerank.io/docs](https://api.namerank.io/docs) for NameGuard.
API documentation is available at [api.nameai.dev/nameai/docs](https://api.nameai.dev/nameai/docs) and [api.nameai.dev/docs](https://api.nameai.dev/docs) for NameGuard.

Lambda is publicly accessible under given domain [api.namerank.io](https://api.namerank.io)
Lambda is publicly accessible under given domain [api.nameai.dev](https://api.nameai.dev)

# AWS deploy
## Requirements
Expand Down Expand Up @@ -94,16 +94,16 @@ You can add these secrets in your GitHub repository settings under the "Secrets"


# Getting Started
This section is describing how to setup running NameRank instance on local environment
This section is describing how to setup running NameAI instance on local environment

## Environment variables
NameRank requires certain env variables propagated for it's NameGuard subcomponent.
NameAI requires certain env variables propagated for it's NameGuard subcomponent.
Those variables are defined and described in [.env.example](./.env.example) file which is a point of reference.
Script responsible for running local NameRank instance is expecting those variables to be poulated in .env file before execution.
Script responsible for running local NameAI instance is expecting those variables to be poulated in .env file before execution.

## Requirements
python3 with pip installed on local env

## Scripts
Running [start-local.sh](./start-local.sh) script will result in creating running NameRank instance on local environment.
This instance can be reached under [localhost:8000](localhost:8000)
Running [start-local.sh](./start-local.sh) script will result in creating running NameAI instance on local environment.
This instance can be reached under [localhost:8000](localhost:8000)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from typing import Tuple, Iterable
import ahocorasick

from namerank.data import get_resource_path
from namerank.static_property import static_property
from nameai.data import get_resource_path
from nameai.static_property import static_property


class Gap(str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@


@contextmanager
def initialize_namerank_config(config_name: Literal['prod_config']):
with initialize_config_module(version_base=None, config_module='namerank.config'):
def initialize_nameai_config(config_name: Literal['prod_config']):
with initialize_config_module(version_base=None, config_module='nameai.config'):
config = compose(config_name=config_name)
yield config


def load_namerank_config(config_name: Literal['prod_config']):
def load_nameai_config(config_name: Literal['prod_config']):
config_path = Path(__file__).parent / (config_name + '.yaml')
with config_path.open('r') as f:
config = omegaconf.OmegaConf.load(f)
Expand Down
Loading

0 comments on commit 4281aab

Please sign in to comment.