Skip to content

Commit

Permalink
test variables
Browse files Browse the repository at this point in the history
  • Loading branch information
BuddyGlas committed Jun 17, 2024
1 parent ebe982f commit 06c60c0
Show file tree
Hide file tree
Showing 2 changed files with 177 additions and 67 deletions.
76 changes: 9 additions & 67 deletions .github/workflows/collator-selection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
collator-selection:
needs: prepare-execution-marix
# The type of runner that the job will run on
runs-on: [test]
runs-on: [self-hosted]

timeout-minutes: 1380

Expand Down Expand Up @@ -92,72 +92,6 @@ jobs:
password: ${{ secrets.CORE_DOCKERHUB_TOKEN }}
tag: ${{ matrix.relay_branch }}

- name: Prepare latest
uses: ./.github/actions/buildContainer
id: latest
with:
container: uniquenetwork/ci-collator-selection-local
tag: ${{ matrix.network }}-${{ env.REF_SLUG }}-${{ env.BUILD_SHA }}
context: .
dockerfile: .docker/Dockerfile-unique
args: |
--build-arg FEATURES=${{ matrix.network }}-runtime,session-test-timings
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/setup@v1-no-debug-output
with:
useCache: false

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

- name: Start network
uses: UniqueNetwork/baedeker-action@v1-no-debug-output
id: bdk
with:
jpath: |
.baedeker/vendor
tla-str: |
relay_spec=${{ env.RELAY_CHAIN_TYPE }}-local
inputs: |
.baedeker/collator-selection.jsonnet
snippet:(import 'baedeker-library/ops/rewrites.libsonnet').rewriteNodePaths({'bin/polkadot':{dockerImage:'${{ steps.polkadot.outputs.name }}'}})
snippet:(import 'baedeker-library/ops/rewrites.libsonnet').rewriteNodePaths({'bin/unique':{dockerImage:'${{ steps.latest.outputs.name }}'}})
- name: Upload network config
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.network }}-network-config
path: ${{ steps.bdk.outputs.composeProject }}
retention-days: 2

- name: Run tests
working-directory: js-packages/tests
run: |
yarn install
yarn add mochawesome
../scripts/wait_for_first_block.sh
echo "Ready to start tests"
NOW=$(date +%s) && yarn testCollators --reporter mochawesome --reporter-options reportFilename=test-collators-${NOW}
env:
RPC_URL: ${{ env.RELAY_UNIQUE_HTTP_URL }}

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

- name: Clean Workspace
if: always()
uses: AutoModality/[email protected]
Expand All @@ -166,3 +100,11 @@ jobs:
if: always()
run: |
docker system prune -a -f
outputs:
result: ${{ steps.polkadot.outputs.exists }}
result_conclusion: ${{ steps.polkadot.outputs.conclusion }}
image: ${{ steps.polkadot.outputs.image }}
tag: ${{ steps.polkadot.outputs.tag }}


168 changes: 168 additions & 0 deletions .github/workflows/collator-selection.yml_bkp
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
name: collator-selection

# Controls when the action will run.
on:
workflow_call:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

#Define Workflow variables
env:
REPO_URL: ${{ github.server_url }}/${{ github.repository }}

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

prepare-execution-marix:
name: Prepare execution matrix
runs-on: [self-hosted]
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/dotenv@v2

- name: Create Execution matrix
uses: CertainLach/create-matrix-action@v4
id: create_matrix
with:
matrix: |
network {opal}, relay_branch {${{ env.UNIQUEWEST_MAINNET_BRANCH }}}
network {quartz}, relay_branch {${{ env.KUSAMA_MAINNET_BRANCH }}}

collator-selection:
needs: prepare-execution-marix
# The type of runner that the job will run on
runs-on: [self-hosted]

timeout-minutes: 1380

name: ${{ matrix.network }}

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-marix.outputs.matrix)}}

steps:
- name: Skip if pull request is in Draft
if: github.event.pull_request.draft == true
run: exit 1

- 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/dotenv@v2

- 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 latest
uses: ./.github/actions/buildContainer
id: latest
with:
container: uniquenetwork/ci-collator-selection-local
tag: ${{ matrix.network }}-${{ env.REF_SLUG }}-${{ env.BUILD_SHA }}
context: .
dockerfile: .docker/Dockerfile-unique
args: |
--build-arg FEATURES=${{ matrix.network }}-runtime,session-test-timings
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/setup@v1-no-debug-output
with:
useCache: false

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

- name: Start network
uses: UniqueNetwork/baedeker-action@v1-no-debug-output
id: bdk
with:
jpath: |
.baedeker/vendor
tla-str: |
relay_spec=${{ env.RELAY_CHAIN_TYPE }}-local
inputs: |
.baedeker/collator-selection.jsonnet
snippet:(import 'baedeker-library/ops/rewrites.libsonnet').rewriteNodePaths({'bin/polkadot':{dockerImage:'${{ steps.polkadot.outputs.name }}'}})
snippet:(import 'baedeker-library/ops/rewrites.libsonnet').rewriteNodePaths({'bin/unique':{dockerImage:'${{ steps.latest.outputs.name }}'}})

- name: Upload network config
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.network }}-network-config
path: ${{ steps.bdk.outputs.composeProject }}
retention-days: 2

- name: Run tests
working-directory: js-packages/tests
run: |
yarn install
yarn add mochawesome
../scripts/wait_for_first_block.sh
echo "Ready to start tests"
NOW=$(date +%s) && yarn testCollators --reporter mochawesome --reporter-options reportFilename=test-collators-${NOW}
env:
RPC_URL: ${{ env.RELAY_UNIQUE_HTTP_URL }}

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

- name: Clean Workspace
if: always()
uses: AutoModality/[email protected]

- name: Remove builder cache
if: always()
run: |
docker system prune -a -f

0 comments on commit 06c60c0

Please sign in to comment.