From 5904c9a198aa4df9a89dc17bb9fecb55b54c9cc7 Mon Sep 17 00:00:00 2001 From: akaryaginUSETECH <74534681+akaryaginUSETECH@users.noreply.github.com> Date: Thu, 11 Mar 2021 00:38:55 +0000 Subject: [PATCH] Adding CI --- --- /dev/null +++ b/Dockerfile-tests @@ -0,0 +1,30 @@ +# ===== Integration Tests ====== + + +FROM ubuntu:18.04 +LABEL maintainer="UniqueNetwork.io" + +RUN apt-get -y update; apt-get -y upgrade; apt-get -y install curl + + +RUN mkdir nft_parachain +WORKDIR /nft_parachain + +COPY . . + +RUN apt-get -y update && \ + apt-get -y upgrade && \ + apt-get -y install curl && \ + 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.0.1 && \ + nvm use v15.0.1 && \ + npm install --save @polkadot/api + +CMD export NVM_DIR="$HOME/.nvm" && \ + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \ + cd tests && \ + npm install --global yarn && \ + yarn install && \ + yarn test --- /dev/null +++ b/Dockerfile-unit @@ -0,0 +1,39 @@ +# ===== Unit Tests ====== + +FROM phusion/baseimage:18.04-1.0.0 +LABEL maintainer="UniqueNetwork.io" + +ENV WASM_TOOLCHAIN=nightly-2021-03-01 +# ENV NATIVE_TOOLCHAIN=1.50.0 + +ARG PROFILE=release + +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 + +# Get project and run it +#RUN git clone https://github.com/usetech-llc/nft_parachain /nft_parachain +RUN mkdir nft_parachain +WORKDIR /nft_parachain +COPY . . + +RUN export CARGO_HOME="/cargo-home" && curl https://sh.rustup.rs -sSf | sh -s -- -y +RUN export PATH="/cargo-home/bin:$PATH" && \ + export CARGO_HOME="/cargo-home" && \ + cargo fetch +RUN export PATH="/cargo-home/bin:$PATH" && \ + export CARGO_HOME="/cargo-home" && \ + rustup toolchain uninstall $(rustup toolchain list) && \ + # rustup toolchain install $NATIVE_TOOLCHAIN && \ + rustup toolchain install $WASM_TOOLCHAIN && \ + rustup target add wasm32-unknown-unknown --toolchain $WASM_TOOLCHAIN && \ + rustup default $WASM_TOOLCHAIN && \ + rustup target list --installed && \ + rustup show + +RUN export PATH="/cargo-home/bin:$PATH" && \ + export CARGO_HOME="/cargo-home" && \ + cargo build "--$PROFILE" + #cargo test +ENV PATH "$PATH:/cargo-home/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" --- /dev/null +++ b/ci_node.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +docker-compose -f docker-compose-tests.yml up -d --build --force-recreate --no-deps + +# validate if testing container finished +while [ "$(docker ps | grep unit_test | wc -l)" -ge 1 ]; do echo "Unit test in process" && date && sleep 60; done && docker logs unit_test &> /home/polkadot/unit_test.log & \ +while [ "$(docker ps | grep integration_test | wc -l)" -ge 1 ]; do echo "Integration test in process" && sleep 60; done && docker logs integration_test &> /home/polkadot/integration_test.log +docker-compose -f docker-compose-tests.yml down -v +echo "Wrokflow finished" +docker system prune --force \ No newline at end of file --- /dev/null +++ b/docker-compose-tests.yml @@ -0,0 +1,44 @@ +version: "3.5" + +services: + node_validator1: + image: nft_node_test + container_name: validator1_test + ports: + - 9944:9944 + build: + context: ./ + dockerfile: Dockerfile +# volumes: +# - ./chain-data:/chain-data + networks: + - node_test_network + command: bash -c "/usr/local/bin/nft --dev --tmp --ws-external --rpc-external" + + integration_tests: + container_name: integration_test + image: int_test + build: + context: ./ + dockerfile: Dockerfile-tests + networks: + - node_test_network + depends_on: + - node_validator1 + + unit_tests: + container_name: unit_test + image: nft_unit_test + build: + context: ./ + dockerfile: Dockerfile-unit + container_name: unit_test + networks: + - node_test_network + # command: bash -c 'while true; do sleep 20; df -h; done' + command: bash -c 'cargo test' + +networks: + node_test_network: + name: node_test_network + driver: bridge \ No newline at end of file --- /dev/null +++ b/node_build_test.yml @@ -0,0 +1,42 @@ +name: 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: [ master ] + pull_request: + branches: [ master ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + build: + # The type of runner that the job will run on + runs-on: ubuntu-20.04 + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + #runs ssh connection + - name: Go to server + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SERVER_IP }} + username: ${{ secrets.SERVER_USERNAME }} + key: ${{ secrets.KEY }} + port: ${{ secrets.SERVER_PORT }} + # command_timeout: 200m + script: | + eval $(ssh-agent -s) + ssh-add /home/devops/.ssh/git_hub + git clone git@github.com:usetech-llc/nft_private.git + cd nft_private + git checkout develop + # git pull --all + chmod +x ci_node.sh + ./ci_node.sh \ No newline at end of file --- a/tests/src/config.ts +++ b/tests/src/config.ts @@ -6,7 +6,7 @@ import process from 'process'; const config = { - substrateUrl: process.env.substrateUrl || 'ws://127.0.0.1:9944' + substrateUrl: process.env.substrateUrl || 'ws://172.17.0.1:9944' } export default config; \ No newline at end of file -- gitstuff