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

difftreelog

Merge pull request #129 from usetech-llc/CI

Greg Zaitsev2021-03-22parents: #23e0b8c #7715274.patch.diff
in: master
Adding CI

8 files changed

deleted.github/workflows/main.ymldiffbeforeafterboth
--- a/.github/workflows/main.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-name: Docker build
-
-on:
-  push:
-    branches: [ master ]
-  schedule:
-    - cron: '* 1 * * *'
-
-jobs:
-  build:
-    runs-on: ubuntu-latest
-    steps:
-    - uses: actions/checkout@v2
-    - name: Docker login
-      run: docker login -u gzusetech -p "$TOKEN"
-      env:
-        TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
-    - name: Build image
-      run: docker build -t usetechcorp/nft_parachain .
-    - name: Push the image to Docker hub
-      run: docker push usetechcorp/nft_parachain:latest
-
added.github/workflows/node_build_test.ymldiffbeforeafterboth
--- /dev/null
+++ b/.github/workflows/node_build_test.yml
@@ -0,0 +1,44 @@
+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: [ develop ]
+ # pull_request:
+ #   branches: [ develop ]
+  # 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
+
+  #  if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
+
+    # 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
+            rm -rf /home/polkadot/nft_private
\ No newline at end of file
addedDockerfile-testsdiffbeforeafterboth
--- /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
addedDockerfile-unitdiffbeforeafterboth
--- /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"
addedci_node.shdiffbeforeafterboth

no changes

addeddocker-compose-tests.ymldiffbeforeafterboth
--- /dev/null
+++ b/docker-compose-tests.yml
@@ -0,0 +1,46 @@
+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
+      volumes:
+      - ./tests/src/config_docker.ts:/nft_parachain/tests/src/config.ts
+    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
addednode_build_test.ymldiffbeforeafterboth
--- /dev/null
+++ b/node_build_test.yml
@@ -0,0 +1,44 @@
+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: [ develop ]
+ # pull_request:
+ #   branches: [ develop ]
+  # 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
+
+  #  if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
+
+    # 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
+            rm -rf /home/polkadot/nft_private
\ No newline at end of file
addedtests/src/config_docker.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/config_docker.ts
@@ -0,0 +1,12 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
+import process from 'process';
+
+const config = {
+  substrateUrl: process.env.substrateUrl || 'ws://172.17.0.1:9944'
+}
+
+export default config;
\ No newline at end of file