From 9859c3fbef5f380de2d30a325c542e46848af90d Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Thu, 8 Jun 2023 15:22:27 +0200 Subject: [PATCH 01/19] Orion integration tests workflow adjustments --- .github/workflows/run-network-tests.yml | 51 +++++++++++++++++++++- tests/network-tests/src/scenarios/orion.ts | 7 +++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 tests/network-tests/src/scenarios/orion.ts diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index 81bca9f41e..310fc6b21c 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -2,6 +2,8 @@ name: run-network-tests on: pull_request: types: [opened, synchronize] + repository_dispatch: + types: [run-network-tests] workflow_dispatch: push: @@ -137,7 +139,54 @@ jobs: name: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz path: joystream-node-docker-image.tar.gz + run_orion_tests: + if: > + github.event_name == 'repository_dispatch' && + github.event.client_payload.sha + name: Load orion docker image from artifact + needs: build_images + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '14.x' + - name: Download Orion Docker image + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{ secrets.ORION_TESTS_TOKEN }} + commit: ${{ github.event.client_payload.sha }} + name: joystream-orion-docker + repo: Lezek123/orion + - name: Load Orion Docker image + run: gunzip -c orion-{{ github.event.client_payload.sha }}.tar.gz | docker load + - name: Install packages and dependencies + run: yarn build:packages + - name: Ensure tests are runnable + run: yarn workspace network-tests build + - name: Execute network tests + run: | + export RUNTIME=${{ needs.build_images.outputs.runtime }} + export SKIP_QUERY_NODE_CHECKS=true + if (tests/network-tests/run-tests.sh orion); then + echo "TESTS_STATUS=success" >> $GITHUB_ENV + else + echo "TESTS_STATUS=failure" >> $GITHUB_ENV + fi + - name: Set commit status + uses: octokit/request-action@v2.x + with: + route: POST /repos/Lezek123/orion/statuses/${{ github.event.client_payload.sha }} + state: ${{ env.TESTS_STATUS }} + target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + description: Integration tests result + context: integration-tests + env: + GITHUB_TOKEN: ${{ secrets.ORION_TESTS_TOKEN }} + + run_test_scenarios: + if: github.event_name == 'pull_request' name: Tests needs: build_images runs-on: ubuntu-latest @@ -179,7 +228,7 @@ jobs: name: Runtime Upgrade from production runtime needs: build_images runs-on: ubuntu-latest - if: github.ref != 'refs/heads/master' + if: github.ref != 'refs/heads/master' && github.event_name == 'pull_request' steps: # Checkout master branch - name: check out master repo diff --git a/tests/network-tests/src/scenarios/orion.ts b/tests/network-tests/src/scenarios/orion.ts new file mode 100644 index 0000000000..793b3a1595 --- /dev/null +++ b/tests/network-tests/src/scenarios/orion.ts @@ -0,0 +1,7 @@ +import { scenario } from '../Scenario' +import buyingMemberships from '../flows/membership/buyingMemberships' + +// eslint-disable-next-line @typescript-eslint/no-floating-promises +scenario('Orion', async ({ job }) => { + job('buying memberships', buyingMemberships) +}) From 24860ed2be064165b7ef1a171ded9f41e17196d5 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Thu, 8 Jun 2023 17:00:20 +0200 Subject: [PATCH 02/19] Use workflow_dispatch instead of repository_dispatch for Orion tests --- .github/workflows/run-network-tests.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index 310fc6b21c..73384ae2f8 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -2,10 +2,11 @@ name: run-network-tests on: pull_request: types: [opened, synchronize] - repository_dispatch: - types: [run-network-tests] - workflow_dispatch: + inputs: + orion_sha: + description: 'SHA of Orion repositry commit to use for testing Orion' + required: false push: jobs: @@ -140,9 +141,7 @@ jobs: path: joystream-node-docker-image.tar.gz run_orion_tests: - if: > - github.event_name == 'repository_dispatch' && - github.event.client_payload.sha + if: github.event.inputs.orion_sha != '' name: Load orion docker image from artifact needs: build_images runs-on: ubuntu-latest @@ -155,11 +154,11 @@ jobs: uses: dawidd6/action-download-artifact@v2 with: github_token: ${{ secrets.ORION_TESTS_TOKEN }} - commit: ${{ github.event.client_payload.sha }} + commit: ${{ github.event.inputs.orion_sha }} name: joystream-orion-docker repo: Lezek123/orion - name: Load Orion Docker image - run: gunzip -c orion-{{ github.event.client_payload.sha }}.tar.gz | docker load + run: gunzip -c orion-{{ github.event.inputs.orion_sha }}.tar.gz | docker load - name: Install packages and dependencies run: yarn build:packages - name: Ensure tests are runnable @@ -176,7 +175,7 @@ jobs: - name: Set commit status uses: octokit/request-action@v2.x with: - route: POST /repos/Lezek123/orion/statuses/${{ github.event.client_payload.sha }} + route: POST /repos/Lezek123/orion/statuses/${{ github.event.inputs.orion_sha }} state: ${{ env.TESTS_STATUS }} target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} description: Integration tests result @@ -186,7 +185,7 @@ jobs: run_test_scenarios: - if: github.event_name == 'pull_request' + if: github.event.inputs.orion_sha == '' name: Tests needs: build_images runs-on: ubuntu-latest @@ -228,7 +227,7 @@ jobs: name: Runtime Upgrade from production runtime needs: build_images runs-on: ubuntu-latest - if: github.ref != 'refs/heads/master' && github.event_name == 'pull_request' + if: github.ref != 'refs/heads/master' && github.event.inputs.orion_sha == '' steps: # Checkout master branch - name: check out master repo From e5b7ca75aba1f6db46883f917bdbf80adcfeec02 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Thu, 8 Jun 2023 17:24:03 +0200 Subject: [PATCH 03/19] Add workflow name to run_orion_tests ("Download Orion Docker image" step) --- .github/workflows/run-network-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index 73384ae2f8..f15ea7e823 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -157,6 +157,7 @@ jobs: commit: ${{ github.event.inputs.orion_sha }} name: joystream-orion-docker repo: Lezek123/orion + workflow: tests.yml - name: Load Orion Docker image run: gunzip -c orion-{{ github.event.inputs.orion_sha }}.tar.gz | docker load - name: Install packages and dependencies From 7b8731a617d7867d3fc7b0667fb7154d5a7c5aed Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Thu, 8 Jun 2023 17:41:52 +0200 Subject: [PATCH 04/19] Fix syntax in "Load Orion Docker image" --- .github/workflows/run-network-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index f15ea7e823..b832456ce7 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -159,7 +159,7 @@ jobs: repo: Lezek123/orion workflow: tests.yml - name: Load Orion Docker image - run: gunzip -c orion-{{ github.event.inputs.orion_sha }}.tar.gz | docker load + run: gunzip -c orion-${{ github.event.inputs.orion_sha }}.tar.gz | docker load - name: Install packages and dependencies run: yarn build:packages - name: Ensure tests are runnable From 074024ddf297ed488f7c999afd1da8a5e732e05c Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Thu, 8 Jun 2023 18:26:31 +0200 Subject: [PATCH 05/19] Add cross-repository pending status to run_orion_tests --- .github/workflows/run-network-tests.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index b832456ce7..9d972ac09f 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -150,6 +150,14 @@ jobs: - uses: actions/setup-node@v3 with: node-version: '14.x' + - name: Set pending status in Orion repo + uses: octokit/request-action@v2.x + with: + route: POST /repos/Lezek123/orion/statuses/${{ github.event.inputs.orion_sha }} + state: pending + target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + description: Integration tests result + context: integration-tests - name: Download Orion Docker image uses: dawidd6/action-download-artifact@v2 with: @@ -173,7 +181,7 @@ jobs: else echo "TESTS_STATUS=failure" >> $GITHUB_ENV fi - - name: Set commit status + - name: Set final status in Orion repo uses: octokit/request-action@v2.x with: route: POST /repos/Lezek123/orion/statuses/${{ github.event.inputs.orion_sha }} From 8adb48146cd48c1aecda44a8fdf32c8724ce9720 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Thu, 8 Jun 2023 18:27:09 +0200 Subject: [PATCH 06/19] runOrionChecks proof of concept --- tests/network-tests/src/Fixture.ts | 28 +++++++++++++++++-- .../BuyMembershipHappyCaseFixture.ts | 20 +++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/tests/network-tests/src/Fixture.ts b/tests/network-tests/src/Fixture.ts index 5bd7de4819..41599b80f7 100644 --- a/tests/network-tests/src/Fixture.ts +++ b/tests/network-tests/src/Fixture.ts @@ -1,7 +1,6 @@ import { Api } from './Api' import { assert } from 'chai' import { ISubmittableResult } from '@polkadot/types/types/' -import { DispatchResult } from '@polkadot/types/interfaces/system' import { QueryNodeApi } from './QueryNodeApi' import { SubmittableExtrinsic } from '@polkadot/api/types' import { extendDebug, Debugger } from './Debugger' @@ -90,6 +89,13 @@ export abstract class BaseQueryNodeFixture extends BaseFixture { // Implement in child class! } + public async runOrionChecks(): Promise { + if (!this.executed) { + throw new Error('Cannot run orion checks before Fixture is executed') + } + // Implement in child class! + } + protected findMatchingQueryNodeEvent( eventToFind: EventDetails, queryNodeEvents: T[] @@ -125,7 +131,7 @@ export abstract class StandardizedFixture extends BaseQueryNodeFixture { }) } - public setErrorName(errName: string) { + public setErrorName(errName: string): void { this.expectedErrorName = errName } @@ -154,6 +160,7 @@ export class FixtureRunner { private fixture: BaseFixture private ran = false private queryNodeChecksRan = false + private orionChecksRan = false constructor(fixture: BaseFixture) { this.fixture = fixture @@ -190,8 +197,25 @@ export class FixtureRunner { await this.fixture.runQueryNodeChecks() } + public async runOrionChecks(): Promise { + if (process.env.SKIP_ORION_CHECKS) { + return + } + if (!(this.fixture instanceof BaseQueryNodeFixture)) { + throw new Error('Tried to run orion checks for non-query-node fixture!') + } + if (this.orionChecksRan) { + throw new Error('Fixture orion checks already ran') + } + + this.orionChecksRan = true + + await this.fixture.runOrionChecks() + } + public async runWithQueryNodeChecks(): Promise { await this.run() await this.runQueryNodeChecks() + await this.runOrionChecks() } } diff --git a/tests/network-tests/src/fixtures/membership/BuyMembershipHappyCaseFixture.ts b/tests/network-tests/src/fixtures/membership/BuyMembershipHappyCaseFixture.ts index b1321c8283..df351d03b8 100644 --- a/tests/network-tests/src/fixtures/membership/BuyMembershipHappyCaseFixture.ts +++ b/tests/network-tests/src/fixtures/membership/BuyMembershipHappyCaseFixture.ts @@ -11,6 +11,7 @@ import { MembershipBoughtEventFieldsFragment, MembershipFieldsFragment } from '. import { Utils } from '../../utils' import { StandardizedFixture } from '../../Fixture' import { SubmittableResult } from '@polkadot/api' +import axios from 'axios' type MembershipBoughtEventDetails = EventDetails> @@ -124,4 +125,23 @@ export class BuyMembershipHappyCaseFixture extends StandardizedFixture { const qMembers = await this.query.getMembersByIds(this.events.map((e) => e.event.data[0])) this.assertQueriedMembersAreValid(qMembers, qEvents) } + + public async runOrionChecks(): Promise { + await super.runOrionChecks() + // Wait a minute, let Orion catch up + await Utils.wait(60_000) + const result = await axios.post('http://localhost:4350/graphql', { + query: ` + query { + memberships(where: { id_in: $ids }) { + id + } + } + `, + variables: { + ids: this.getCreatedMembers().map((id) => id.toString()), + }, + }) + assert.equal(result.data.data.memberships.length, this.getCreatedMembers().length) + } } From 31267fff6a791305f4932c402fda60d9fa319979 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Thu, 8 Jun 2023 19:09:20 +0200 Subject: [PATCH 07/19] Add missing GITHUB_TOKEN --- .github/workflows/run-network-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index 9d972ac09f..793933cec1 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -158,6 +158,8 @@ jobs: target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} description: Integration tests result context: integration-tests + env: + GITHUB_TOKEN: ${{ secrets.ORION_TESTS_TOKEN }} - name: Download Orion Docker image uses: dawidd6/action-download-artifact@v2 with: From e42ee88451ba4833632ef76dc9395634891b42ed Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Thu, 8 Jun 2023 20:05:24 +0200 Subject: [PATCH 08/19] run-tests.sh - start Orion --- tests/network-tests/run-tests.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/network-tests/run-tests.sh b/tests/network-tests/run-tests.sh index 48ffc85f91..eccf8f6e38 100755 --- a/tests/network-tests/run-tests.sh +++ b/tests/network-tests/run-tests.sh @@ -29,6 +29,12 @@ then ../../query-node/start.sh fi +# Start orion +if [ "${NO_ORION}" != true ] +then + ../../start-orion.sh +fi + # Execute tests if [ "${NO_STORAGE}" != true ] From 9509de543a30a01e253eb039f49134e461b0c1cc Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Fri, 9 Jun 2023 11:11:06 +0200 Subject: [PATCH 09/19] Fix start-orion.sh script (cd to BASH_SOURCE[0]) --- start-orion.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/start-orion.sh b/start-orion.sh index 9c9325876d..fb07cf4c56 100755 --- a/start-orion.sh +++ b/start-orion.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -e +SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")" +cd $SCRIPT_PATH + docker-compose up -d orion-db docker-compose up -d squid-archive docker-compose up -d squid-archive-gateway From 9182ce868d8e9abc4e0283cfaa926f62aec78d19 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Fri, 9 Jun 2023 11:16:12 +0200 Subject: [PATCH 10/19] Add Orion tests result marking step --- .github/workflows/run-network-tests.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index 793933cec1..242535119f 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -193,6 +193,15 @@ jobs: context: integration-tests env: GITHUB_TOKEN: ${{ secrets.ORION_TESTS_TOKEN }} + - name: Test result + run: | + if [ "${{ env.TESTS_STATUS }}" == "success" ]; then + echo "Tests passed" + exit 0 + else + echo "Tests failed" + exit 1 + fi run_test_scenarios: From 16e64e8e8f6df4b96f217b9690043a3a7abf708c Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Fri, 9 Jun 2023 12:03:50 +0200 Subject: [PATCH 11/19] Fix Orion GraphQL query --- .../fixtures/membership/BuyMembershipHappyCaseFixture.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/network-tests/src/fixtures/membership/BuyMembershipHappyCaseFixture.ts b/tests/network-tests/src/fixtures/membership/BuyMembershipHappyCaseFixture.ts index df351d03b8..b419a7c0c1 100644 --- a/tests/network-tests/src/fixtures/membership/BuyMembershipHappyCaseFixture.ts +++ b/tests/network-tests/src/fixtures/membership/BuyMembershipHappyCaseFixture.ts @@ -133,14 +133,13 @@ export class BuyMembershipHappyCaseFixture extends StandardizedFixture { const result = await axios.post('http://localhost:4350/graphql', { query: ` query { - memberships(where: { id_in: $ids }) { + memberships(where: { id_in: [${this.getCreatedMembers() + .map((id) => `"${id}"`) + .join(', ')}] }) { id } } `, - variables: { - ids: this.getCreatedMembers().map((id) => id.toString()), - }, }) assert.equal(result.data.data.memberships.length, this.getCreatedMembers().length) } From a06d135be8f2b31c06d40b17756f013e01c91b89 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Fri, 9 Jun 2023 13:26:59 +0200 Subject: [PATCH 12/19] Make Orion repo configurable --- .github/workflows/run-network-tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index 242535119f..891579ab27 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -142,7 +142,7 @@ jobs: run_orion_tests: if: github.event.inputs.orion_sha != '' - name: Load orion docker image from artifact + name: Orion integration tests needs: build_images runs-on: ubuntu-latest steps: @@ -153,7 +153,7 @@ jobs: - name: Set pending status in Orion repo uses: octokit/request-action@v2.x with: - route: POST /repos/Lezek123/orion/statuses/${{ github.event.inputs.orion_sha }} + route: POST /repos/${{ vars.ORION_REPO }}/statuses/${{ github.event.inputs.orion_sha }} state: pending target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} description: Integration tests result @@ -166,7 +166,7 @@ jobs: github_token: ${{ secrets.ORION_TESTS_TOKEN }} commit: ${{ github.event.inputs.orion_sha }} name: joystream-orion-docker - repo: Lezek123/orion + repo: ${{ vars.ORION_REPO }} workflow: tests.yml - name: Load Orion Docker image run: gunzip -c orion-${{ github.event.inputs.orion_sha }}.tar.gz | docker load @@ -186,7 +186,7 @@ jobs: - name: Set final status in Orion repo uses: octokit/request-action@v2.x with: - route: POST /repos/Lezek123/orion/statuses/${{ github.event.inputs.orion_sha }} + route: POST /repos/${{ vars.ORION_REPO }}/statuses/${{ github.event.inputs.orion_sha }} state: ${{ env.TESTS_STATUS }} target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} description: Integration tests result From 5ba5f26cceccca3e8a253141d22c3ae5b8b67feb Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Fri, 9 Jun 2023 17:05:42 +0200 Subject: [PATCH 13/19] Rename Orion workflow --- .github/workflows/run-network-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index 891579ab27..5220c42405 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -167,7 +167,7 @@ jobs: commit: ${{ github.event.inputs.orion_sha }} name: joystream-orion-docker repo: ${{ vars.ORION_REPO }} - workflow: tests.yml + workflow: build-docker-image.yml - name: Load Orion Docker image run: gunzip -c orion-${{ github.event.inputs.orion_sha }}.tar.gz | docker load - name: Install packages and dependencies From a4e70e237c0eaf093fdf79845b206ca8fa8077b9 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Sat, 10 Jun 2023 12:46:14 +0200 Subject: [PATCH 14/19] Upload Orion tests result as artifact --- .github/workflows/run-network-tests.yml | 41 ++++++++----------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index 5220c42405..359babcf3d 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -150,16 +150,6 @@ jobs: - uses: actions/setup-node@v3 with: node-version: '14.x' - - name: Set pending status in Orion repo - uses: octokit/request-action@v2.x - with: - route: POST /repos/${{ vars.ORION_REPO }}/statuses/${{ github.event.inputs.orion_sha }} - state: pending - target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - description: Integration tests result - context: integration-tests - env: - GITHUB_TOKEN: ${{ secrets.ORION_TESTS_TOKEN }} - name: Download Orion Docker image uses: dawidd6/action-download-artifact@v2 with: @@ -183,25 +173,20 @@ jobs: else echo "TESTS_STATUS=failure" >> $GITHUB_ENV fi - - name: Set final status in Orion repo - uses: octokit/request-action@v2.x + + upload_orion_tests_result_artifact: + name: Upload Orion tests result artifact + needs: run_orion_tests + if: ${{ always() }} + runs-on: ubuntu-latest + steps: + - name: Create result file + run: echo $TESTS_STATUS > result.txt + - name: Upload the result artifact + uses: actions/upload-artifact@v3 with: - route: POST /repos/${{ vars.ORION_REPO }}/statuses/${{ github.event.inputs.orion_sha }} - state: ${{ env.TESTS_STATUS }} - target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - description: Integration tests result - context: integration-tests - env: - GITHUB_TOKEN: ${{ secrets.ORION_TESTS_TOKEN }} - - name: Test result - run: | - if [ "${{ env.TESTS_STATUS }}" == "success" ]; then - echo "Tests passed" - exit 0 - else - echo "Tests failed" - exit 1 - fi + name: orion-tests-${{ github.event.inputs.orion_sha }}-${{ github.event.inputs.attempt }} + path: result.txt run_test_scenarios: From 52c133c1ab6b4d0aca07deed16ab05a69491d793 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Sat, 10 Jun 2023 13:05:38 +0200 Subject: [PATCH 15/19] Add attempt parameter --- .github/workflows/run-network-tests.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index 359babcf3d..ebe81c4733 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -7,6 +7,11 @@ on: orion_sha: description: 'SHA of Orion repositry commit to use for testing Orion' required: false + attempt: + description: | + Orion integration tests attempt number + (to identify individual testing attempts for the same commit) + required: false push: jobs: From b51b0b90cb41dd05540c35ca36ecbf37afc99d38 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Sat, 10 Jun 2023 14:05:16 +0200 Subject: [PATCH 16/19] Change Orion docker build artifact structure --- .github/workflows/run-network-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index ebe81c4733..bb726cb3f3 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -160,11 +160,11 @@ jobs: with: github_token: ${{ secrets.ORION_TESTS_TOKEN }} commit: ${{ github.event.inputs.orion_sha }} - name: joystream-orion-docker + name: joystream-orion-docker-${{ github.event.inputs.orion_sha }} repo: ${{ vars.ORION_REPO }} workflow: build-docker-image.yml - name: Load Orion Docker image - run: gunzip -c orion-${{ github.event.inputs.orion_sha }}.tar.gz | docker load + run: gunzip -c orion.tar.gz | docker load - name: Install packages and dependencies run: yarn build:packages - name: Ensure tests are runnable From a98c4440c3084b9242120df89765dad85433585f Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Sat, 10 Jun 2023 15:20:49 +0200 Subject: [PATCH 17/19] Fix orion test results status --- .github/workflows/run-network-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index bb726cb3f3..3f11f561ca 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -177,6 +177,7 @@ jobs: echo "TESTS_STATUS=success" >> $GITHUB_ENV else echo "TESTS_STATUS=failure" >> $GITHUB_ENV + exit 1 fi upload_orion_tests_result_artifact: @@ -186,7 +187,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Create result file - run: echo $TESTS_STATUS > result.txt + run: echo "${{ env.TESTS_STATUS }}" > result.txt - name: Upload the result artifact uses: actions/upload-artifact@v3 with: From e5e02327dba2fd7af8d9eb51c6c24d8e915da310 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Mon, 12 Jun 2023 10:46:40 +0200 Subject: [PATCH 18/19] Use "outputs" to preserve orion tests status across jobs --- .github/workflows/run-network-tests.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index 3f11f561ca..b0390fbefc 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -170,15 +170,18 @@ jobs: - name: Ensure tests are runnable run: yarn workspace network-tests build - name: Execute network tests + id: execute_network_tests run: | export RUNTIME=${{ needs.build_images.outputs.runtime }} export SKIP_QUERY_NODE_CHECKS=true if (tests/network-tests/run-tests.sh orion); then - echo "TESTS_STATUS=success" >> $GITHUB_ENV + echo "tests_status=success" >> $GITHUB_OUTPUT else - echo "TESTS_STATUS=failure" >> $GITHUB_ENV + echo "tests_status=failure" >> $GITHUB_OUTPUT exit 1 fi + outputs: + tests_status: ${{ steps.execute_network_tests.outputs.tests_status }} upload_orion_tests_result_artifact: name: Upload Orion tests result artifact @@ -187,7 +190,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Create result file - run: echo "${{ env.TESTS_STATUS }}" > result.txt + run: echo "${{ needs.run_orion_tests.outputs.tests_status }}" > result.txt - name: Upload the result artifact uses: actions/upload-artifact@v3 with: From 259f07cb434035fd894eb39da045e3fb8a77ddb6 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Tue, 13 Jun 2023 17:27:32 +0200 Subject: [PATCH 19/19] Revert changes to `run-network-tests.yml` due to alternative approach chosen in Orion repository --- .github/workflows/run-network-tests.yml | 66 +------------------------ 1 file changed, 2 insertions(+), 64 deletions(-) diff --git a/.github/workflows/run-network-tests.yml b/.github/workflows/run-network-tests.yml index b0390fbefc..81bca9f41e 100644 --- a/.github/workflows/run-network-tests.yml +++ b/.github/workflows/run-network-tests.yml @@ -2,16 +2,8 @@ name: run-network-tests on: pull_request: types: [opened, synchronize] + workflow_dispatch: - inputs: - orion_sha: - description: 'SHA of Orion repositry commit to use for testing Orion' - required: false - attempt: - description: | - Orion integration tests attempt number - (to identify individual testing attempts for the same commit) - required: false push: jobs: @@ -145,61 +137,7 @@ jobs: name: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz path: joystream-node-docker-image.tar.gz - run_orion_tests: - if: github.event.inputs.orion_sha != '' - name: Orion integration tests - needs: build_images - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: '14.x' - - name: Download Orion Docker image - uses: dawidd6/action-download-artifact@v2 - with: - github_token: ${{ secrets.ORION_TESTS_TOKEN }} - commit: ${{ github.event.inputs.orion_sha }} - name: joystream-orion-docker-${{ github.event.inputs.orion_sha }} - repo: ${{ vars.ORION_REPO }} - workflow: build-docker-image.yml - - name: Load Orion Docker image - run: gunzip -c orion.tar.gz | docker load - - name: Install packages and dependencies - run: yarn build:packages - - name: Ensure tests are runnable - run: yarn workspace network-tests build - - name: Execute network tests - id: execute_network_tests - run: | - export RUNTIME=${{ needs.build_images.outputs.runtime }} - export SKIP_QUERY_NODE_CHECKS=true - if (tests/network-tests/run-tests.sh orion); then - echo "tests_status=success" >> $GITHUB_OUTPUT - else - echo "tests_status=failure" >> $GITHUB_OUTPUT - exit 1 - fi - outputs: - tests_status: ${{ steps.execute_network_tests.outputs.tests_status }} - - upload_orion_tests_result_artifact: - name: Upload Orion tests result artifact - needs: run_orion_tests - if: ${{ always() }} - runs-on: ubuntu-latest - steps: - - name: Create result file - run: echo "${{ needs.run_orion_tests.outputs.tests_status }}" > result.txt - - name: Upload the result artifact - uses: actions/upload-artifact@v3 - with: - name: orion-tests-${{ github.event.inputs.orion_sha }}-${{ github.event.inputs.attempt }} - path: result.txt - - run_test_scenarios: - if: github.event.inputs.orion_sha == '' name: Tests needs: build_images runs-on: ubuntu-latest @@ -241,7 +179,7 @@ jobs: name: Runtime Upgrade from production runtime needs: build_images runs-on: ubuntu-latest - if: github.ref != 'refs/heads/master' && github.event.inputs.orion_sha == '' + if: github.ref != 'refs/heads/master' steps: # Checkout master branch - name: check out master repo