Skip to content

Commit

Permalink
add just-tests workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
BuddyGlas committed Dec 9, 2024
1 parent 9d0bc02 commit c949076
Show file tree
Hide file tree
Showing 5 changed files with 362 additions and 3 deletions.
109 changes: 109 additions & 0 deletions .baedeker/just-tests.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
local
m = import 'baedeker-library/mixin/spec.libsonnet',
rm = import 'baedeker-library/mixin/raw-spec.libsonnet',
;

function(relay_spec, forked_spec, dump_spec)

local relay = {
name: 'relay',
bin: 'bin/polkadot',
validatorIdAssignment: 'staking',
spec: {Genesis:{
chain: relay_spec,
modify:: bdk.mixer([
m.genericRelay($),
{
genesis+: {
runtimeGenesis+: {
runtime+: {
configuration+: {
config+: {
async_backing_params+: {
allowed_ancestry_len: 3,
max_candidate_depth: 4,
},
scheduling_lookahead:5,
max_validators_per_core:1,
minimum_backing_votes:2,
needed_approvals:2,
on_demand_cores:5,
validation_upgrade_cooldown:400,
validation_upgrade_delay:200,
minimum_validation_upgrade_delay:10,
},
},
},
},
},
},
]),
}},
nodes: {
[name]: {
bin: $.bin,
wantedKeys: 'relay',
expectedDataPath: '/parity',
},
for name in ['alice', 'bob', 'charlie', 'dave', 'eve']
},
};

local unique = {
name: 'unique',
bin: 'bin/unique',
paraId: 1001,
spec: {Genesis:{
modify:: bdk.mixer([
m.genericPara($),
m.simplifyGenesisName(),
{
_code: cql.toHex(importbin '../runtime.compact.compressed.wasm'),
},
m.unsimplifyGenesisName(),
]),
},
Raw:{
local modifyRaw = bdk.mixer([
rm.resetNetworking($),
rm.decodeSpec(),
rm.polkaLaunchPara($),
rm.reencodeSpec(),
]),
raw_spec: modifyRaw({
name: "Unused",
id: "%s_local" % forked_spec,
bootNodes: error "override me",
chainType: error "override me",
telemetryEndpoints: error "override me",
codeSubstitutes: error "override me",
para_id: error "override me",
relay_chain: "unused",
genesis: {
raw: {
top: import "dump.json",
childrenDefault: {},
},
},
}),
}},
nodes: {
[name]: {
bin: $.bin,
wantedKeys: 'para',
extraArgs: [
'--increase-future-pool',
'--pool-type=fork-aware',
'-laura=debug',
],
},
for name in ['alice', 'bob', 'charlie']
},
};

relay + {
parachains: {
[para.name]: para,
for para in [unique]
},
}
6 changes: 3 additions & 3 deletions .baedeker/main-process.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ local relay = {
minimum_backing_votes:2,
needed_approvals:2,
on_demand_cores:5,
validation_upgrade_cooldown:200,
validation_upgrade_delay:100,
minimum_validation_upgrade_delay:5,
validation_upgrade_cooldown:400,
validation_upgrade_delay:200,
minimum_validation_upgrade_delay:10,
},
},
},
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ jobs:
uses: ./.github/workflows/main-process-update.yml
secrets: inherit

just-tests:
if: github.event.pull_request.draft == false && (contains(github.event.pull_request.labels.*.name, 'CI-just-tests') || contains(github.event.pull_request.labels.*.name, 'CI-just-tests'))
uses: ./.github/workflows/just-tests-without-update.yml
secrets: inherit

try-runtime:
if: github.event.pull_request.draft == false && (contains(github.event.pull_request.labels.*.name, 'CI-try-runtime') || contains(github.event.pull_request.labels.*.name, 'CI-try-runtime'))
uses: ./.github/workflows/try-runtime.yml
Expand Down
225 changes: 225 additions & 0 deletions .github/workflows/just-tests-without-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
# Triger: only call from main workflow(re-usable workflows)
name: main-process-update

on:
workflow_call:
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:

prepare-execution-matrix:

name: execution matrix

runs-on: [ ci ]
outputs:
matrix: ${{ steps.create_matrix.outputs.matrix }}

steps:

