Skip to content

Commit

Permalink
Merge branch 'dev' into perekopskiy-zks-743-implement-architecture-fo…
Browse files Browse the repository at this point in the history
…r-ethereum-like
  • Loading branch information
Deniallugo authored Aug 9, 2021
2 parents 68bcf49 + 80cf617 commit defad1e
Show file tree
Hide file tree
Showing 53 changed files with 919 additions and 621 deletions.
99 changes: 66 additions & 33 deletions .github/workflows/deploy-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Deploy Apps
on:
deployment:

defaults:
run:
shell: bash -leo pipefail {0}

env:
DEPLOY_APPS: -l name=server -l name=prover

Expand All @@ -12,41 +16,36 @@ jobs:
steps:
- uses: actions/checkout@v2
-
id: print
run: echo "::set-output name=shortRev::$(git rev-parse --short HEAD)"
id: config
run: |
environment=${{ github.event.deployment.environment }}
echo "::set-output name=shortRev::$(git rev-parse --short HEAD)"
echo "::set-output name=environment::${environment}"
-
uses: actions-ecosystem/action-regex-match@v2
id: regex-match
with:
text: ${{ github.ref }}
regex: '^refs\/tags\/(v[0-9]+\.[0-9]+\.[0-9](-?.*)?)$'
regex: '^refs\/tags\/((v[0-9]+\.[0-9]+\.[0-9])(-?.*)?)$'
-
name: Map runtime environment data
uses: kanga333/[email protected]
id: envMap
uses: kanga333/[email protected]
with:
key: "${{ github.event.deployment.environment }}"
key: ${{ steps.config.outputs.environment }}
export_to: output
mode: overwrite
map: |
{
"^mainnet$": {
"KUBECONF": "KUBECONF_MAINNET",
"HFENV": "prod",
"RUNNER": "mainnet"
},
"^rinkeby$": {
"KUBECONF": "KUBECONF_TESTNET",
"HFENV": "${{ github.event.deployment.environment }}",
"RUNNER": "testnet"
},
"^ropsten$": {
"KUBECONF": "KUBECONF_TESTNET",
"HFENV": "${{ github.event.deployment.environment }}",
"RUNNER": "testnet"
},
".*": {
"KUBECONF": "KUBECONF_STAGE",
"HFENV": "${{ github.event.deployment.environment }}",
"RUNNER": "stage"
}
"hfEnv": "${{ steps.config.outputs.environment }}",
"kubeConf": "KUBECONF_STAGE",
"runner": "stage",
"namespace": "${{ steps.config.outputs.environment }}"
},
"^rinkeby$": { "kubeConf": "KUBECONF_TESTNET", "runner": "testnet" },
"^ropsten$": { "kubeConf": "KUBECONF_TESTNET", "runner": "testnet" },
"^mainnet$": { "kubeConf": "KUBECONF_MAINNET", "runner": "mainnet", "hfEnv": "prod", "namespace": "zksync" }
}
-
name: Cancel deployment (deployment tag missmatch)
Expand All @@ -58,25 +57,60 @@ jobs:
deployment_id: ${{ github.event.deployment.id }}

outputs:
shortRev: ${{ steps.print.outputs.shortRev }}
kubeConf: ${{ env.KUBECONF }}
hfEnv: ${{ env.HFENV }}
runner: ${{ env.RUNNER }}
shortRev: ${{ steps.config.outputs.shortRev }}
environment: ${{ steps.config.outputs.environment }}
kubeConf: ${{ steps.envMap.outputs.kubeConf }}
hfEnv: ${{ steps.envMap.outputs.hfEnv }}
namespace: ${{ steps.envMap.outputs.namespace }}
runner: ${{ steps.envMap.outputs.runner }}
isTag: ${{ steps.regex-match.outputs.group1 != '' }}
configTag: ${{ steps.regex-match.outputs.group2 }}

updateConfig:
name: update config
needs: [pre]
runs-on: [k8s, deployer, "${{ needs.pre.outputs.runner }}"]
container:
image: dysnix/kubectl:v1.19-gcloud
env:
IMAGE_TAG: ${{ needs.pre.outputs.shortRev }}
KUBECONF: ${{ secrets[needs.pre.outputs.kubeConf] }}
ENVFILE: ./compiled_envs/${{ needs.pre.outputs.environment }}.env
steps:
-
if: ${{ needs.pre.outputs.isTag == 'true' }}
name: Create ~/.kube/config
run: mkdir -p ~/.kube && echo "$KUBECONF" | base64 -d > ~/.kube/config
-
if: ${{ needs.pre.outputs.isTag == 'true' }}
name: Clone configs
uses: actions/checkout@v2
with:
repository: matter-labs/configs
path: configs
ref: ${{ needs.pre.outputs.configTag }}
token: ${{ secrets.GH_TOKEN }}
-
if: ${{ needs.pre.outputs.isTag == 'true' }}
name: Update Server Config
working-directory: configs
run: |
sudo apk --no-cache add yarn
./bin/config
./bin/config compile ${{ needs.pre.outputs.environment }}
kubectl delete configmap -n ${{ needs.pre.outputs.namespace }} server-env-custom || /bin/true
kubectl create configmap -n ${{ needs.pre.outputs.namespace }} server-env-custom --from-env-file=${{ env.ENVFILE }}
deploy:
name: Deploy Apps
runs-on: [k8s, deployer, "${{ needs.pre.outputs.runner }}"]
needs: pre

