Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
f3bfca4
Force rustup update on CI for building polkadot
May 3, 2022
272c8a3
Fixes breaking install by removing previous version
May 3, 2022
c1d2b71
Testing random stuff
May 3, 2022
8d9bf5c
testing
May 3, 2022
6c00332
Update polkadot-relay.Dockerfile
May 3, 2022
d6ba894
Adds log
May 3, 2022
77a0fec
even more logs
May 3, 2022
50da9ab
rustup logs
May 3, 2022
d47e9c8
Remove rustup mess
May 3, 2022
cceecca
Force reload ci-linux image
May 3, 2022
72c00a6
Force --pull on polkadot docker build
May 3, 2022
a5c9e54
Forces download image for para tests
May 3, 2022
8d31ad2
Forces mocha to exit on tests
May 3, 2022
1f4b77c
Restore build
May 4, 2022
8817dac
run para-tests in docker
May 4, 2022
95b6ffa
fixes docker folder
May 4, 2022
a09465d
Fix para-test docker usage
May 4, 2022
c7a3170
Testing para-node config
May 4, 2022
c31f14e
Force CI to download binary for para-tests
May 4, 2022
6018bc1
Typo in the build
May 4, 2022
27f9246
testing docker tmp folder
May 4, 2022
4a00dc4
more tests
May 4, 2022
86c4a53
change mktemp to make directory for para tests
May 4, 2022
bf2c815
Restore initial tmp for docker para test
May 4, 2022
36dcba1
Testing more docker in the CI
May 5, 2022
b02cc69
Making it work
May 5, 2022
3611069
using existing build folder
May 5, 2022
fc5507f
Testing more
May 5, 2022
41b6aa0
debugging
May 5, 2022
7143f16
More debugging
May 5, 2022
0d88286
getting crazy
May 5, 2022
2a09020
And more
May 5, 2022
add1539
Hum...
May 5, 2022
d07f600
testing special volumes
May 5, 2022
49985a0
Who knows what it does...
May 5, 2022
aa25c03
oups
May 5, 2022
0711413
more and more
May 5, 2022
af8cdc0
forgot node
May 5, 2022
a8f73db
test with version
May 6, 2022
0291a90
Testing correct build-spec
May 6, 2022
6bd58f6
forgot node :(
May 6, 2022
62ede55
forcing +w on moonbeam repo for docker execution
May 6, 2022
fe40325
Still not working
May 6, 2022
655b966
restore x flag on moonbeam binary
May 6, 2022
64d6345
Better chmod
May 6, 2022
f8860fe
Testing new para-test docker image
May 6, 2022
8f45dc1
fix docker creation for para-test
May 6, 2022
d4c148b
Adds login to para-test docker push
May 6, 2022
6d19ae3
more and more
May 6, 2022
140603f
Fix for docker
May 6, 2022
7e6c7e0
cleanup
May 6, 2022
c14620f
force cleanup
May 6, 2022
c01461d
Better :)
May 6, 2022
8eba792
??
May 7, 2022
82a321a
Finally !!
May 7, 2022
7e811ce
restore missing node
May 7, 2022
5141037
Testing dockerized tests
May 8, 2022
3f8740f
Faster testing
May 8, 2022
af85494
Kick forcing cleanup
May 8, 2022
a50a9d9
typo
May 8, 2022
326494c
fix wd in docker
May 8, 2022
fa5c1eb
Force build folder on docker polkadot creation
May 8, 2022
b54c287
Testing concurrent
May 8, 2022
649fa8f
Testing multi docker
May 9, 2022
984a73d
Adds log to CI
May 9, 2022
e3a052d
Going crazy
May 9, 2022
1947ea8
fixes typo
May 9, 2022
8543395
more typo
May 9, 2022
5a8f16c
Fixing network in docker
May 9, 2022
677ccb3
Adds doc
May 9, 2022
e0e8fd6
Merge branch 'moonbeam-polkadot-v0.9.19' into crystalin-fix-ci-polkad…
May 9, 2022
a74981a
new build
May 9, 2022
2d333c8
Merge branch 'moonbeam-polkadot-v0.9.19' into crystalin-fix-ci-polkad…
May 9, 2022
cd4538c
Remove useless env
May 9, 2022
0761abf
Another build
May 9, 2022
6d1baa8
More testing
May 9, 2022
58b22a1
Merge branch 'moonbeam-polkadot-v0.9.19' into crystalin-fix-ci-polkad…
May 9, 2022
983b7ef
Merge branch 'moonbeam-polkadot-v0.9.19' into crystalin-fix-ci-polkad…
May 9, 2022
e47e0a9
Creates folder if missing in para-node tests
May 9, 2022
4b718ad
fix concurrency
May 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 172 additions & 44 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,28 @@ jobs:
./scripts/build-alphanet-relay-image.sh
docker push $DOCKER_TAG
fi
- name: Check & prepare para-test docker image
run: |
POLKADOT_REPO=${{ needs.set-tags.outputs.polkadot_repo }}
POLKADOT_COMMIT=${{ needs.set-tags.outputs.polkadot_commit }}
DOCKER_TAG="purestake/polkadot-para-tests:sha-$POLKADOT_COMMIT"
docker rmi --force $DOCKER_TAG
POLKADOT_EXISTS=$(docker manifest inspect $DOCKER_TAG > /dev/null && \
echo "true" || echo "false")

