--- a/.docker/.env +++ /dev/null @@ -1,7 +0,0 @@ -RUST_TOOLCHAIN=nightly-2022-05-11 -RUST_C=1.62.0-nightly -POLKA_VERSION=release-v0.9.24 -UNIQUE_BRANCH=develop -FEATURE='--features=quartz-runtime' -USER=*** -PASS=*** --- a/.docker/Dockerfile-chain-dev +++ b/.docker/Dockerfile-chain-dev @@ -10,9 +10,10 @@ 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 RUST_TOOLCHAIN=nightly-2022-05-11 +ARG POLKA_VERSION=release-v0.9.24 +ARG BRANCH= +ARG REPO_URL= ARG FEATURE= RUN rustup toolchain uninstall $(rustup toolchain list) && \ @@ -20,16 +21,9 @@ 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 +RUN mkdir /dev_chain && git clone $REPO_URL -b $BRANCH /dev_chain 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 --- a/.docker/Dockerfile-parachain +++ b/.docker/Dockerfile-parachain @@ -1,21 +1,16 @@ # ===== Rust builder ===== -FROM phusion/baseimage:focal-1.1.0 as rust-builder +FROM ubuntu:20.04 as rust-builder LABEL maintainer="Unique.Network" ARG RUST_TOOLCHAIN=nightly-2022-05-11 -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 && \ apt-get clean && \ rm -r /var/lib/apt/lists/* @@ -28,51 +23,39 @@ 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 - -####works inside repo folder### - # ===== BUILD ====== FROM rust-builder as builder-unique +ARG PROFILE=release +ARG FEATURE= + RUN mkdir unique_parachain WORKDIR /unique_parachain -COPY --from=chef /unique_parachain/recipe.json recipe.json - -RUN cargo chef cook --release --recipe-path recipe.json - -ARG FEATURE=' ' - -COPY . . -RUN cargo build $FEATURE --release +RUN git clone $REPO_URL -b $BRANCH +RUN cargo build $FEATURE --$PROFILE # && \ # cargo test # ===== BUILD POLKADOT ===== FROM rust-builder as builder-polkadot +ARG POLKA_VERSION=release-v0.9.24 +ENV POLKA_VERSION $POLKA_VERSION + 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 + cargo build --release # ===== RUN ====== -FROM phusion/baseimage:focal-1.1.0 +FROM ubuntu:20.04 RUN apt-get -y update && \ apt-get -y upgrade && \ @@ -80,31 +63,22 @@ 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 + nvm install v16.16.0 && \ + nvm use v16.16.0 -RUN git clone https://github.com/UniqueNetwork/polkadot-launch.git && \ - cd /polkadot-launch && \ - git checkout feature/runtime-upgrade-testing +RUN git clone https://github.com/uniquenetwork/polkadot-launch -b 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 + yarn install 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" && \ --- a/.docker/Dockerfile-parachain-v2 +++ /dev/null @@ -1,97 +0,0 @@ -# ===== 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' - -ENV PROFILE $PROFILE - -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 - - -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 --- a/.docker/docker-compose-dev.yaml +++ b/.docker/docker-compose-dev.yaml @@ -1,12 +1,12 @@ version: "3.5" services: - node-o: + node-dev: build: context: ../ dockerfile: .docker/Dockerfile-chain-dev - image: node-o - container_name: node-o + image: node-dev + container_name: node-dev expose: - 9944 - 9933 --- a/.docker/docker-compose-tests-parachain.yml +++ /dev/null @@ -1,34 +0,0 @@ -version: "3.5" - -services: - blockchain_nodes: - build: - context: ../ - dockerfile: .docker/Dockerfile-parachain - args: - - RUST_TOOLCHAIN=${RUST_TOOLCHAIN:?err} - - RUST_C=${RUST_C:?err} - - POLKA_VERSION=${POLKA_VERSION:?err} - - FEATURE=${FEATURE:?err} - volumes: - - ../launch-config.json:/polkadot-launch/launch-config.json - env_file: - - ./.env - expose: - - 9944 - - 9933 - ports: - - 127.0.0.1:9944:9944 - - 127.0.0.1:9933:9933 - -# 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 --- a/.docker/docker-compose.tmp-master.j2 +++ /dev/null @@ -1,10 +0,0 @@ -version: "3.5" - -services: - blockchain_nodes: - build: - args: - - "RUST_TOOLCHAIN={{ RUST_TOOLCHAIN }}" - - "BRANCH={{ BRANCH }}" - - "REPO_URL={{ REPO_URL }}" - - "FEATURE={{ FEATURE }}" --- a/.docker/docker-compose.tmp.j2 +++ b/.docker/docker-compose.tmp.j2 @@ -1,10 +1,13 @@ version: "3.5" services: - node-o: + node-dev: build: args: - "RUST_TOOLCHAIN={{ RUST_TOOLCHAIN }}" - "BRANCH={{ BRANCH }}" - "REPO_URL={{ REPO_URL }}" - "FEATURE={{ FEATURE }}" + - "POLKA_VERSION={{ POLKA_VERSION }}" + + command: cargo run --release $FEATURE -- --dev -linfo --unsafe-ws-external --rpc-cors=all --unsafe-rpc-external --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,6 @@ .git/ .github/ +.docker/ doc/ target/ tests/ --- a/.github/workflows/build-test-master.yml +++ /dev/null @@ -1,126 +0,0 @@ -name: Build & Test Master - -# Controls when the action will run. -on: - # Triggers the workflow on push or pull request events but only for the master branch - #push: - # branches: [ develop ] - pull_request: - branches: - - master - types: - - opened - - edited - - reopened - # pull_request: - # branches: [ develop ] - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -#Define Workflow variables -env: - ubuntu_version: focal - chains_release_dir: /opt/runner/chains_release - opal_chain_workdir: ./src_opal_chain - quartz_chain_workdir: ./src_quartz_chain - unique_chain_workdir: ./src_unique_chain - RUST_TOOLCHAIN: nightly-2022-05-11 - REPO_URL: ${{ github.server_url }}/${{ github.repository }} - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - pre-requisites: - # The type of runner that the job will run on - runs-on: self-hosted-ci - - steps: - #runs ssh connection - - name: Install dependencies - run: | - sudo apt-get install git curl libssl-dev llvm pkg-config libclang-dev clang make cmake - sudo apt autoremove - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none - . $HOME/.cargo/env && cargo install --locked --git https://github.com/chevdor/subwasm - rustup toolchain install ${{ env.RUST_TOOLCHAIN }} - rustup default ${{ env.RUST_TOOLCHAIN }} - rustup target add wasm32-unknown-unknown --toolchain ${{ env.RUST_TOOLCHAIN }} - - - build: - # The type of runner that the job will run on - runs-on: self-hosted-ci - - needs: pre-requisites - name: Build Container, Spin it Up an test - - continue-on-error: true #Do not stop testing of matrix runs failed. - - strategy: - matrix: - include: - - network: "Opal" - features: " " - - network: "Quartz" - features: "--features=quartz-runtime" - - network: "Unique" - features: "--features=unique-runtime" - - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 - - - name: Generate ENV related extend file for docker-compose - uses: cuchi/jinja2-action@v1.2.0 - with: - template: .docker/docker-compose.tmp-master.j2 - output_file: .docker/docker-compose.${{ matrix.network }}.yml - variables: | - REPO_URL=${{ github.server_url }}/${{ github.repository }}.git - RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }} - FEATURE=${{ matrix.features }} - BRANCH=${{ github.head_ref }} - - - name: Show temporary file - run: cat .docker/docker-compose.${{ matrix.network }}.yml - - - name: Build the stack - run: docker-compose -f ".docker/docker-compose-tests-parachain.yml" -f ".docker/docker-compose.${{ matrix.network }}.yml" up -d --build - -# - name: "Build the Docker image with Feature: ${{ env.features }}" -# 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 . - - - name: Wait - run: sleep 420s - - - name: Install node - uses: actions/setup-node@v1 - with: - node-version: 14.x - - - name: Install dependencies - run: | - cd tests - yarn install - yarn add mochawesome - yarn --pure-lockfile - - - name: Run tests - run: | - cd tests - NOW=$(date +%s) && yarn test --reporter mochawesome --reporter-options reportFilename=test-${NOW} - env: - RPC_URL: http://127.0.0.1:9933/ - - - name: Test Report - uses: phoenix-actions/test-reporting@v8 - id: test-report # Set ID reference for step - if: success() || failure() # run this step even if previous step failed - with: - name: Tests ${{ matrix.network }} # Name of the check run which will be created - path: tests/mochawesome-report/test-*.json # Path to test results - reporter: mochawesome-json - fail-on-error: 'false' - - - name: Stop running containers - if: always() # run this step always - run: docker-compose -f ".docker/docker-compose-tests-parachain.yml" -f ".docker/docker-compose.${{ matrix.network }}.yml" down --- a/.github/workflows/codestyle.yml +++ b/.github/workflows/codestyle.yml @@ -6,7 +6,8 @@ - develop types: - opened - - edited + - reopened + - synchronize jobs: rustfmt: @@ -29,7 +30,7 @@ runs-on: self-hosted-ci steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 - name: Install substrate dependencies run: sudo apt-get install libssl-dev pkg-config libclang-dev clang - name: Install latest nightly --- a/.github/workflows/node_build_test.yml +++ b/.github/workflows/node_build_test.yml @@ -1,73 +1,68 @@ -name: Build & test +name: Develop - Build & test # Controls when the action will run. on: # Triggers the workflow on push or pull request events but only for the master branch - #push: - # branches: [ develop ] pull_request: branches: - develop types: - opened - - edited - reopened - # pull_request: - # branches: [ develop ] + - synchronize #commit(s) pushed to the pull request + # Allows you to run this workflow manually from the Actions tab workflow_dispatch: #Define Workflow variables env: - ubuntu_version: focal - chains_release_dir: /opt/runner/chains_release - opal_chain_workdir: ./src_opal_chain - quartz_chain_workdir: ./src_quartz_chain - unique_chain_workdir: ./src_unique_chain RUST_TOOLCHAIN: nightly-2022-05-11 REPO_URL: ${{ github.server_url }}/${{ github.repository }} + POLKA_VERSION: release-v0.9.24 # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - pre-requisites: - # The type of runner that the job will run on - runs-on: self-hosted-ci - - steps: - #runs ssh connection - - name: Install dependencies - run: | - sudo apt-get install git curl libssl-dev llvm pkg-config libclang-dev clang make cmake - sudo apt autoremove - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none - . $HOME/.cargo/env && cargo install --locked --git https://github.com/chevdor/subwasm - rustup toolchain install ${{ env.RUST_TOOLCHAIN }} - rustup default ${{ env.RUST_TOOLCHAIN }} - rustup target add wasm32-unknown-unknown --toolchain ${{ env.RUST_TOOLCHAIN }} - - build: # The type of runner that the job will run on runs-on: self-hosted-ci - needs: pre-requisites name: Build Container, Spin it Up an test - continue-on-error: true #Do not stop testing of matrix runs failed. + continue-on-error: false #Do not stop testing of matrix runs failed. As it decided during PR review - it required 50/50& Let's check it with false. strategy: matrix: include: - network: "Opal" - features: " " + features: "--features=opal-runtime" - network: "Quartz" features: "--features=quartz-runtime" - network: "Unique" features: "--features=unique-runtime" steps: + - name: Skip if pull request is in Draft + # `if: github.event.pull_request.draft == true` should be kept here, at + # the step level, rather than at the job level. The latter is not + # recommended because when the PR is moved from "Draft" to "Ready to + # review" the workflow will immediately be passing (since it was skipped), + # even though it hasn't actually ran, since it takes a few seconds for + # the workflow to start. This is also disclosed in: + # https://github.community/t/dont-run-actions-on-draft-pull-requests/16817/17 + # That scenario would open an opportunity for the check to be bypassed: + # 1. Get your PR approved + # 2. Move it to Draft + # 3. Push whatever commits you want + # 4. Move it to "Ready for review"; now the workflow is passing (it was + # skipped) and "Check reviews" is also passing (it won't be updated + # until the workflow is finished) + if: github.event.pull_request.draft == true + run: exit 1 + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} #Checking out head commit - name: Generate ENV related extend file for docker-compose uses: cuchi/jinja2-action@v1.2.0 @@ -77,43 +72,34 @@ variables: | REPO_URL=${{ github.server_url }}/${{ github.repository }}.git RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }} + POLKA_VERSION=${{ env.POLKA_VERSION }} FEATURE=${{ matrix.features }} BRANCH=${{ github.head_ref }} - - name: Show temporary file + - name: Show build configuration run: cat .docker/docker-compose.${{ matrix.network }}.yml - name: Build the stack run: docker-compose -f ".docker/docker-compose-dev.yaml" -f ".docker/docker-compose.${{ matrix.network }}.yml" up -d --build -# - name: "Build the Docker image with Feature: ${{ env.features }}" -# 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 . - - - name: Wait - run: sleep 420s - - - name: Install node - uses: actions/setup-node@v1 + - uses: actions/setup-node@v3 with: - node-version: 14.x + node-version: 16 - - name: Install dependencies + - name: Run tests run: | cd tests yarn install yarn add mochawesome yarn --pure-lockfile - - - name: Run tests - run: | - cd tests + echo "Ready to start tests" + node scripts/readyness.js NOW=$(date +%s) && yarn test --reporter mochawesome --reporter-options reportFilename=test-${NOW} env: RPC_URL: http://127.0.0.1:9933/ - name: Test Report uses: phoenix-actions/test-reporting@v8 - id: test-report # Set ID reference for step if: success() || failure() # run this step even if previous step failed with: name: Tests ${{ matrix.network }} # Name of the check run which will be created @@ -121,6 +107,10 @@ reporter: mochawesome-json fail-on-error: 'false' + - name: Read output variables + run: | + echo "url is ${{ steps.test-report.outputs.runHtmlUrl }}" + - name: Stop running containers if: always() # run this step always run: docker-compose -f ".docker/docker-compose-dev.yaml" -f ".docker/docker-compose.${{ matrix.network }}.yml" down --- a/.github/workflows/notify.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: telegram message -on: - pull_request: - branches: - - develop - types: - - opened - - edited -jobs: - build: - runs-on: self-hosted-ci - steps: - - uses: avkviring/telegram-github-action@v0.0.13 - env: - telegram_to: ${{ secrets.TELEGRAM_TO }} - telegram_token: ${{ secrets.TELEGRAM_TOKEN }} - event: ${{ toJson(github.event) }} --- a/.github/workflows/tests_codestyle.yml +++ b/.github/workflows/tests_codestyle.yml @@ -6,13 +6,19 @@ - develop types: - opened - - edited + - reopened + - synchronize jobs: build: runs-on: self-hosted-ci steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Install modules run: cd tests && yarn - name: Run ESLint --- a/Dockerfile-parachain +++ /dev/null @@ -1,107 +0,0 @@ -# ===== 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/ - -CMD export NVM_DIR="$HOME/.nvm" && \ - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \ - cd /polkadot-launch && \ - yarn start launch-config.json --- a/docker-compose-tests-parachain.yml +++ /dev/null @@ -1,28 +0,0 @@ -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 --- /dev/null +++ b/tests/scripts/readyness.js @@ -0,0 +1,35 @@ +const { ApiPromise, WsProvider } = require('@polkadot/api'); + +const connect = async () => { + const wsEndpoint = 'ws://127.0.0.1:9944' + const api = new ApiPromise({provider: new WsProvider(wsEndpoint)}); + await api.isReadyOrError; + + const head = (await api.rpc.chain.getHeader()).number.toNumber(); + if(head < 1) throw Error('No block #1'); + + await api.disconnect(); +} + +const sleep = time => { + return new Promise(resolve => { + setTimeout(() => resolve(), time); + }); +} + +const main = async () => { + while(true) { + try { + await connect(); + break; + } + catch(e) { + await sleep(60000); + } + } +} + +main().then(() => process.exit(0)).catch(e => { + console.error(e); + process.exit(1); +});