container:
image: dysnix/kubectl:v1.19-gcloud

env:
IMAGE_TAG: ${{ needs.pre.outputs.shortRev }}
KUBECONF: ${{ secrets[needs.pre.outputs.kubeConf] }}
HFENV: ${{ needs.pre.outputs.hfEnv }}

steps:
-
if: ${{ needs.pre.outputs.isTag == 'true' }}
Expand All @@ -89,7 +123,6 @@ jobs:
with:
repository: matter-labs/helm-infra
path: helm-infra
ref: new-health-and-conf
token: ${{ secrets.GH_TOKEN }}
-
if: ${{ needs.pre.outputs.isTag == 'true' }}
Expand Down Expand Up @@ -123,7 +156,7 @@ jobs:
uses: tferreira/matterfy@releases/v1
with:
type: ${{ job.status }}
job_name: '*Deployment to "${{ github.event.deployment.environment }}" failed*'
job_name: '*Deployment to "${{ steps.config.outputs.environment }}" failed*'
icon_emoji: octocat
channel: 'matterlabs-alerts'
url: ${{ secrets.MATTERMOST_WEBHOOK }}
105 changes: 24 additions & 81 deletions .github/workflows/deploy-stage.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
name: Deploy Stage

name: Build and Deploy Stage
on:
push:
branches:
- dev
- breaking

env:
DEPLOY_APPS: -l name=server -l name=prover -l name=explorer

jobs:
pre:
setup:
name: Setup
runs-on: [k8s, stage]
outputs:
image_tag: ${{ steps.set.outputs.shortRev }}
steps:
- uses: actions/checkout@v2
- id: print
- id: set
run: echo "::set-output name=shortRev::$(git rev-parse --short HEAD)"

outputs:
shortRev: ${{ steps.print.outputs.shortRev }}

build-images:
name: Build and Push Docker Images
runs-on: [self-hosted, MAIN]
needs: pre

## Required services
services:
Expand All @@ -34,7 +29,6 @@ jobs:

steps:
- uses: actions/checkout@v2

- name: setup-env
run: |
echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
Expand All @@ -53,72 +47,21 @@ jobs:
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
zk docker push rust
## !!! TODO: fix stage and enable deployments back.
## !!! TODO: breaking deployment is not supported.
# deploy:
# name: Deploy to the Stage enviroment
# runs-on: [k8s, deployer, stage]
# needs: [pre, build-images]

# container:
# image: dysnix/kubectl:v1.19-gcloud

# env:
# KUBECONF: ${{ secrets.KUBECONF_STAGE }}
# IMAGE_TAG: ${{ needs.pre.outputs.shortRev }}
# HFENV: stage

# steps:
# -
# name: Create ~/.kube/config
# run: mkdir -p ~/.kube && echo "$KUBECONF" | base64 -d > ~/.kube/config
# -
# name: Clone helm-infra
# uses: actions/checkout@v2
# with:
# repository: matter-labs/helm-infra
# path: helm-infra
# ref: master
# token: ${{ secrets.GH_TOKEN }}
# -
# uses: chrnorm/deployment-action@releases/v1
# name: Create GitHub deployment
# id: deployment
# with:
# token: "${{ github.token }}"
# environment: stage
# -
# name: Deploy apps
# working-directory: helm-infra
# run: |
# # copy helm plugins over (from dysnix/kubectl, don't forget)!!!
# cp -r /dysnix/kubectl/.local /dysnix/kubectl/.cache ~

# UPDATE_REPOS=y helmfile -e $HFENV repos
# helmfile -e $HFENV $DEPLOY_APPS apply --args "timeout 180s"
# -
# name: Update deployment status (success)
# if: success()
# uses: chrnorm/deployment-status@releases/v1
# with:
# token: ${{ github.token }}
# state: success
# deployment_id: ${{ steps.deployment.outputs.deployment_id }}
# -
# name: Update deployment status (failure)
# if: failure()
# uses: chrnorm/deployment-status@releases/v1
# with:
# token: ${{ github.token }}
# state: failure
# deployment_id: ${{ steps.deployment.outputs.deployment_id }}
# -
# name: Notify to Mattermost (on failure)
# uses: tferreira/matterfy@releases/v1
# if: failure()
# with:
# type: ${{ job.status }}
# job_name: '*Deployment to stage failed*'
# icon_emoji: octocat
# channel: 'matterlabs-alerts'
# url: ${{ secrets.MATTERMOST_WEBHOOK }}
# Reminder: when disabling the deploy stage - comment the whole job out!
deploy:
name: Deploy Stage environment
runs-on: [k8s, deployer, stage]
needs: [setup, build-images]
steps:
- name: Deploy
uses: aurelien-baudet/workflow-dispatch@v2
with:
workflow: Deploy
token: ${{ secrets.GH_TOKEN }}
wait-for-completion-timeout: 10m
wait-for-completion-interval: 1m
inputs: |
{
"environment": "stage",
"image_tag": "${{ needs.setup.outputs.image_tag }}"
}
Loading

0 comments on commit defad1e

Please sign in to comment.