if [[ "$POLKADOT_EXISTS" == "false" ]]; then
mkdir -p build
MOONBEAM_DOCKER_TAG="purestake/moonbase-relay-testnet:sha-$POLKADOT_COMMIT"
docker create --pull always -ti --name dummy $MOONBEAM_DOCKER_TAG bash
docker cp dummy:/usr/local/bin/polkadot build/polkadot
docker rm -f dummy

docker build . --pull --no-cache -f docker/polkadot-para-tests.Dockerfile \
--network=host \
--build-arg HOST_UID="$UID" \
-t $DOCKER_TAG
docker push $DOCKER_TAG
fi

####### Building and Testing binaries #######

Expand All @@ -219,8 +241,6 @@ jobs:
RUSTFLAGS: "-C opt-level=3 -D warnings"
# MOONBEAM_LOG: info
# DEBUG: "test*"
outputs:
RUSTC: ${{ steps.get-rust-versions.outputs.rustc }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -251,21 +271,37 @@ jobs:
fi
$SCCACHE_BIN -s
echo "RUSTC_WRAPPER=$SCCACHE_BIN" >> $GITHUB_ENV
- id: get-rust-versions
run: |
echo "::set-output name=rustc::$(rustc --version)"
- name: Build Node
run: |
env
cargo build --release --all
- name: Verify node version
run: |
GIT_COMMIT=`git log -1 --format="%H" | cut -c1-7`
MB_VERSION=`./target/release/moonbeam --version`
echo "Checking $MB_VERSION contains $GIT_COMMIT"
echo "$MB_VERSION" | grep $GIT_COMMIT
- name: Unit tests
run: cargo test --release --all
# - name: Build Node
# run: |
# env
# cargo build --release --all
- name: TODO remove - Download artifact moonbeam
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{secrets.GITHUB_TOKEN}}
# Required, workflow file name or ID
workflow: build.yml
name: moonbeam
run_id: 2296555362
path: build
- name: TODO remove - Download artifact runtime
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{secrets.GITHUB_TOKEN}}
# Required, workflow file name or ID
workflow: build.yml
name: runtimes
run_id: 2296555362
path: runtimes

# - name: Verify node version
# run: |
# GIT_COMMIT=`git log -1 --format="%H" | cut -c1-7`
# MB_VERSION=`./target/release/moonbeam --version`
# echo "Checking $MB_VERSION contains $GIT_COMMIT"
# echo "$MB_VERSION" | grep $GIT_COMMIT
# - name: Unit tests
# run: cargo test --release --all

# We determine whether there are unmodified Cargo.lock files by:
# 1. Asking git for a list of all modified files
Expand All @@ -289,21 +325,21 @@ jobs:
echo $DIFF_INDEX | grep Cargo.lock
false
fi
- name: Ensure benchmarking compiles
run: cargo check --release --features=runtime-benchmarks
- name: Save moonbeam binary
run: |
mkdir -p build
cp target/release/moonbeam build/moonbeam;
# - name: Ensure benchmarking compiles
# run: cargo check --release --features=runtime-benchmarks
# - name: Save moonbeam binary
# run: |
# mkdir -p build
# cp target/release/moonbeam build/moonbeam;
- name: Upload binary
uses: actions/upload-artifact@v2
with:
name: moonbeam
path: build
- name: Save runtime wasm
run: |
mkdir -p runtimes
cp target/release/wbuild/moon*/moon*_runtime.compact.compressed.wasm runtimes/;
# - name: Save runtime wasm
# run: |
# mkdir -p runtimes
# cp target/release/wbuild/moon*/moon*_runtime.compact.compressed.wasm runtimes/;
- name: Upload runtimes
uses: actions/upload-artifact@v2
with:
Expand All @@ -312,7 +348,7 @@ jobs:

typescript-tests:
runs-on: self-hosted
needs: ["set-tags", "build"]
needs: ["set-tags", "build", "prepare-polkadot"]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -330,13 +366,74 @@ jobs:
env:
BINARY_PATH: ../build/moonbeam
run: |
#### Compute CPUS & CONCURRENCY
CPU_PER_TEST=3;
CPUS=$(lscpu | grep '^CPU(s):' | grep -o '[0-9]*')
CONCURRENCY=$((CPUS/CPU_PER_TEST))
echo "Preparing $CONCURRENCY groups (CPUs/test: $CPU_PER_TEST, Total: $CPUS)"

#### Preparing the repository
chmod uog+x build/moonbeam
cd moonbeam-types-bundle
npm install
npm run build
cd ../tests
npm install
node_modules/.bin/mocha --parallel -j 4 -r ts-node/register 'tests/**/test-*.ts'

#### Splitting test files in groups (for concurrent execution)
mapfile -t SPLIT < <(find tests/ -name "test-*.ts" |\
while read -r file; do \
L[$((COUNT%CONCURRENCY))]+="$file "; \
echo ${L[$((COUNT%CONCURRENCY))]}; \
COUNT=$(($COUNT + 1)); \
done | tail -$CONCURRENCY)

cd ..

#### Cleaning possible previous data
rm -f fail.txt docker*.txt

#### Retrieving docker image as base to run tests
POLKADOT_REPO=${{ needs.set-tags.outputs.polkadot_repo }}
POLKADOT_COMMIT=${{ needs.set-tags.outputs.polkadot_commit }}
DOCKER_TAG="purestake/polkadot-para-tests:sha-$POLKADOT_COMMIT"

#### Script function to launch concurrent tests
launch_as() {
local cmd_name=$1
shift
(time $@ || echo $cmd_name >> fail.txt) 2>&1 > $cmd_name.txt
echo "Done $cmd_name"
}

echo "Running tests inside docker"
for i in $(eval echo "{0..$((CONCURRENCY - 1))}"); do
launch_as docker$i docker run \
--cpus $((CPUS / $CONCURRENCY)) \
-e BINARY_PATH='../build/moonbeam' \
-e DEBUG='test:*' \
-v $(pwd):/moonbeam:z \
-u $UID \
-w /moonbeam/tests \
$DOCKER_TAG \
node node_modules/.bin/mocha --exit -r ts-node/register "${SPLIT[$i]}" &
done

#### Waiting for all the group to finish
wait
echo "Done executing tests"

#### Displaying output of each group
for i in $(eval echo "{0..$((CONCURRENCY - 1))}"); do \
cat docker$i.txt
done
egrep "[0-9][0-9]* (passing|pending|failing)" docker*.txt

#### Forcing error if file is present
if [ -f fail.txt ]; then
cat fail.txt
exit 1
fi

# We determine whether there are unmodified package-lock.json files by:
# 1. Asking git for a list of all modified files
Expand Down Expand Up @@ -398,7 +495,7 @@ jobs:
npm run build
cd ../tests
npm install
node_modules/.bin/mocha --parallel -j 2 -r ts-node/register 'tracing-tests/**/test-*.ts'
node_modules/.bin/mocha --exit --parallel -j 2 -r ts-node/register 'tracing-tests/**/test-*.ts'

typescript-para-tests:
runs-on: self-hosted
Expand All @@ -417,31 +514,62 @@ jobs:
with:
name: runtimes
path: tests/runtimes
- name: Retrieve polkadot
run: |
POLKADOT_COMMIT=${{ needs.set-tags.outputs.polkadot_commit }}
DOCKER_TAG="purestake/moonbase-relay-testnet:sha-$POLKADOT_COMMIT"
docker create -ti --name dummy $DOCKER_TAG bash
docker cp dummy:/usr/local/bin/polkadot build/polkadot
docker rm -f dummy
- name: Use Node.js 14.x
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Typescript integration tests (against dev service)
env:
OVERRIDE_RUNTIME_PATH: ./runtimes
BINARY_PATH: ../build/moonbeam
MOONBEAM_LOG: info
RELAY_BINARY_PATH: ../build/polkadot
run: |
chmod uog+x build/polkadot
#### Preparing the repository
chmod uog+x build/moonbeam
cd moonbeam-types-bundle
npm install
cd ../tests
npm install
node_modules/.bin/mocha -r ts-node/register 'para-tests/**/test-*.ts'
cd ..

