Skip to content

Feature/crt constraints proposal #6052

Feature/crt constraints proposal

Feature/crt constraints proposal #6052

name: run-network-tests
on:
pull_request:
types: [opened, synchronize]
workflow_dispatch:
push:
jobs:
tests_build_ubuntu:
name: Ubuntu Checks
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: checks
run: |
yarn build
tests_build_osx:
name: MacOS Checks
runs-on: macos-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: checks
run: |
yarn build
build_images:
name: Build joystream/node
needs: tests_build_ubuntu
runs-on: ubuntu-latest
outputs:
use_artifact: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz
runtime: ${{ steps.compute_shasum.outputs.shasum }}
steps:
- name: Make some space
shell: bash
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- id: compute_shasum
name: Compute runtime code shasum
env:
RUNTIME_PROFILE: 'TESTING'
run: |
export RUNTIME_CODE_SHASUM=`scripts/runtime-code-shasum.sh`
echo "::set-output name=shasum::${RUNTIME_CODE_SHASUM}"
- name: Setup cache directory
run: mkdir ~/docker-images
- name: Cache docker images
uses: actions/cache@v3
env:
cache-name: joystream-node-docker-1
with:
path: ~/docker-images
key: ${{ env.cache-name }}-${{ steps.compute_shasum.outputs.shasum }}
- name: Check if we have cached image
continue-on-error: true
run: |
if [ -f ~/docker-images/joystream-node-docker-image.tar.gz ]; then
docker load --input ~/docker-images/joystream-node-docker-image.tar.gz
cp ~/docker-images/joystream-node-docker-image.tar.gz .
fi
- name: Check if we have pre-built image on Dockerhub
continue-on-error: true
run: |
if ! [ -f joystream-node-docker-image.tar.gz ]; then
docker pull joystream/node:${{ steps.compute_shasum.outputs.shasum }}
docker save --output joystream-node-docker-image.tar joystream/node:${{ steps.compute_shasum.outputs.shasum }}
gzip joystream-node-docker-image.tar
cp joystream-node-docker-image.tar.gz ~/docker-images/
fi
- name: Check we now have an image
id: check_files
uses: andstor/file-existence-action@v1
with:
files: 'joystream-node-docker-image.tar.gz'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # v1.7
id: builder1
if: steps.check_files.outputs.files_exists == 'false'
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-tests
if: steps.check_files.outputs.files_exists == 'false'
- name: Build
uses: docker/build-push-action@v3
with:
context: .
file: joystream-node.Dockerfile
platforms: linux/amd64
build-args: |
CARGO_FEATURES=testing-runtime
CODE_SHASUM=${{ steps.compute_shasum.outputs.shasum }}
push: false
tags: joystream/node:${{ steps.compute_shasum.outputs.shasum }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
builder: ${{ steps.builder1.outputs.name }}
load: true
if: steps.check_files.outputs.files_exists == 'false'
- name: Save joystream/node image to cache
run: |
docker save --output joystream-node-docker-image.tar joystream/node:${{ steps.compute_shasum.outputs.shasum }}
gzip joystream-node-docker-image.tar
cp joystream-node-docker-image.tar.gz ~/docker-images/
if: steps.check_files.outputs.files_exists == 'false'
- name: Save joystream/node image to Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz
path: joystream-node-docker-image.tar.gz
run_test_scenarios:
name: Tests
needs: build_images
runs-on: ubuntu-latest
strategy:
matrix:
scenario: ['full', 'setupNewChain', 'setupNewChainMultiStorage', 'bonding', 'storageSync']
include:
- scenario: 'full'
no_storage: 'false'
- scenario: 'setupNewChain'
no_storage: 'true'
- scenario: 'setupNewChainMultiStorage'
no_storage: 'true'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Get artifacts
uses: actions/download-artifact@v3
with:
name: ${{ needs.build_images.outputs.use_artifact }}
- name: Install artifacts
run: |
docker load --input joystream-node-docker-image.tar.gz
docker images
- name: Install packages and dependencies
run: |
yarn build
- name: Ensure tests are runnable
run: yarn workspace network-tests build
- name: Execute network tests
run: |
export RUNTIME=${{ needs.build_images.outputs.runtime }}
export NO_STORAGE=${{ matrix.no_storage }}
tests/network-tests/run-tests.sh ${{ matrix.scenario }}
runtime_upgrade:
name: Runtime Upgrade from production runtime
needs: build_images
runs-on: ubuntu-latest
# Disabling until we find a workaround
# as it is no longer practical to start the node
# while importing huge state from production network in genesis block.
# if: github.ref != 'refs/heads/master'
if: false
steps:
# Checkout master branch
- name: check out master repo
uses: actions/checkout@v3
with:
repository: Joystream/joystream
ref: master
- name: pull base runtime image
id: pull_base_image
env:
RUNTIME_PROFILE: 'TESTING'
run: |
export RUNTIME=`scripts/runtime-code-shasum.sh`
echo "::set-output name=shasum::${RUNTIME}"
docker pull joystream/node:$RUNTIME
docker images
# Get new runtime built for this workflow (target runtime)
# tagged in local repo as joystream/node:latest
- name: Get artifacts
uses: actions/download-artifact@v3
with:
name: ${{ needs.build_images.outputs.use_artifact }}
- name: Install artifacts
run: |
docker load --input joystream-node-docker-image.tar.gz
docker images
# Checkout workflow's branch/tag/commit
- name: checkout workflow branch
uses: actions/checkout@v3
# Look only for changes that would indicate possible change in runtime version
# This is not the best way to check. Ideally the script "run-runtime-upgrade-tests.sh" should
# look for the change of `spec_version`, and exit gracefully.
- name: Check for runtime version change
uses: technote-space/get-diff-action@v3
with:
PREFIX_FILTER: |
runtime
runtime-modules
SUFFIX_FILTER: |
.rs
- name: setup node
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install packages and dependencies
if: env.GIT_DIFF
run: |
yarn build
- name: Ensure tests are runnable
if: env.GIT_DIFF
run: yarn workspace network-tests build
- name: Execute network tests
if: env.GIT_DIFF
env:
TARGET_RUNTIME: ${{ needs.build_images.outputs.runtime }}
RUNTIME: ${{ steps.pull_base_image.outputs.shasum }}
run: |
export HOME=${PWD}
mkdir -p ${HOME}/.local/share/joystream-cli
yarn joystream-cli api:setUri ws://localhost:9944
tests/network-tests/run-runtime-upgrade-tests.sh