git.delta.rocks / unique-network / refs/commits / ce1b3ca1bc40

difftreelog

Merge pull request #2 from lzadjsf/ci-build-workflow-v3

Alex2022-08-01parents: #2232fc1 #80975a9.patch.diff
in: master
Re-created branch with changes related to STEP1 task.

10 files changed

added.docker/Dockerfile-chain-devdiffbeforeafterboth
--- /dev/null
+++ b/.docker/Dockerfile-chain-dev
@@ -0,0 +1,35 @@
+FROM ubuntu:20.04
+
+ENV DEBIAN_FRONTEND=noninteractive
+ENV TZ=Etc/UTC
+
+RUN apt-get update && apt-get install -y git curl libssl-dev llvm pkg-config libclang-dev clang git make cmake
+
+ENV CARGO_HOME="/cargo-home"
+ENV PATH="/cargo-home/bin:$PATH"
+
+RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none
+
+ARG RUST_TOOLCHAIN=nightly-2022-04-07
+ARG BRANCH=develop
+ARG REPO_URL=https://github.com/UniqueNetwork/unique-chain.git
+ARG FEATURE=
+
+RUN rustup toolchain uninstall $(rustup toolchain list) && \
+    rustup toolchain install $RUST_TOOLCHAIN && \
+    rustup default $RUST_TOOLCHAIN && \
+    rustup target add wasm32-unknown-unknown --toolchain $RUST_TOOLCHAIN
+
+RUN mkdir /dev_chain && git clone $REPO_URL /dev_chain && cd /dev_chain && git checkout $BRANCH
+WORKDIR /dev_chain
+
+RUN cargo build --release
+
+EXPOSE 9844
+EXPOSE 9944
+EXPOSE 9933
+EXPOSE 9833
+EXPOSE 40333
+EXPOSE 30333
+
+CMD cargo run --release $FEATURE -- --dev -linfo --unsafe-ws-external --rpc-cors=all --unsafe-rpc-external
added.docker/Dockerfile-parachaindiffbeforeafterboth
--- /dev/null
+++ b/.docker/Dockerfile-parachain
@@ -0,0 +1,114 @@
+# ===== Rust builder =====
+FROM phusion/baseimage:focal-1.1.0 as rust-builder
+LABEL maintainer="Unique.Network"
+
+ARG RUST_TOOLCHAIN=nightly-2022-05-11
+#ARG RUST_C=1.62.0-nightly
+ARG POLKA_VERSION=release-v0.9.24
+ARG UNIQUE_BRANCH=develop
+
+#ARG USER=***
+#ARG PASS=***
+
+
+ENV RUST_TOOLCHAIN $RUST_TOOLCHAIN
+#ENV RUST_C $RUST_C
+ENV POLKA_VERSION $POLKA_VERSION
+ENV UNIQUE_BRANCH $UNIQUE_BRANCH
+
+
+#RUN echo $RUST_TOOLCHAIN
+#RUN echo $RUST_C
+#RUN echo $POLKA_VERSION
+#RUN echo $UNIQUE_BRANCH
+
+ENV CARGO_HOME="/cargo-home"
+ENV PATH="/cargo-home/bin:$PATH"
+
+RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none
+
+RUN apt-get update && \
+    apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" && \
+    apt-get install -y cmake pkg-config libssl-dev git clang
+
+RUN rustup toolchain uninstall $(rustup toolchain list) && \
+    rustup toolchain install $RUST_TOOLCHAIN && \
+    rustup default $RUST_TOOLCHAIN && \
+    rustup target list --installed && \
+    rustup show
+RUN rustup target add wasm32-unknown-unknown --toolchain $RUST_TOOLCHAIN
+
+RUN cargo install cargo-chef
+
+RUN mkdir unique_parachain
+WORKDIR /unique_parachain
+
+# ===== Chef =====
+FROM rust-builder as chef
+
+COPY . .
+RUN cargo chef prepare --recipe-path recipe.json
+
+# ===== BUILD ======
+FROM rust-builder as builder
+
+RUN mkdir unique_parachain
+WORKDIR /unique_parachain
+
+COPY --from=chef /unique_parachain/recipe.json recipe.json
+ARG PROFILE=release
+RUN cargo chef cook "--$PROFILE" --recipe-path recipe.json
+
+COPY . .
+RUN cargo build "--$PROFILE"
+   # && \
+   # cargo test
+
+# ===== BUILD POLKADOT =====
+FROM rust-builder as builder-polkadot
+
+RUN mkdir unique_parachain
+WORKDIR /unique_parachain
+
+RUN git clone -b $POLKA_VERSION --depth 1 https://github.com/paritytech/polkadot.git && \
+    cd polkadot && \
+    git tag -n && \
+	cargo build --release
+
+# ===== RUN ======
+
+FROM phusion/baseimage:focal-1.1.0
+
+ARG PROFILE=release
+
+RUN apt-get -y update && \
+      apt-get -y upgrade && \
+      apt-get -y install curl git && \
+      curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash && \
+      export NVM_DIR="$HOME/.nvm" && \
+      [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
+      nvm install v15.5.0 && \
+      nvm use v15.5.0
+
+RUN git clone https://github.com/paritytech/polkadot-launch
+
+RUN export NVM_DIR="$HOME/.nvm" && \
+    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
+    cd /polkadot-launch && \
+    npm install --global yarn && \
+    yarn
+
+COPY --from=builder /unique_parachain/target/$PROFILE/unique-collator /unique-chain/target/$PROFILE/
+COPY --from=builder-polkadot /unique_parachain/polkadot/target/$PROFILE/polkadot /polkadot/target/$PROFILE/
+
+EXPOSE 9844
+EXPOSE 9944
+EXPOSE 9933
+EXPOSE 9833
+EXPOSE 40333
+EXPOSE 30333
+
+CMD export NVM_DIR="$HOME/.nvm" && \
+    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
+    cd /polkadot-launch && \
+    yarn start launch-config.json
added.docker/Dockerfile-parachain-v2diffbeforeafterboth
--- /dev/null
+++ b/.docker/Dockerfile-parachain-v2
@@ -0,0 +1,96 @@
+# ===== Rust builder =====
+FROM phusion/baseimage:focal-1.1.0 as rust-builder
+LABEL maintainer="Unique.Network"
+
+ARG RUST_TOOLCHAIN={{ actual_toolchain }}
+ARG POLKA_VERSION=release-v0.9.24
+
+
+ENV RUST_TOOLCHAIN $RUST_TOOLCHAIN
+ENV POLKA_VERSION $POLKA_VERSION
+
+ENV CARGO_HOME="/cargo-home"
+ENV PATH="/cargo-home/bin:$PATH"
+
+RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none
+
+RUN apt-get update && \
+    apt-get dist-upgrade -y -o Dpkg::Options::="--force-confold" && \
+    apt-get install -y cmake pkg-config libssl-dev git clang
+
+RUN rustup toolchain uninstall $(rustup toolchain list) && \
+    rustup toolchain install $RUST_TOOLCHAIN && \
+    rustup default $RUST_TOOLCHAIN && \
+    rustup target list --installed && \
+    rustup show
+RUN rustup target add wasm32-unknown-unknown --toolchain $RUST_TOOLCHAIN
+
+####works inside repo folder###
+
+
+# ===== BUILD ======
+FROM rust-builder as builder-unique
+
+RUN mkdir unique_parachain
+WORKDIR /unique_parachain
+
+ARG PROFILE='features=quartz-runtime --release'
+
+COPY . .
+RUN cargo build --features=quartz-runtime --release
+   # && \
+   # cargo test
+
+# ===== BUILD POLKADOT =====
+FROM rust-builder as builder-polkadot
+
+RUN mkdir unique_parachain
+WORKDIR /unique_parachain
+
+RUN git clone -b $POLKA_VERSION --depth 1 https://github.com/paritytech/polkadot.git && \
+    cd polkadot && \
+    git tag -n && \
+	cargo build --release
+
+# ===== RUN ======
+
+FROM phusion/baseimage:focal-1.1.0
+
+#ARG PROFILE='--features=quartz-runtime --release'
+
+RUN apt-get -y update && \
+      apt-get -y upgrade && \
+      apt-get -y install curl git && \
+      curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash && \
+      export NVM_DIR="$HOME/.nvm" && \
+      [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
+      nvm install v15.5.0 && \
+      nvm use v15.5.0
+
+RUN git clone https://github.com/UniqueNetwork/polkadot-launch.git && \
+    cd ./polkadot-launch && \
+    git checkout feature/runtime-upgrade-testing
+
+RUN export NVM_DIR="$HOME/.nvm" && \
+    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
+    cd /polkadot-launch && \
+    npm install --global yarn && \
+    yarn
+
+COPY --from=builder-unique /unique_parachain/target/release/unique-collator /unique-chain/target/release/
+COPY --from=builder-polkadot /unique_parachain/polkadot/target/release/polkadot /polkadot/target/release/
+
+COPY ["./launch-config.json", "/polkadot-launch/launch-config.json"]
+
+
+EXPOSE 9844
+EXPOSE 9944
+EXPOSE 9933
+EXPOSE 9833
+EXPOSE 40333
+EXPOSE 30333
+
+CMD export NVM_DIR="$HOME/.nvm" && \
+    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \
+    cd /polkadot-launch && \
+    yarn start launch-config.json
added.docker/docker-compose-dev.yamldiffbeforeafterboth
--- /dev/null
+++ b/.docker/docker-compose-dev.yaml
@@ -0,0 +1,19 @@
+version: "3.5"
+
+services:
+  node-o:
+    build:
+      context: .
+      dockerfile: Dockerfile-chain-dev
+    image: node-o
+    container_name: node-o
+    expose:
+      - 9944
+      - 9933
+    ports:
+      - 127.0.0.1:9944:9944
+      - 127.0.0.1:9933:9933
+    logging:
+      options:
+        max-size: "1m"
+        max-file: "3"
added.docker/docker-compose-tests-parachain.ymldiffbeforeafterboth
--- /dev/null
+++ b/.docker/docker-compose-tests-parachain.yml
@@ -0,0 +1,28 @@
+version: "3.5"
+
+services:
+  blockchain_nodes:
+    build:
+      context: ./
+      dockerfile: Dockerfile-parachain
+      args:
+        - RUST_TOOLCHAIN=${RUST_TOOLCHAIN:?err}
+        - RUST_C=${RUST_C:?err}
+        - POLKA_VERSION=${POLKA_VERSION:?err}
+        - UNIQUE_BRANCH=${UNIQUE_BRANCH:?err}
+    volumes:
+      - ./launch-config.json:/polkadot-launch/launch-config.json
+    env_file:
+      - ./.env
+
+  integration_tests:
+    build:
+      context: tests/
+      dockerfile: Dockerfile-tests
+    environment:
+      RPC_URL: http://blockchain_nodes:9933/
+    volumes:
+      - ./tests/src/config_docker.ts:/unique_parachain/src/config.ts
+      - /home/ubuntu/mochawesome-report:/unique_parachain/mochawesome-report
+    depends_on:
+      - blockchain_nodes
added.docker/docker-compose.tmp.j2diffbeforeafterboth
--- /dev/null
+++ b/.docker/docker-compose.tmp.j2
@@ -0,0 +1,13 @@
+version: "3.5"
+
+services:
+  node-o:
+    build:
+      args:
+        - "RUST_TOOLCHAIN={{ RUST_TOOLCHAIN }}"
+        - "BRANCH={{ BRANCH }}"
+        - "REPO_URL={{ REPO_URL }}"
+        - "FEATURE={{ FEATURE }}"
+
+    command: cargo run --release $FEATURE -- --dev -linfo --unsafe-ws-external --rpc-cors=all --unsafe-rpc-external
+    
modified.github/workflows/codestyle.ymldiffbeforeafterboth
--- a/.github/workflows/codestyle.yml
+++ b/.github/workflows/codestyle.yml
@@ -1,10 +1,16 @@
 name: Code style
 
-on: [push]
+on:
+  pull_request:
+    branches:
+      - develop
+    types:
+      - opened
+      - edited
 
 jobs:
   rustfmt:
-    runs-on: ubuntu-20.04
+    runs-on: self-hosted-ci
 
     steps:
       - uses: actions/checkout@v1
@@ -20,7 +26,7 @@
 
   clippy:
     if: ${{ false }}
-    runs-on: ubuntu-20.04
+    runs-on: self-hosted-ci
 
     steps:
       - uses: actions/checkout@v1
modified.github/workflows/node_build_test.ymldiffbeforeafterboth
before · .github/workflows/node_build_test.yml
1name: Build & test23# Controls when the action will run. 4on:5 # Triggers the workflow on push or pull request events but only for the master branch6  push:7    branches: [ develop ]8 # pull_request:9 #   branches: [ develop ]10  # Allows you to run this workflow manually from the Actions tab11  workflow_dispatch:1213# A workflow run is made up of one or more jobs that can run sequentially or in parallel14jobs:15  build:16    # The type of runner that the job will run on17    runs-on: ubuntu-20.041819  #  if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true2021    # Steps represent a sequence of tasks that will be executed as part of the job22    steps:23      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it24      - uses: actions/checkout@v225          26     #runs ssh connection27      - name: Go to server28        uses: appleboy/ssh-action@master29        with:30          host: ${{ secrets.SERVER_IP }}31          username: ${{ secrets.SERVER_USERNAME }}32          key: ${{ secrets.KEY }}33          port: ${{ secrets.SERVER_PORT }}34          command_timeout: 300m35          script: |36            eval $(ssh-agent -s)37            ssh-add /home/devops/.ssh/git_hub38            git clone git@github.com:UniqueNetwork/unique-chain.git39            cd unique-chain40            git checkout develop41            # git pull --all42            chmod +x ci_node.sh43            ./ci_node.sh44            rm -rf /home/polkadot/unique-chain
after · .github/workflows/node_build_test.yml
1name: Build & test23# Controls when the action will run.4on:5 # Triggers the workflow on push or pull request events but only for the master branch6  #push:7  #  branches: [ develop ]8  pull_request:9    branches:10      - develop11    types:12      - opened13      - edited14      - reopened15  # pull_request:16 #   branches: [ develop ]17  # Allows you to run this workflow manually from the Actions tab18  workflow_dispatch:1920#Define Workflow variables21env:22  ubuntu_version: focal23  chains_release_dir: /opt/runner/chains_release24  opal_chain_workdir: ./src_opal_chain25  quartz_chain_workdir: ./src_quartz_chain26  unique_chain_workdir: ./src_unique_chain27  src_repo_url: https://github.com/lzadjsf/unique-chain.git28  RUST_TOOLCHAIN: nightly-2022-05-1129  REPO_URL: ${{ github.server_url }}/${{ github.repository }}3031# A workflow run is made up of one or more jobs that can run sequentially or in parallel32jobs:33  pre-requisites:34    # The type of runner that the job will run on35    runs-on: self-hosted-ci3637    steps:38      #runs ssh connection39      - name: Install dependencies40        run: |41          sudo apt-get install git curl libssl-dev llvm pkg-config libclang-dev clang make cmake42          sudo apt autoremove43          curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none44          . $HOME/.cargo/env && cargo install --locked --git https://github.com/chevdor/subwasm45          rustup toolchain install ${{ env.RUST_TOOLCHAIN }}46          rustup default ${{ env.RUST_TOOLCHAIN }}47          rustup target add wasm32-unknown-unknown --toolchain ${{ env.RUST_TOOLCHAIN }}484950  build:51    # The type of runner that the job will run on52    runs-on: self-hosted-ci5354    needs: pre-requisites55    name: Build Container, Spin it Up an test5657    continue-on-error: true         #Do not stop testing of matrix runs failed.5859    strategy:60      matrix:61        include:62          - network: "Opal"63            features: " "64          - network: "Quartz"65            features: "--features=quartz-runtime"66          - network: "Unique"67            features: "--features=unique-runtime"6869    steps:70      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it71      - uses: actions/checkout@v37273      - name: Generate ENV related extend file for docker-compose74        uses: cuchi/jinja2-action@v1.2.075        with:76          template: .docker/docker-compose.tmp.j277          output_file: .docker/docker-compose.${{ matrix.network }}.yml78          variables: |79            REPO_URL=${{ github.server_url }}/${{ github.repository }}.git80            RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}81            FEATURE=${{ matrix.features }}82            BRANCH=${{ github.head_ref }}8384      - name: Show temporary file85        run: cat .docker/docker-compose.${{ matrix.network }}.yml8687      - name: Build the stack88        run: docker-compose -f ".docker/docker-compose-dev.yaml" -f ".docker/docker-compose.${{ matrix.network }}.yml" up -d --build8990#      - name: "Build the Docker image with Feature: ${{ env.features }}"91#        run: docker build -t build-${{ github.head_ref }} --file .docker/Dockerfile-chain-dev --build-arg REPO_URL=${{ github.server_url }}/${{ github.repository }}.git --build-arg RUST_TOOLCHAIN=${{ env.actual_toolchain }} --build-arg FEATURE="${{ env.features }}" --build-arg BRANCH=${{ github.head_ref }} --no-cache .9293      - name: Wait94        run: sleep 420s9596      - name: Install node97        uses: actions/setup-node@v198        with:99          node-version: 14.x100101      - name: Install dependencies102        run: |103          cd tests104          yarn install105          yarn add mochawesome106          yarn --pure-lockfile107108      - name: Run tests109        run: |110          cd tests111          ./scripts/ci-check-docker-state.sh112          NOW=$(date +%s) && yarn test --reporter mochawesome --reporter-options reportFilename=test-${NOW}113        env:114          RPC_URL: http://127.0.0.1:9933/115116      - name: Test Report117        uses: phoenix-actions/test-reporting@v8118        id: test-report               # Set ID reference for step119        if: success() || failure()    # run this step even if previous step failed120        with:121          name: Tests ${{ matrix.network }}            # Name of the check run which will be created122          path: tests/mochawesome-report/test-*.json    # Path to test results123          reporter: mochawesome-json124          fail-on-error: 'false'125126      - name: Stop running containers127        if: always()                   # run this step always128        run: docker-compose -f ".docker/docker-compose-dev.yaml" -f ".docker/docker-compose.${{ matrix.network }}.yml" down
modified.github/workflows/notify.ymldiffbeforeafterboth
--- a/.github/workflows/notify.yml
+++ b/.github/workflows/notify.yml
@@ -1,13 +1,17 @@
 name: telegram message
 on:
-  push:
-    branches: [ develop ]  
+  pull_request:
+    branches:
+      - develop
+    types:
+      - opened
+      - edited
 jobs:
-  build:    
-    runs-on: ubuntu-latest    
-    steps:        
+  build:
+    runs-on: self-hosted-ci
+    steps:
     - uses: avkviring/telegram-github-action@v0.0.13
       env:
-        telegram_to: ${{ secrets.TELEGRAM_TO }}  
+        telegram_to: ${{ secrets.TELEGRAM_TO }}
         telegram_token: ${{ secrets.TELEGRAM_TOKEN }}
         event: ${{ toJson(github.event) }}
modified.github/workflows/tests_codestyle.ymldiffbeforeafterboth
--- a/.github/workflows/tests_codestyle.yml
+++ b/.github/workflows/tests_codestyle.yml
@@ -1,14 +1,19 @@
 name: Tests code style
 
-on: [push]
-
+on:
+  pull_request:
+    branches:
+      - develop
+    types:
+      - opened
+      - edited
 jobs:
   build:
-    runs-on: ubuntu-20.04
+    runs-on: self-hosted-ci
 
     steps:
     - uses: actions/checkout@v2
     - name: Install modules
       run: cd tests && yarn
     - name: Run ESLint
-      run: cd tests && yarn eslint --ext .ts,.js src/
\ No newline at end of file
+      run: cd tests && yarn eslint --ext .ts,.js src/