From 43e3ecc17f08ce11d662fca66c4a3dfa6187002a Mon Sep 17 00:00:00 2001 From: Baptiste Guerin Date: Wed, 6 Nov 2024 15:33:05 -0300 Subject: [PATCH 1/7] ci: add actions --- .github/actions/setup-repo/action.yml | 18 +++++++ .github/workflows/lint.yml | 27 ++++++++++ .github/workflows/update_production.yml | 56 +++++++++++++++++++++ .github/workflows/update_staging.yml | 65 +++++++++++++++++++++++++ Dockerfile | 4 +- docker-compose.yaml | 4 +- 6 files changed, 170 insertions(+), 4 deletions(-) create mode 100644 .github/actions/setup-repo/action.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/update_production.yml create mode 100644 .github/workflows/update_staging.yml diff --git a/.github/actions/setup-repo/action.yml b/.github/actions/setup-repo/action.yml new file mode 100644 index 00000000..521a2cdc --- /dev/null +++ b/.github/actions/setup-repo/action.yml @@ -0,0 +1,18 @@ +name: Setup repo +description: Runs all steps to setup the repo (install node_modules, build, etc...) +inputs: + registry-token: + description: 'PAT to access registries' +runs: + using: 'composite' + steps: + - uses: actions/checkout@v3 + - name: Set up Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + - name: Install dependencies + run: bun install + env: + GITHUB_REGISTRY_TOKEN: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }} + shell: bash \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..fc926fe8 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,27 @@ +name: test code quality + +on: + pull_request: + push: + branches: + - main + +defaults: + run: + shell: bash + +jobs: + check-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + - name: Install dependencies + run: bun install + env: + GITHUB_REGISTRY_TOKEN: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }} + - name: Lint merkl-api codebase + run: yarn lint:ci \ No newline at end of file diff --git a/.github/workflows/update_production.yml b/.github/workflows/update_production.yml new file mode 100644 index 00000000..ebce20de --- /dev/null +++ b/.github/workflows/update_production.yml @@ -0,0 +1,56 @@ +name: Trigger production deployment + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +defaults: + run: + shell: bash + +jobs: + tag-image: + runs-on: ubuntu-latest + env: + IMAGE_URL: europe-west1-docker.pkg.dev/angle-artifacts/angle-docker-registry/merkl-app + steps: + - uses: 'google-github-actions/auth@v0' + with: + credentials_json: '${{ secrets.GCLOUD_SECRET_ARTIFACTS }}' + - name: Login to Docker + run: gcloud auth configure-docker europe-west1-docker.pkg.dev + - name: Pull and tag image + run: | + export SHORT_SHA=${GITHUB_SHA:0:7} + export VERSION=${GITHUB_REF#refs/tags/} + docker pull $IMAGE_URL:$SHORT_SHA + docker tag $IMAGE_URL:$SHORT_SHA $IMAGE_URL:$VERSION + docker push $IMAGE_URL:$VERSION + trigger-production-deployment: + runs-on: ubuntu-latest + needs: tag-image + steps: + - name: Install dependencies + run: | + sudo snap install yq + - name: Clone deployments repo + uses: actions/checkout@v3 + with: + repository: AngleProtocol/deployments + token: ${{ secrets.ACCESS_TOKEN }} + path: deployments + - name: Modify config.production.yaml and push to deployments + run: | + cd deployments + + export VERSION=${GITHUB_REF#refs/tags/} + yq -i '.merkl-app.version = strenv(VERSION)' ./config.production.yaml + + git config --global user.email "baptiste@angle.money" + git config --global user.name "BaptistG" + + git add ./config.production.yaml + git commit -m "Update config.production.yaml with merkl-app version $VERSION" + + git push diff --git a/.github/workflows/update_staging.yml b/.github/workflows/update_staging.yml new file mode 100644 index 00000000..50896642 --- /dev/null +++ b/.github/workflows/update_staging.yml @@ -0,0 +1,65 @@ +name: Build image and trigger staging deployment + +on: + workflow_dispatch: + push: + branches: + - main + +defaults: + run: + shell: bash + +jobs: + build-image: + runs-on: ubuntu-latest + env: + IMAGE_URL: europe-west1-docker.pkg.dev/angle-artifacts/angle-docker-registry/merkl-app + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - uses: 'google-github-actions/auth@v0' + with: + credentials_json: '${{ secrets.GCLOUD_SECRET_ARTIFACTS }}' + - name: Login to Docker + run: gcloud auth configure-docker europe-west1-docker.pkg.dev + - name: Build image + run: | + export SHORT_SHA=${GITHUB_SHA:0:7} + docker pull $IMAGE_URL:latest || true + docker build --build-arg GITHUB_REGISTRY_TOKEN=${{ secrets.GH_REGISTRY_ACCESS_TOKEN }} --cache-from $IMAGE_URL:latest --tag $IMAGE_URL:$SHORT_SHA --tag $IMAGE_URL:latest . + - name: Push image + run: | + export SHORT_SHA=${GITHUB_SHA:0:7} + docker push $IMAGE_URL:$SHORT_SHA + + trigger-staging-deployment: + runs-on: ubuntu-latest + needs: build-image + steps: + - name: Install dependencies + run: | + sudo snap install yq + - name: Clone deployments repo + uses: actions/checkout@v3 + with: + repository: AngleProtocol/deployments + token: ${{ secrets.ACCESS_TOKEN }} + path: deployments + - name: Modify config.staging.yaml and push to deployments + run: | + cd deployments + + export SHORT_SHA=${GITHUB_SHA:0:7} + + yq -i '.merkl-app.version = strenv(SHORT_SHA)' ./config.staging.yaml + + git config --global user.email "baptiste@angle.money" + git config --global user.name "BaptistG" + + git add ./config.staging.yaml + git commit -m "Update config.staging.yaml with merkl-app version $SHORT_SHA" + + git push diff --git a/Dockerfile b/Dockerfile index ad6dce88..e0468ec1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,4 +20,6 @@ COPY tsconfig.json ./ COPY ./ ./ -CMD ["bun", "dev"] \ No newline at end of file +EXPOSE 5173 + +CMD ["bun", "dev"] diff --git a/docker-compose.yaml b/docker-compose.yaml index 7e5facf2..09eb0325 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -11,8 +11,6 @@ services: - '3000:5173' env_file: - .env - environment: - PORT: '3000' volumes: - ./src:/app/src - - ./app:/app/app \ No newline at end of file + - ./app:/app/app From 4c17dda9f9056b0f5ba5ed9aeb8754925653e248 Mon Sep 17 00:00:00 2001 From: sheykei Date: Thu, 7 Nov 2024 10:57:21 +0100 Subject: [PATCH 2/7] fix --- .github/workflows/lint.yml | 2 +- bunfig.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index fc926fe8..7a0f1761 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,4 +24,4 @@ jobs: env: GITHUB_REGISTRY_TOKEN: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }} - name: Lint merkl-api codebase - run: yarn lint:ci \ No newline at end of file + run: bun lint:ci \ No newline at end of file diff --git a/bunfig.toml b/bunfig.toml index d513c258..e65c3455 100644 --- a/bunfig.toml +++ b/bunfig.toml @@ -1,5 +1,5 @@ [install.scopes] "@angleprotocol" = { - token = $GH_REGISTRY_ACCESS_TOKEN, + token = $GITHUB_REGISTRY_TOKEN, url = "https://npm.pkg.github.com/" } \ No newline at end of file From 8eca5dd2b1caa02a126fe522dc801563ad4b364f Mon Sep 17 00:00:00 2001 From: picodes Date: Fri, 8 Nov 2024 10:18:02 +0100 Subject: [PATCH 3/7] fix: SDK_READ_ACCESS_TOKEN --- .github/actions/setup-repo/action.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/update_staging.yml | 2 +- bunfig.toml | 2 +- packages/dappkit | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/actions/setup-repo/action.yml b/.github/actions/setup-repo/action.yml index 521a2cdc..63270ab2 100644 --- a/.github/actions/setup-repo/action.yml +++ b/.github/actions/setup-repo/action.yml @@ -14,5 +14,5 @@ runs: - name: Install dependencies run: bun install env: - GITHUB_REGISTRY_TOKEN: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }} + SDK_READ_ACCESS_TOKEN: ${{ secrets.SDK_READ_ACCESS_TOKEN }} shell: bash \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7a0f1761..843c2808 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,6 +22,6 @@ jobs: - name: Install dependencies run: bun install env: - GITHUB_REGISTRY_TOKEN: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }} + SDK_READ_ACCESS_TOKEN: ${{ secrets.SDK_READ_ACCESS_TOKEN }} - name: Lint merkl-api codebase run: bun lint:ci \ No newline at end of file diff --git a/.github/workflows/update_staging.yml b/.github/workflows/update_staging.yml index 50896642..910caf67 100644 --- a/.github/workflows/update_staging.yml +++ b/.github/workflows/update_staging.yml @@ -29,7 +29,7 @@ jobs: run: | export SHORT_SHA=${GITHUB_SHA:0:7} docker pull $IMAGE_URL:latest || true - docker build --build-arg GITHUB_REGISTRY_TOKEN=${{ secrets.GH_REGISTRY_ACCESS_TOKEN }} --cache-from $IMAGE_URL:latest --tag $IMAGE_URL:$SHORT_SHA --tag $IMAGE_URL:latest . + docker build --build-arg SDK_READ_ACCESS_TOKEN=${{ secrets.SDK_READ_ACCESS_TOKEN }} --cache-from $IMAGE_URL:latest --tag $IMAGE_URL:$SHORT_SHA --tag $IMAGE_URL:latest . - name: Push image run: | export SHORT_SHA=${GITHUB_SHA:0:7} diff --git a/bunfig.toml b/bunfig.toml index e65c3455..fce057ca 100644 --- a/bunfig.toml +++ b/bunfig.toml @@ -1,5 +1,5 @@ [install.scopes] "@angleprotocol" = { - token = $GITHUB_REGISTRY_TOKEN, + token = $SDK_READ_ACCESS_TOKEN, url = "https://npm.pkg.github.com/" } \ No newline at end of file diff --git a/packages/dappkit b/packages/dappkit index 66f1074d..b0ed96c9 160000 --- a/packages/dappkit +++ b/packages/dappkit @@ -1 +1 @@ -Subproject commit 66f1074d37f93015cbb84dabcfb73f17930786eb +Subproject commit b0ed96c9e8cf0fe4cabebbb3e230af647532d6a6 From 3e7452210aa59a5140c0a18d1f204d3c7a85105c Mon Sep 17 00:00:00 2001 From: sheykei Date: Fri, 8 Nov 2024 10:34:33 +0100 Subject: [PATCH 4/7] add: lint check command --- .github/workflows/lint.yml | 2 +- package.json | 1 + packages/dappkit | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 843c2808..fdb2198b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v3 - name: Set up Bun uses: oven-sh/setup-bun@v1 - with: + with:SDK_READ_ACCESS_TOKEN bun-version: latest - name: Install dependencies run: bun install diff --git a/package.json b/package.json index 00f957b4..076fe095 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "build": "remix vite:build", "dev": "remix vite:dev --host", "lint": "biome check --fix ./src ./app", + "lint:ci": "biome check --diagnostic-level error ./src", "start": "remix-serve ./build/server/index.js", "typecheck": "tsc" }, diff --git a/packages/dappkit b/packages/dappkit index b0ed96c9..66f1074d 160000 --- a/packages/dappkit +++ b/packages/dappkit @@ -1 +1 @@ -Subproject commit b0ed96c9e8cf0fe4cabebbb3e230af647532d6a6 +Subproject commit 66f1074d37f93015cbb84dabcfb73f17930786eb From cd985ca5db8c9ff9151217f408232e27e13d6833 Mon Sep 17 00:00:00 2001 From: sheykei Date: Fri, 8 Nov 2024 10:36:01 +0100 Subject: [PATCH 5/7] fix: lint --- app/root.tsx | 3 +- app/routes/_merkl.(home).tsx | 2 +- app/routes/_merkl.action.$action.tsx | 4 +-- app/routes/_merkl.chain.$id.tsx | 23 ++++++++------- .../_merkl.opportunity.$chain.$type.$id.tsx | 28 +++++-------------- app/routes/_merkl.status.$status.tsx | 4 +-- app/routes/_merkl.token.$symbol.tsx | 3 +- app/routes/_merkl.user.$address.(rewards).tsx | 3 +- app/routes/_merkl.user.$address.tsx | 3 +- src/components/composite/Faq.tsx | 15 ++++------ src/components/composite/layout/Container.tsx | 4 +-- .../element/campaign/CampaignTableRow.tsx | 6 +++- .../element/rewards/ClaimRewardsLibrary.tsx | 2 +- .../rewards/ClaimRewardsTokenTable.tsx | 8 +++--- src/components/layout/Header.tsx | 5 +--- src/config/type.ts | 10 +++---- src/hooks/resources/useCampaign.tsx | 2 +- 17 files changed, 51 insertions(+), 74 deletions(-) diff --git a/app/root.tsx b/app/root.tsx index 5b5dbd95..c3e95d08 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -2,9 +2,8 @@ import type { LinksFunction } from "@remix-run/node"; import { Links, Meta, Outlet, Scripts, ScrollRestoration } from "@remix-run/react"; import "./tailwind.css"; import { DAppProvider } from "dappkit"; +import config from "../merkl.config"; import styles from "./tailwind.css?url"; -import config from "../merkl.config" - export const links: LinksFunction = () => [ { rel: "preconnect", href: "https://fonts.googleapis.com" }, diff --git a/app/routes/_merkl.(home).tsx b/app/routes/_merkl.(home).tsx index 03c2d4cb..726ff9b4 100644 --- a/app/routes/_merkl.(home).tsx +++ b/app/routes/_merkl.(home).tsx @@ -1,6 +1,6 @@ import type { MetaFunction } from "@remix-run/node"; import { Outlet } from "@remix-run/react"; -import { type Coloring, Container, createColoring } from "dappkit"; +import { Container } from "dappkit"; import Heading from "src/components/composite/Heading"; import { http, createConfig } from "wagmi"; import { mainnet, sepolia } from "wagmi/chains"; diff --git a/app/routes/_merkl.action.$action.tsx b/app/routes/_merkl.action.$action.tsx index 81dd6d84..00bccfb2 100644 --- a/app/routes/_merkl.action.$action.tsx +++ b/app/routes/_merkl.action.$action.tsx @@ -4,9 +4,7 @@ import { Container } from "dappkit"; import Heading from "src/components/composite/Heading"; import { type Action, actions, getAction } from "src/config/actions"; -export async function loader({ - params: { action: _action }, -}: LoaderFunctionArgs) { +export async function loader({ params: { action: _action } }: LoaderFunctionArgs) { const action = getAction(_action ?? ""); if (!action) throw new Error("Unknown action"); diff --git a/app/routes/_merkl.chain.$id.tsx b/app/routes/_merkl.chain.$id.tsx index 1510d0fe..8ec52cd4 100644 --- a/app/routes/_merkl.chain.$id.tsx +++ b/app/routes/_merkl.chain.$id.tsx @@ -45,15 +45,18 @@ export function ErrorBoundary() { const networks = useMemo(() => { const a = Object.keys(chains); - return Object.entries(chains).reduce((supported, [chainId, chain]) => { - supported[chainId] = ( - - - {chain.label} - - ); - return supported; - }, {} as { [C in ChainId]?: ReactNode }); + return Object.entries(chains).reduce( + (supported, [chainId, chain]) => { + supported[chainId] = ( + + + {chain.label} + + ); + return supported; + }, + {} as { [C in ChainId]?: ReactNode }, + ); }, []); return ( @@ -63,7 +66,7 @@ export function ErrorBoundary() { {/* We don't support this chain */}