Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
Conflicts:
	.github/workflows/ci.yml
  • Loading branch information
gshep committed Nov 28, 2024
2 parents e9cdc78 + b0079ec commit 33e6de9
Show file tree
Hide file tree
Showing 70 changed files with 11,048 additions and 960 deletions.
42 changes: 41 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,54 @@ jobs:
docker pull ghcr.io/gear-tech/node:v1.6.2
docker run --name $NODE_CONTAINER_NAME --detach --rm --publish 127.0.0.1:9944:9944 ghcr.io/gear-tech/node:v1.6.2 gear --dev --tmp --rpc-external
- name: Run tests
run: cargo test --release --workspace --all-targets || { exit_code=$?; if [ x$exit_code != x0 ]; then docker stop $NODE_CONTAINER_NAME; fi; exit $exit_code; }
run: cargo test --release --workspace
--exclude prover
--exclude plonky2_blake2b256
--exclude plonky2_ecdsa
--exclude plonky2_ed25519
--exclude plonky2_sha512
--exclude plonky2_u32 || { exit_code=$?; if [ x$exit_code != x0 ]; then docker stop $NODE_CONTAINER_NAME; fi; exit $exit_code; }
- name: Run solidity tests
run: |
cd ethereum
forge test
- name: Stop Gear node container (if any)
continue-on-error: true
run: docker stop $NODE_CONTAINER_NAME
check-zk-circuits-changed:
runs-on: kuberunner
outputs:
circuits_changed: ${{ steps.filter.outputs.circuits }}
prover_changed: ${{ steps.filter.outputs.prover }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Filter files
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
circuits:
- 'circuits/**'
prover:
- 'prover/**'
zk-tests:
runs-on: kuberunner
needs: check-zk-circuits-changed
if: ${{needs.check-zk-circuits-changed.outputs.circuits_changed == 'true' || needs.check-zk-circuits-changed.outputs.prover_changed == 'true'}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Run tests
run: cargo test --release
-p prover
-p plonky2_blake2b256
-p plonky2_ecdsa
-p plonky2_ed25519
-p plonky2_sha512
-p plonky2_u32
check-api-files:
runs-on: kuberunner
steps:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/indexer-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI indexer

on:
pull_request:
branches:
- main
paths:
- indexer/**

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Install dependencies
working-directory: indexer
run: npm install

- name: Copy api files
run: |
mkdir -p indexer/assets
node indexer/scripts/abi.js api/ethereum/IERC20Manager.json indexer/assets
node indexer/scripts/abi.js api/ethereum/IMessageQueue.json indexer/assets
- name: Build
working-directory: indexer
run: npm run build
87 changes: 23 additions & 64 deletions .github/workflows/k8s-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Frontend
on:
workflow_dispatch:
push:
branches: ['master', 'main', 'staging']
branches: ['main']
paths:
- frontend/**

Expand All @@ -11,67 +11,38 @@ concurrency:
cancel-in-progress: true

env:
ENVIRONMENT: ${{ (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && 'prod' || 'stg' }}
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
KUBECTL_VERSION: 'v1.22.17'
KUBE_NAMESPACE: zk-bridge
KUBE_DEPLOYMENT_PREFIX: zk-bridge
REGISTRY: ghcr.io/${{ github.repository }}

jobs:
prepair:
build-frontend-image-staging:
runs-on: ubuntu-latest
outputs:
image_name: ${{ steps.image.outputs.image_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get branch
id: branch
run: |
branch_name=${GITHUB_REF#refs/heads/}
echo "branch_name=$branch_name" >> $GITHUB_ENV
- name: Get short SHA
id: sha
run: |
sha_short=$(git rev-parse --short HEAD)
echo "sha_short=$sha_short" >> $GITHUB_ENV
- name: Set IMAGE_NAME
id: image
run: |
image_name=${{ env.REGISTRY }}-${{ env.KUBE_DEPLOYMENT_PREFIX }}:${{ env.branch_name }}-${{ env.sha_short }}
echo "image_name=$image_name" >> $GITHUB_OUTPUT
build-and-push-image:
needs: [prepair]
runs-on: ubuntu-latest
environment: ${{ (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && 'prod' || 'stg' }}
environment: stg
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v2

- name: Log in to the github container registry
uses: docker/login-action@v3
uses: docker/login-action@master
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image
uses: docker/build-push-action@v5
- name: Build and push Frontend Docker image
uses: docker/build-push-action@master
with:
file: frontend/Dockerfile
push: true
tags: ${{ needs.prepair.outputs.image_name }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend:qa
build-args: |
VITE_VARA_NODE_ADDRESS=${{ secrets.VITE_VARA_NODE_ADDRESS }}
VITE_ETH_NODE_ADDRESS=${{ secrets.VITE_ETH_NODE_ADDRESS }}
Expand All @@ -80,38 +51,26 @@ jobs:
VITE_INDEXER_ADDRESS=${{ secrets.VITE_INDEXER_ADDRESS }}
VITE_BRIDGING_PAYMENT_CONTRACT_ADDRESS=${{ secrets.VITE_BRIDGING_PAYMENT_CONTRACT_ADDRESS }}
VITE_ETH_BRIDGING_PAYMENT_CONTRACT_ADDRESS=${{ secrets.VITE_ETH_BRIDGING_PAYMENT_CONTRACT_ADDRESS }}
VITE_WRAPPED_VARA_CONTRACT_ADDRESS=${{ secrets.VITE_WRAPPED_VARA_CONTRACT_ADDRESS }}
deploy-to-k8s:
needs: [prepair, build-and-push-image]
deploy-to-k8s-staging:
needs:
[build-frontend-image-staging]
runs-on: ubuntu-latest
environment: ${{ (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && 'prod' || 'stg' }}

steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Update deployment image
uses: kodermax/kubectl-aws-eks@main
- name: Deploy to k8s
uses: sergeyfilyanin/kubectl-aws-eks@master
with:
args: |
set image deployment/${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }} \
${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }}=${{ needs.prepair.outputs.image_name }} \
-n ${{ env.KUBE_NAMESPACE }}
- name: Restart deployment
uses: kodermax/kubectl-aws-eks@main
with:
args: |
rollout restart deployment/${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }} \
-n ${{ env.KUBE_NAMESPACE }}
- name: Check deployment
uses: kodermax/kubectl-aws-eks@main
args: rollout restart deployment zk-bridge-stg -n zk-bridge
- name: Check k8s deployments
uses: sergeyfilyanin/kubectl-aws-eks@master
with:
args: |
rollout status deployment/${{ env.KUBE_DEPLOYMENT_PREFIX }}-${{ env.ENVIRONMENT }} \
--timeout=240s \
-n ${{ env.KUBE_NAMESPACE }}
args: get deployment -o name -n zk-bridge | xargs -n1 -t kubectl rollout status -n zk-bridge --timeout=120s
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ out/
ethereum/broadcast

.env
.DS_Store

node_modules/
indexer/lib/
indexer/assets/
11 changes: 7 additions & 4 deletions .dockerignore → Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Rust build directory
target

# Resource files
# Resource files
audits
images
LICENSE
*.md
api

# Git
# Git
.git
.gitignore
.github

# IDE-generated files
# IDE-generated files
.vscode
.idea

Expand All @@ -28,5 +28,8 @@ ethereum/cache
ethereum/out
ethereum/broadcast

# Indexer-related
indexer/

# Frontend
frontend
frontend/
1 change: 1 addition & 0 deletions frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ VITE_WALLET_CONNECT_PROJECT_ID=
VITE_INDEXER_ADDRESS=
VITE_BRIDGING_PAYMENT_CONTRACT_ADDRESS=
VITE_ETH_BRIDGING_PAYMENT_CONTRACT_ADDRESS=
VITE_WRAPPED_VARA_CONTRACT_ADDRESS=
6 changes: 4 additions & 2 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ ARG VITE_VARA_NODE_ADDRESS \
VITE_WALLET_CONNECT_PROJECT_ID \
VITE_INDEXER_ADDRESS \
VITE_BRIDGING_PAYMENT_CONTRACT_ADDRESS \
VITE_ETH_BRIDGING_PAYMENT_CONTRACT_ADDRESS
VITE_ETH_BRIDGING_PAYMENT_CONTRACT_ADDRESS \
VITE_WRAPPED_VARA_CONTRACT_ADDRESS

ENV VITE_VARA_NODE_ADDRESS=${VITE_VARA_NODE_ADDRESS} \
VITE_ETH_NODE_ADDRESS=${VITE_ETH_NODE_ADDRESS} \
VITE_ETH_CHAIN_ID=${VITE_ETH_CHAIN_ID} \
VITE_WALLET_CONNECT_PROJECT_ID=${VITE_WALLET_CONNECT_PROJECT_ID} \
VITE_INDEXER_ADDRESS=${VITE_INDEXER_ADDRESS} \
VITE_BRIDGING_PAYMENT_CONTRACT_ADDRESS=${VITE_BRIDGING_PAYMENT_CONTRACT_ADDRESS} \
VITE_ETH_BRIDGING_PAYMENT_CONTRACT_ADDRESS=${VITE_ETH_BRIDGING_PAYMENT_CONTRACT_ADDRESS}
VITE_ETH_BRIDGING_PAYMENT_CONTRACT_ADDRESS=${VITE_ETH_BRIDGING_PAYMENT_CONTRACT_ADDRESS} \
VITE_WRAPPED_VARA_CONTRACT_ADDRESS=${VITE_WRAPPED_VARA_CONTRACT_ADDRESS}

RUN pnpm install

Expand Down
14 changes: 7 additions & 7 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"codegen": "graphql-codegen"
},
"dependencies": {
"@gear-js/api": "0.38.1",
"@gear-js/react-hooks": "0.12.2",
"@gear-js/api": "0.39.0",
"@gear-js/react-hooks": "0.14.0",
"@gear-js/vara-ui": "0.0.10",
"@hookform/resolvers": "3.9.0",
"@polkadot/api": "11.0.2",
"@polkadot/react-identicon": "3.9.1",
"@tanstack/react-query": "5.52.1",
"@polkadot/api": "14.3.1",
"@polkadot/react-identicon": "3.11.3",
"@tanstack/react-query": "5.61.5",
"@web3modal/wagmi": "5.1.3",
"graphql": "16.9.0",
"graphql-request": "7.1.0",
Expand All @@ -26,7 +26,7 @@
"react-hook-form": "7.52.2",
"react-number-format": "5.4.0",
"react-router-dom": "6.26.1",
"sails-js": "0.1.8",
"sails-js": "0.3.0",
"viem": "2.19.6",
"wagmi": "2.12.7",
"zod": "3.23.8"
Expand All @@ -35,7 +35,7 @@
"@graphql-codegen/cli": "5.0.2",
"@graphql-codegen/client-preset": "4.3.3",
"@graphql-typed-document-node/core": "3.2.0",
"@polkadot/types": "11.0.2",
"@polkadot/types": "14.3.1",
"@types/react": "18.3.4",
"@types/react-dom": "18.3.0",
"@typescript-eslint/eslint-plugin": "8.2.0",
Expand Down
Loading

0 comments on commit 33e6de9

Please sign in to comment.