- name: Clean Workspace
uses: AutoModality/[email protected]

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/[email protected]
with:
ref: ${{ github.head_ref }} #Checking out head commit

- name: Read .env file
uses: xom9ikk/[email protected]

- name: Create Execution matrix
uses: CertainLach/create-matrix-action@v4
id: create_matrix
with:
matrix: |
network {opal}, relay_branch {${{ env.UNIQUEWEST_MAINNET_BRANCH }}}, fork_source {${{ env.OPAL_REPLICA_FROM }}}
network {quartz}, relay_branch {${{ env.KUSAMA_MAINNET_BRANCH }}}, fork_source {${{ env.QUARTZ_REPLICA_FROM }}}
network {unique}, relay_branch {${{ env.POLKADOT_MAINNET_BRANCH }}}, fork_source {${{ env.UNIQUE_REPLICA_FROM }}}
main-process:

needs: prepare-execution-matrix
# The type of runner that the job will run on
runs-on: [ ci ]

timeout-minutes: 1380

name: ${{ matrix.network }}-update

continue-on-error: true #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: ${{fromJson(needs.prepare-execution-matrix.outputs.matrix)}}

steps:

- name: Clean Workspace
uses: AutoModality/[email protected]

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/[email protected]
with:
ref: ${{ github.head_ref }} #Checking out head commit

# Prepare SHA
- name: Prepare SHA
uses: ./.github/actions/prepare

- name: Read .env file
uses: xom9ikk/[email protected]

- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.CORE_DOCKERHUB_USERNAME }}
password: ${{ secrets.CORE_DOCKERHUB_TOKEN }}

- name: Check and pull polkadot image
id: polkadot
uses: cloudposse/github-action-docker-image-exists@main
with:
registry: registry.hub.docker.com
organization: parity
repository: polkadot
login: ${{ secrets.CORE_DOCKERHUB_USERNAME }}
password: ${{ secrets.CORE_DOCKERHUB_TOKEN }}
tag: ${{ matrix.relay_branch }}

- name: Prepare target runtime
uses: ./.github/actions/buildContainer
id: runtime
with:
container: uniquenetwork/ci-main-process
tag: ${{ matrix.network }}-${{ env.REF_SLUG }}-${{ env.BUILD_SHA }}
context: .
dockerfile: .docker/Dockerfile-unique
args: |
--build-arg FEATURES=${{ matrix.network }}-runtime
dockerhub_username: ${{ secrets.CORE_DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.CORE_DOCKERHUB_TOKEN }}

- name: Extract wasms
uses: ./.github/actions/extractDocker
id: wasms
with:
image: ${{ steps.runtime.outputs.name }}
directory: /wasm

- name: Prepare target node
uses: ./.github/actions/buildContainer
id: node
with:
container: uniquenetwork/ci-main-process
tag: ${{ matrix.network }}-${{ env.NODE_BRANCH }}-${{ env.NODE_HASH}}
context: .docker
dockerfile: Dockerfile-unique-release
args: |
--build-arg FEATURES=${{ matrix.network }}-runtime
--build-arg CODE_VERSION=${{ env.NODE_BRANCH}}
--build-arg CODE_HASH=${{ env.NODE_HASH}}
dockerhub_username: ${{ secrets.CORE_DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.CORE_DOCKERHUB_TOKEN }}

- uses: actions/[email protected]
with:
node-version: 20

- name: Install baedeker
uses: UniqueNetwork/baedeker-action/[email protected]
with:
version: "v0.1.4"
useCache: false

- name: Setup library
run: mkdir -p .baedeker/vendor/ && git clone https://github.com/UniqueNetwork/baedeker-library .baedeker/vendor/baedeker-library