POLKADOT_REPO=${{ needs.set-tags.outputs.polkadot_repo }}
POLKADOT_COMMIT=${{ needs.set-tags.outputs.polkadot_commit }}
DOCKER_TAG="purestake/polkadot-para-tests:sha-$POLKADOT_COMMIT"

#### Retrieve binary to avoid para-node script to rely on docker
mkdir -p build
localVersion=$(grep 'spec_version: [0-9]*' runtime/moonbase/src/lib.rs | grep -o '[0-9]*')
baseRuntime=$(git tag -l -n 'runtime-[0-9]*' | \
cut -d' ' -f 1 | cut -d'-' -f 2 | \
sed "1 i ${localVersion}" | \
sort -n -r | \
uniq | \
grep -A1 "${localVersion}" | \
tail -1)
rev=$(git rev-list -1 runtime-$baseRuntime)
sha8=${rev:0:8}
dockerImage=purestake/moonbeam:sha-${sha8}
binaryPath=build/moonbeam-${sha8}
docker create --pull always --name moonbeam-tmp ${dockerImage} && \
docker cp moonbeam-tmp:/moonbeam/moonbeam ${binaryPath} && \
docker rm moonbeam-tmp

echo "Running para-tests inside docker"
docker run \
-e OVERRIDE_RUNTIME_PATH='./runtimes' \
-e BINARY_PATH='../build/moonbeam' \
-e MOONBEAM_LOG='info' \
-e RELAY_BINARY_PATH='/binaries/polkadot' \
-e RUNTIME_DIRECTORY='/tmp/runtimes' \
-e BINARY_DIRECTORY='../build/' \
-e SPECS_DIRECTORY='/tmp/specs' \
-v $(pwd):/moonbeam:z \
-v $(pwd)/${binaryPath}:/binaries/moonbeam:z \
-u $UID \
-w /moonbeam/tests \
$DOCKER_TAG \
node node_modules/.bin/mocha --exit -r ts-node/register 'para-tests/**/test-*.ts'

docker-parachain:
runs-on: ubuntu-latest
Expand Down
27 changes: 27 additions & 0 deletions docker/polkadot-para-tests.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Node for Moonbase Parachains.
#
# Requires to run from repository root and to copy the binary in the build folder (part of the release workflow)

FROM node
LABEL maintainer "alan@purestake.com"
LABEL description="Node image use to run Moonbeam para-tests"

ARG HOST_UID=1001

RUN ((getent passwd $HOST_UID > /dev/null) || \
useradd -m -u $HOST_UID -U -s /bin/sh -d /polkadot polkadot) && \
mkdir -p /polkadot/.local/share/polkadot && \
chown -R $HOST_UID /polkadot && \
ln -s /polkadot/.local/share/polkadot /data

RUN mkdir -p /binaries
COPY build/polkadot /binaries/
RUN chmod -R uog+rwX /binaries

USER $HOST_UID

WORKDIR /polkadot

ENTRYPOINT ["docker-entrypoint.sh"]
CMD [ "node" ]

2 changes: 1 addition & 1 deletion moonbeam-types-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "moonbeam-types-bundle",
"version": "2.0.4",
"description": "Bundled types to instantiate the Polkadot JS api with a Moonbeam network",
"main": "dist/index.js",
"main": "index.js",
"types": "dist/index.d.ts",
"prepublish": "tsc",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-alphanet-relay-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fi

echo "Using Polkadot from $POLKADOT_REPO revision #${POLKADOT_COMMIT}"

docker build . -f docker/polkadot-relay.Dockerfile --network=host \
docker build . --pull --no-cache -f docker/polkadot-relay.Dockerfile --network=host \
--build-arg POLKADOT_COMMIT="$POLKADOT_COMMIT" \
--build-arg POLKADOT_REPO="$POLKADOT_REPO" \
-t purestake/moonbase-relay-testnet:sha-$POLKADOT_COMMIT
Loading