From c3598fd53e947bff9d657fa0f6aec81d2e0479a8 Mon Sep 17 00:00:00 2001 From: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com> Date: Mon, 16 Sep 2024 14:33:59 +0300 Subject: [PATCH] fix: tidy-up CI (#191) * fix: tidy-up CI * fix: make ci work on all PRs --- ...api-deploy.yml => auto-api-deploy-dev.yml} | 7 +- ...emix-deploy.yml => auto-ui-deploy-dev.yml} | 0 .github/workflows/devnet-deploy.yml | 102 ------------------ .github/workflows/devnet-prod-deploy.yml | 102 ------------------ .github/workflows/rust-checks.yml | 64 +++++++++++ .github/workflows/rust-linting.yml | 30 ------ .github/workflows/ui-linting.yml | 5 +- DockerfileApiServer | 41 ------- DockerfileDevnet | 25 ----- api/Cargo.toml | 14 +-- api/Rocket.toml | 2 +- config.nginx | 18 ---- supervisord.conf | 19 ---- 13 files changed, 77 insertions(+), 352 deletions(-) rename .github/workflows/{api-deploy.yml => auto-api-deploy-dev.yml} (97%) rename .github/workflows/{remix-deploy.yml => auto-ui-deploy-dev.yml} (100%) delete mode 100644 .github/workflows/devnet-deploy.yml delete mode 100644 .github/workflows/devnet-prod-deploy.yml create mode 100644 .github/workflows/rust-checks.yml delete mode 100644 .github/workflows/rust-linting.yml delete mode 100644 DockerfileApiServer delete mode 100644 DockerfileDevnet delete mode 100644 config.nginx delete mode 100644 supervisord.conf diff --git a/.github/workflows/api-deploy.yml b/.github/workflows/auto-api-deploy-dev.yml similarity index 97% rename from .github/workflows/api-deploy.yml rename to .github/workflows/auto-api-deploy-dev.yml index 5b27409c..d6e485d2 100644 --- a/.github/workflows/api-deploy.yml +++ b/.github/workflows/auto-api-deploy-dev.yml @@ -5,11 +5,11 @@ on: - develop paths: - 'api/**' - - '.github/workflows/api-deploy.yml' + - 'auto-api-deploy-dev.yml' permissions: - id-token: write - contents: read + id-token: write + contents: read env: REGISTRY: "599564732950.dkr.ecr.us-east-2.amazonaws.com" @@ -77,7 +77,6 @@ jobs: REPOSITORY: ${{ env.REPOSITORY }} IMAGE_TAG: ${{ steps.determine-version.outputs.version }} # ${{ github.run_number }} - # docker build --target final -t $REGISTRY/$REPOSITORY:apiserver-$IMAGE_TAG -f ./DockerfileApiServer . run: | docker build -t $REGISTRY/$REPOSITORY:apiserver-$IMAGE_TAG -f ./DockerfileRocket . docker push $REGISTRY/$REPOSITORY:apiserver-$IMAGE_TAG diff --git a/.github/workflows/remix-deploy.yml b/.github/workflows/auto-ui-deploy-dev.yml similarity index 100% rename from .github/workflows/remix-deploy.yml rename to .github/workflows/auto-ui-deploy-dev.yml diff --git a/.github/workflows/devnet-deploy.yml b/.github/workflows/devnet-deploy.yml deleted file mode 100644 index f259ee17..00000000 --- a/.github/workflows/devnet-deploy.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: (develop) Manual devnet deploy -on: - workflow_dispatch: - inputs: - version: - description: 'Devnet version tag' - required: true - type: string - default: 'v0.1.0-alpha.10' - -permissions: - id-token: write - contents: read - -env: - REGISTRY: "599564732950.dkr.ecr.us-east-2.amazonaws.com" - REPOSITORY: "zksync-remix-plugin" - DEV_CLUSTER: "zksync-remix-plugin-ecs-cluster" - DEV_SERVICE_NAME: "devnet-development-svc" - PROD_CLUSTER: "zksync-remix-plugin-production-ecs-cluster" - PROD_SERVICE_NAME: "devnet-production-svc" -jobs: - - Build: - runs-on: ubuntu-latest - steps: - - name: Clone repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Determine version numbers - id: determine-version - uses: paulhatch/semantic-version@v5.2.1 - with: - tag_prefix: "v" - major_pattern: "(MAJOR)" - major_regexp_flags: "" - minor_pattern: "(MINOR)" - minor_regexp_flags: "" - version_format: "${major}.${minor}.${patch}-dev${increment}" - bump_each_commit: false - bump_each_commit_patch_pattern: "" - search_commit_body: false - user_format_type: "csv" - enable_prerelease_mode: true - debug: false - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-region: us-east-2 - role-to-assume: arn:aws:iam::599564732950:role/Aws-GH-Action-Assume-Role-ZKSync - role-session-name: GHZKSync - - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 - with: - mask-password: 'true' - - - name: Build, tag, and push docker image to Amazon ECR - env: - REGISTRY: ${{ steps.login-ecr.outputs.registry }} - REPOSITORY: ${{ env.REPOSITORY }} - IMAGE_TAG: ${{ steps.determine-version.outputs.version }} # ${{ github.run_number }} - LATEST_RELEASE: ${{ inputs.version }} - run: | - docker build --build-arg LATEST_RELEASE=$LATEST_RELEASE -t $REGISTRY/$REPOSITORY:devnet-$IMAGE_TAG -f ./DockerfileDevnet . - docker push $REGISTRY/$REPOSITORY:devnet-$IMAGE_TAG - outputs: - image-version: ${{ steps.determine-version.outputs.version }} - Deploy_Dev: - runs-on: ubuntu-latest - needs: Build - steps: - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-region: us-east-2 - role-to-assume: arn:aws:iam::599564732950:role/Aws-GH-Action-Assume-Role-ZKSync - role-session-name: GHZKSync - - - name: Download task definition - run: | - aws ecs describe-task-definition --task-definition zksync-remix-development-devnet --query taskDefinition > task-definition.json - - - name: Update the task definition to use the image from Docker Hub - id: task-def - uses: aws-actions/amazon-ecs-render-task-definition@v1 - with: - task-definition: task-definition.json - container-name: "devnet" - image: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:devnet-${{ needs.Build.outputs.image-version }} - - name: Deploy Amazon ECS task definition - uses: aws-actions/amazon-ecs-deploy-task-definition@v1 - with: - task-definition: ${{ steps.task-def.outputs.task-definition }} - service: ${{ env.DEV_SERVICE_NAME }} - cluster: ${{ env.DEV_CLUSTER }} - wait-for-service-stability: true diff --git a/.github/workflows/devnet-prod-deploy.yml b/.github/workflows/devnet-prod-deploy.yml deleted file mode 100644 index e1b5b08b..00000000 --- a/.github/workflows/devnet-prod-deploy.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: (prod) Manual devnet deploy -on: - workflow_dispatch: - inputs: - version: - description: 'Devnet version tag' - required: true - type: string - default: 'v0.1.0-alpha.10' - -permissions: - id-token: write - contents: read - -env: - REGISTRY: "599564732950.dkr.ecr.us-east-2.amazonaws.com" - REPOSITORY: "zksync-remix-plugin" - DEV_CLUSTER: "zksync-remix-plugin-ecs-cluster" - DEV_SERVICE_NAME: "devnet-development-svc" - PROD_CLUSTER: "zksync-remix-plugin-production-ecs-cluster" - PROD_SERVICE_NAME: "devnet-production-svc" -jobs: - - Build: - runs-on: ubuntu-latest - steps: - - name: Clone repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Determine version numbers - id: determine-version - uses: paulhatch/semantic-version@v5.2.1 - with: - tag_prefix: "v" - major_pattern: "(MAJOR)" - major_regexp_flags: "" - minor_pattern: "(MINOR)" - minor_regexp_flags: "" - version_format: "${major}.${minor}.${patch}-dev${increment}" - bump_each_commit: false - bump_each_commit_patch_pattern: "" - search_commit_body: false - user_format_type: "csv" - enable_prerelease_mode: true - debug: false - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-region: us-east-2 - role-to-assume: arn:aws:iam::599564732950:role/Aws-GH-Action-Assume-Role-ZKSync - role-session-name: GHZKSync - - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 - with: - mask-password: 'true' - - - name: Build, tag, and push docker image to Amazon ECR - env: - REGISTRY: ${{ steps.login-ecr.outputs.registry }} - REPOSITORY: ${{ env.REPOSITORY }} - IMAGE_TAG: ${{ steps.determine-version.outputs.version }} # ${{ github.run_number }} - LATEST_RELEASE: ${{ inputs.version }} - run: | - docker build --build-arg LATEST_RELEASE=$LATEST_RELEASE -t $REGISTRY/$REPOSITORY:devnet-$IMAGE_TAG -f ./DockerfileDevnet . - docker push $REGISTRY/$REPOSITORY:devnet-$IMAGE_TAG - outputs: - image-version: ${{ steps.determine-version.outputs.version }} - Deploy_Prod: - runs-on: ubuntu-latest - needs: Build - steps: - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-region: us-east-2 - role-to-assume: arn:aws:iam::228016254426:role/Aws-GH-Action-Assume-Role-ZKSync-Production - role-session-name: GHZKSync - - - name: Download task definition - run: | - aws ecs describe-task-definition --task-definition zksync-remix-production-devnet --query taskDefinition > task-definition.json - - - name: Update the task definition to use the image from Docker Hub - id: task-def - uses: aws-actions/amazon-ecs-render-task-definition@v1 - with: - task-definition: task-definition.json - container-name: "devnet" - image: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:devnet-${{ needs.Build.outputs.image-version }} - - name: Deploy Amazon ECS task definition - uses: aws-actions/amazon-ecs-deploy-task-definition@v1 - with: - task-definition: ${{ steps.task-def.outputs.task-definition }} - service: ${{ env.PROD_SERVICE_NAME }} - cluster: ${{ env.PROD_CLUSTER }} - wait-for-service-stability: true diff --git a/.github/workflows/rust-checks.yml b/.github/workflows/rust-checks.yml new file mode 100644 index 00000000..0fb74f43 --- /dev/null +++ b/.github/workflows/rust-checks.yml @@ -0,0 +1,64 @@ +name: (ci/cd) Rust Checks + +on: + pull_request: + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - run: cd api && cargo build --all + + rustfmt: + name: Rustfmt + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + override: true + components: rustfmt + - run: cd api && cargo +nightly fmt --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + components: clippy + - run: cd api && cargo clippy --all -- -D warnings + + taplo: + name: Taplo + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - uses: baptiste0928/cargo-install@v3 + with: + crate: taplo-cli + version: "0.9.0" + locked: true + - run: taplo format --check --diff 1>&2 + + machete: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Detect unused dependencies with Machete + uses: bnjbvr/cargo-machete@main \ No newline at end of file diff --git a/.github/workflows/rust-linting.yml b/.github/workflows/rust-linting.yml deleted file mode 100644 index 666bad98..00000000 --- a/.github/workflows/rust-linting.yml +++ /dev/null @@ -1,30 +0,0 @@ -on: - pull_request: - branches: - - develop - -jobs: - rustfmt: - name: Rustfmt - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - components: rustfmt - - run: cd api && cargo +nightly fmt --all -- --check - - clippy: - name: Clippy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - components: clippy - - run: cd api && cargo clippy --all -- -D warnings diff --git a/.github/workflows/ui-linting.yml b/.github/workflows/ui-linting.yml index 3fff3a95..d36acb0e 100644 --- a/.github/workflows/ui-linting.yml +++ b/.github/workflows/ui-linting.yml @@ -1,10 +1,7 @@ -name: 'UI: Lint' +name: '(ci/cd) UI: Lint' on: pull_request: - branches: - - develop - - release/* env: NODE_VERSION: '20.x' diff --git a/DockerfileApiServer b/DockerfileApiServer deleted file mode 100644 index d08c0803..00000000 --- a/DockerfileApiServer +++ /dev/null @@ -1,41 +0,0 @@ -FROM ubuntu:20.04 AS build - -ENV DEBIAN_FRONTEND=noninteractive -ENV DEBCONF_NONINTERACTIVE_SEEN=true - -RUN apt-get update -RUN apt-get install -y curl \ - git \ - cmake \ - build-essential \ - gcc - -WORKDIR /opt/app - -COPY . /opt/app - -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y - -RUN whoami - -ENV PATH="/root/.cargo/bin:${PATH}" - -RUN git submodule update --init - -WORKDIR /opt/app/api - -RUN cargo build - - - - -FROM ubuntu:20.04 AS final - -WORKDIR /opt/app - -COPY ./api/target/debug/* /opt/app - -EXPOSE 8000 - -ENTRYPOINT [ "api" ] - diff --git a/DockerfileDevnet b/DockerfileDevnet deleted file mode 100644 index e0a6baec..00000000 --- a/DockerfileDevnet +++ /dev/null @@ -1,25 +0,0 @@ -FROM ubuntu:latest -ARG LATEST_RELEASE -WORKDIR /app -RUN apt-get update \ - && apt-get install -y curl jq supervisor nginx \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -RUN echo "In memory node version: ${LATEST_RELEASE}" - -# Download the release version specified by the build argument -RUN curl -s echo "https://api.github.com/repos/matter-labs/era-test-node/releases/tags/${LATEST_RELEASE}" | \ - jq -r '.assets[] | select(.name | contains("x86_64-unknown-linux-gnu")) | .browser_download_url' | \ - head -n 1 | xargs -I {} curl -L -o era_test_node.tar.gz {} - -# Extract binary and make it executable -RUN tar xz -f era_test_node.tar.gz -C /usr/local/bin/ -RUN chmod +x /usr/local/bin/era_test_node - -COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf -COPY config.nginx /etc/nginx/config.nginx - -EXPOSE 5050 - -CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/api/Cargo.toml b/api/Cargo.toml index 0313a0e0..2c67230d 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -7,15 +7,17 @@ edition = "2021" [dependencies] rocket = { version = "0.5.0-rc.4", features = ["json"] } -rand = "0.8" serde = { version = "1.0.152", features = ["derive"] } tracing = "^0.1" -tracing-subscriber = { version = "^0.3.17", features=["env-filter", "json", "registry", "smallvec"]} +tracing-subscriber = { version = "^0.3.17", features = [ + "env-filter", + "json", + "registry", + "smallvec", +] } tracing-appender = "0.2" tracing-log = "0.1.3" -crossbeam = "0.8.2" uuid = { version = "1.4.1", features = ["serde", "v4"] } -futures = "0.3.28" solang-parser = "0.3.2" crossbeam-queue = "0.3.8" crossbeam-skiplist = "0.1.1" @@ -26,5 +28,5 @@ chrono = "0.4.31" clokwerk = "0.4.0" walkdir = "2.3.2" lazy_static = "1.5.0" -tokio = {version = "1.38.0", features = ["process"]} -prometheus = "0.13.4" \ No newline at end of file +tokio = { version = "1.38.0", features = ["process"] } +prometheus = "0.13.4" diff --git a/api/Rocket.toml b/api/Rocket.toml index ec599ff0..4217947c 100644 --- a/api/Rocket.toml +++ b/api/Rocket.toml @@ -2,4 +2,4 @@ address = "0.0.0.0" [default.limits] -json = "10 MiB" \ No newline at end of file +json = "10 MiB" diff --git a/config.nginx b/config.nginx deleted file mode 100644 index 6b042591..00000000 --- a/config.nginx +++ /dev/null @@ -1,18 +0,0 @@ -http { - server { - listen 5050; - - location /is_alive { - add_header Content-Type text/plain; - return 200 'ok'; - } - - location / { - proxy_pass http://127.0.0.1:8011; - } - } - -} -events { - -} diff --git a/supervisord.conf b/supervisord.conf deleted file mode 100644 index 574dfb8a..00000000 --- a/supervisord.conf +++ /dev/null @@ -1,19 +0,0 @@ -[supervisord] -nodaemon=true -logfile=/var/log/supervisor/supervisord.log -pidfile=/var/run/supervisord.pid -childlogdir=/var/log/supervisor - -[program:nginx] -command=/usr/sbin/nginx -g "daemon off;" -c /etc/nginx/config.nginx -autostart=true -autorestart=true -stdout_logfile=/var/log/nginx/access.log -stderr_logfile=/var/log/nginx/error.log - -[program:era_test_node] -command=/usr/local/bin/era_test_node run -autostart=true -autorestart=true -stdout_logfile=/var/log/era_test_node.log -stderr_logfile=/var/log/era_test_node.log