- name: Get state from production
run: |
. "$HOME/.cargo/env"
chainql -e "cql.chain(\"${{ matrix.fork_source }}\").latest._preloadKeys._raw" > .baedeker/vendor/dump.json
- name: Copy runtime file
run: |
cp ${{ steps.wasms.outputs.dir }}/${{ matrix.network }}-runtime/${{ matrix.network }}_runtime.compact.compressed.wasm .baedeker/vendor/runtime.compact.compressed.wasm
- name: Start network
uses: UniqueNetwork/[email protected]
if: success()
id: bdk
with:
jpath: |
.baedeker/vendor
input-modules: |
lib:baedeker-library/ops/nginx-dev.libsonnet
tla-str: |
relay_spec=${{ env.RELAY_CHAIN_TYPE }}-local
forked_spec=${{ matrix.network }}
tla-code: |
dump_spec=import 'dump.json'
inputs: |
.baedeker/just-tests.jsonnet
snippet:(import 'baedeker-library/ops/rewrites.libsonnet').rewriteNodePaths({'bin/polkadot':{dockerImage:'${{ steps.polkadot.outputs.image }}:${{ steps.polkadot.outputs.tag }}'}})
snippet:(import 'baedeker-library/ops/rewrites.libsonnet').rewriteNodePaths({'bin/unique':{dockerImage:'${{ steps.node.outputs.name }}'}}, extra_node_mixin={extraArgs: []})
- name: Ensure network is alive
working-directory: js-packages/tests
id: alive3
if: ${{ !cancelled() && steps.reconcile2.outcome == 'success' }}
run: |
yarn
../scripts/wait_for_first_block.sh
env:
RPC_URL: ${{ env.RELAY_UNIQUE_HTTP_URL }}

- name: Run Parallel tests after upgrade
working-directory: js-packages/tests
if: ${{ !cancelled() && steps.alive3.outcome == 'success' }}
run: |
echo "adding mochawesome"
yarn add mochawesome
echo "Ready to start Parallel tests"
NOW=$(date +%s) && yarn testParallel --reporter mochawesome --reporter-options reportFilename=test-parallel-${NOW}
env:
RPC_URL: ${{ env.RELAY_UNIQUE_HTTP_URL }}

- name: Parallel Test Report
uses: phoenix-actions/test-reporting@v15
id: parallel-report
if: success() || failure()
with:
name: Main Parallel Tests ${{ matrix.network }}
path: js-packages/tests/mochawesome-report/test-parallel-*.json
reporter: mochawesome-json
fail-on-error: 'false'

- name: Run Sequential tests after upgrade
working-directory: js-packages/tests
if: ${{ !cancelled() && steps.alive3.outcome == 'success' }}
run: |
echo "Ready to start Sequential tests"
NOW=$(date +%s) && yarn testSequential --reporter mochawesome --reporter-options reportFilename=test-sequential-${NOW}
env:
RPC_URL: ${{ env.RELAY_UNIQUE_HTTP_URL }}

- name: Sequential Tests Report
uses: phoenix-actions/test-reporting@v15
id: sequential-report
if: success() || failure()
with:
name: Main Sequential Tests ${{ matrix.network }}
path: js-packages/tests/mochawesome-report/test-sequential-*.json
reporter: mochawesome-json
fail-on-error: 'false'

- name: Remove all containers
if: always() # run this step always
run: |
docker ps -aq | xargs docker rm -f
- name: Remove builder cache
if: always() # run this step always
run: |
docker system prune -f -a
20 changes: 20 additions & 0 deletions .github/workflows/main-process-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,16 @@ jobs:
env:
RPC_URL: ${{ env.RELAY_UNIQUE_HTTP_URL }}

- name: Parallel Test Report
uses: phoenix-actions/test-reporting@v15
id: parallel-report
if: success() || failure()
with:
name: Main Parallel Tests ${{ matrix.network }}
path: js-packages/tests/mochawesome-report/test-parallel-*.json
reporter: mochawesome-json
fail-on-error: 'false'

- name: Run Sequential tests after upgrade
working-directory: js-packages/tests
if: ${{ !cancelled() && steps.alive3.outcome == 'success' }}
Expand All @@ -271,6 +281,16 @@ jobs:
env:
RPC_URL: ${{ env.RELAY_UNIQUE_HTTP_URL }}

- name: Sequential Tests Report
uses: phoenix-actions/test-reporting@v15
id: sequential-report
if: success() || failure()
with:
name: Main Sequential Tests ${{ matrix.network }}
path: js-packages/tests/mochawesome-report/test-sequential-*.json
reporter: mochawesome-json
fail-on-error: 'false'

- name: Remove all containers
if: always() # run this step always
run: |
Expand Down

0 comments on commit c949076

Please sign in to comment.