From c1faa313091450e6e0d2181b251e13e0dcfd2c29 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Thu, 8 Jun 2023 15:36:48 +0200 Subject: [PATCH 01/20] Trigger integration tests workflow --- .github/workflows/tests.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..161862ed6 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,29 @@ +name: External integration tests + +on: + push: + +jobs: + trigger-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build Docker image + run: make build-docker + - name: Save Docker image + run: docker save joystream/orion:latest | gzip > orion-{{ github.sha }}.tar.gz + - name: Upload Docker image + uses: actions/upload-artifact@v3 + with: + name: joystream-orion-docker + path: orion-{{ github.sha }}.tar.gz + - name: Trigger tests + uses: peter-evans/repository-dispatch@v2 + with: + token: ${{ secrets.TIGGER_TESTS_TOKEN }} + repository: Lezek123/substrate-runtime-joystream + event-type: run-network-tests + client-payload: > + { + "sha": "${{ github.sha }}" + } \ No newline at end of file From 54cfd243ef5db0fa2f3e11dab5036f0bd4a4ee95 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Thu, 8 Jun 2023 15:49:00 +0200 Subject: [PATCH 02/20] Syntax fixes in tests.yml --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 161862ed6..2b38ea3e2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,12 +11,12 @@ jobs: - name: Build Docker image run: make build-docker - name: Save Docker image - run: docker save joystream/orion:latest | gzip > orion-{{ github.sha }}.tar.gz + run: docker save joystream/orion:latest | gzip > orion-${{ github.sha }}.tar.gz - name: Upload Docker image uses: actions/upload-artifact@v3 with: name: joystream-orion-docker - path: orion-{{ github.sha }}.tar.gz + path: orion-${{ github.sha }}.tar.gz - name: Trigger tests uses: peter-evans/repository-dispatch@v2 with: From 815361ea37c8215c673dd70ea7b5a886cd39deec Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Thu, 8 Jun 2023 15:55:26 +0200 Subject: [PATCH 03/20] Fix typo --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2b38ea3e2..c60ccdc01 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,7 @@ jobs: - name: Trigger tests uses: peter-evans/repository-dispatch@v2 with: - token: ${{ secrets.TIGGER_TESTS_TOKEN }} + token: ${{ secrets.TRIGGER_TESTS_TOKEN }} repository: Lezek123/substrate-runtime-joystream event-type: run-network-tests client-payload: > From 3ca596b4a7559725ceddf77a1cf55b745071dd84 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Thu, 8 Jun 2023 17:03:59 +0200 Subject: [PATCH 04/20] Replace repository-dispatch with workflow-dispatch --- .github/workflows/tests.yml | 41 +++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c60ccdc01..38a375098 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,23 +7,24 @@ jobs: trigger-tests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Build Docker image - run: make build-docker - - name: Save Docker image - run: docker save joystream/orion:latest | gzip > orion-${{ github.sha }}.tar.gz - - name: Upload Docker image - uses: actions/upload-artifact@v3 - with: - name: joystream-orion-docker - path: orion-${{ github.sha }}.tar.gz - - name: Trigger tests - uses: peter-evans/repository-dispatch@v2 - with: - token: ${{ secrets.TRIGGER_TESTS_TOKEN }} - repository: Lezek123/substrate-runtime-joystream - event-type: run-network-tests - client-payload: > - { - "sha": "${{ github.sha }}" - } \ No newline at end of file + - uses: actions/checkout@v3 + - name: Build Docker image + run: make build-docker + - name: Save Docker image + run: docker save joystream/orion:latest | gzip > orion-${{ github.sha }}.tar.gz + - name: Upload Docker image + uses: actions/upload-artifact@v3 + with: + name: joystream-orion-docker + path: orion-${{ github.sha }}.tar.gz + - name: Trigger tests + uses: benc-uk/workflow-dispatch@v1 + with: + token: ${{ secrets.TRIGGER_TESTS_TOKEN }} + repo: Lezek123/substrate-runtime-joystream + ref: orion-integration-tests + workflow: run-network-tests.yml + inputs: > + { + "orion_sha": "${{ github.sha }}" + } From 540d7c7c0a0c8b197dd3b8c10fce863ad074b360 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Thu, 8 Jun 2023 18:28:14 +0200 Subject: [PATCH 05/20] trigger-tests: Add initial "Pending" status --- .github/workflows/tests.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 38a375098..16aaea9c0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,3 +28,10 @@ jobs: { "orion_sha": "${{ github.sha }}" } + - name: Set pending status + uses: octokit/request-action@v2.x + with: + route: POST /repos/${{ github.repository }}/statuses/${{ github.sha }} + state: pending + description: Integration tests result + context: integration-tests From ff3af14c2f0dd1e1c5a6aef06ccf003d03cb650e Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Thu, 8 Jun 2023 18:33:01 +0200 Subject: [PATCH 06/20] Add missing GITHUB_TOKEN --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 16aaea9c0..1a56ba5ce 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -35,3 +35,5 @@ jobs: state: pending description: Integration tests result context: integration-tests + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 9d81af1c7adc7ec3435ca96a5bcbc927a18f58b3 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Fri, 9 Jun 2023 17:05:18 +0200 Subject: [PATCH 07/20] Allow integration tests tiggering on pull_request --- .github/workflows/build-docker-image.yml | 18 ++++++++ .github/workflows/checks.yml | 16 ------- .github/workflows/tests.yml | 39 ----------------- .github/workflows/trigger-tests.yml | 54 ++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/build-docker-image.yml delete mode 100644 .github/workflows/tests.yml create mode 100644 .github/workflows/trigger-tests.yml diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml new file mode 100644 index 000000000..4786ad454 --- /dev/null +++ b/.github/workflows/build-docker-image.yml @@ -0,0 +1,18 @@ +name: Build and save docker image + +on: [push, pull_request] + +jobs: + build-docker-image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build Docker image + run: make build-docker + - name: Save Docker image + run: docker save joystream/orion:latest | gzip > orion-${{ github.sha }}.tar.gz + - name: Upload Docker image + uses: actions/upload-artifact@v3 + with: + name: joystream-orion-docker + path: orion-${{ github.sha }}.tar.gz diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0a1e19223..b7836d2d4 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -20,19 +20,3 @@ jobs: run: npm ci - name: Run checks run: npm run checks - docker: - name: Docker build check - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - node-version: [16.x] - fail-fast: true - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{matrix.node-version}} - uses: actions/setup-node@v1 - with: - node-version: ${{matrix.node-version}} - - name: Build docker image - run: make build-docker diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 1a56ba5ce..000000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: External integration tests - -on: - push: - -jobs: - trigger-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Build Docker image - run: make build-docker - - name: Save Docker image - run: docker save joystream/orion:latest | gzip > orion-${{ github.sha }}.tar.gz - - name: Upload Docker image - uses: actions/upload-artifact@v3 - with: - name: joystream-orion-docker - path: orion-${{ github.sha }}.tar.gz - - name: Trigger tests - uses: benc-uk/workflow-dispatch@v1 - with: - token: ${{ secrets.TRIGGER_TESTS_TOKEN }} - repo: Lezek123/substrate-runtime-joystream - ref: orion-integration-tests - workflow: run-network-tests.yml - inputs: > - { - "orion_sha": "${{ github.sha }}" - } - - name: Set pending status - uses: octokit/request-action@v2.x - with: - route: POST /repos/${{ github.repository }}/statuses/${{ github.sha }} - state: pending - description: Integration tests result - context: integration-tests - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/trigger-tests.yml b/.github/workflows/trigger-tests.yml new file mode 100644 index 000000000..56aaaf654 --- /dev/null +++ b/.github/workflows/trigger-tests.yml @@ -0,0 +1,54 @@ +name: Trigger external integration tests + +on: [push, pull_request_target] + +jobs: + trigger-tests: + runs-on: ubuntu-latest + environment: + name: ${{ github.ref_name }} + steps: + - name: Wait until build-docker-image workflow finishes successfully + run: | + CONCLUSION="null" + while [[ "$CONCLUSION" == "null" ]] + do + STATUS=$( + curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{ github.repository }}/actions/workflows/build-docker-image.yml/runs?head_sha=${{ github.sha }} \ + | jq -r '.workflow_runs[0].conclusion' + ) + if [[ "$CONCLUSION" == "null" ]] + then + echo "Waiting for build-docker-image workflow to finish..." + exit 1 + fi + done + if [[ "$CONCLUSION" != "success" ]] + then + echo "build-docker-image workflow failed" + exit 1 + fi + - name: Trigger tests + uses: benc-uk/workflow-dispatch@v1 + with: + token: ${{ secrets.TRIGGER_TESTS_TOKEN }} + repo: ${{ vars.INTEGRATION_TESTS_REPO }} + ref: ${{ vars.INTEGRATION_TESTS_BRANCH }} + workflow: run-network-tests.yml + inputs: > + { + "orion_sha": "${{ github.sha }}" + } + - name: Set pending status + uses: octokit/request-action@v2.x + with: + route: POST /repos/${{ github.repository }}/statuses/${{ github.sha }} + state: pending + description: Integration tests result + context: integration-tests + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From ad18e475c249bbddee2d0373ecb17f8b97955d80 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Fri, 9 Jun 2023 17:09:08 +0200 Subject: [PATCH 08/20] trigger-tests workflow: fix env variable name bug and add build-docker-image workflow conclusion log --- .github/workflows/trigger-tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/trigger-tests.yml b/.github/workflows/trigger-tests.yml index 56aaaf654..0d659ad42 100644 --- a/.github/workflows/trigger-tests.yml +++ b/.github/workflows/trigger-tests.yml @@ -13,7 +13,7 @@ jobs: CONCLUSION="null" while [[ "$CONCLUSION" == "null" ]] do - STATUS=$( + CONCLUSION=$( curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ @@ -21,6 +21,7 @@ jobs: https://api.github.com/repos/${{ github.repository }}/actions/workflows/build-docker-image.yml/runs?head_sha=${{ github.sha }} \ | jq -r '.workflow_runs[0].conclusion' ) + echo "build-docker-image workflow conclusion: $CONCLUSION" if [[ "$CONCLUSION" == "null" ]] then echo "Waiting for build-docker-image workflow to finish..." From bb1d70d56c30f41af53e4449fe4516467136c12f Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Fri, 9 Jun 2023 17:14:17 +0200 Subject: [PATCH 09/20] trigger-tests.yml: Remove invalid exit line --- .github/workflows/trigger-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/trigger-tests.yml b/.github/workflows/trigger-tests.yml index 0d659ad42..69c05b193 100644 --- a/.github/workflows/trigger-tests.yml +++ b/.github/workflows/trigger-tests.yml @@ -25,7 +25,6 @@ jobs: if [[ "$CONCLUSION" == "null" ]] then echo "Waiting for build-docker-image workflow to finish..." - exit 1 fi done if [[ "$CONCLUSION" != "success" ]] From 4b6781d5340e1a47408ddcaadaf76918a10d038e Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Fri, 9 Jun 2023 17:20:05 +0200 Subject: [PATCH 10/20] trigger-tests.yml: Add sleep to waiting script --- .github/workflows/trigger-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/trigger-tests.yml b/.github/workflows/trigger-tests.yml index 69c05b193..e2c51d8fe 100644 --- a/.github/workflows/trigger-tests.yml +++ b/.github/workflows/trigger-tests.yml @@ -25,6 +25,7 @@ jobs: if [[ "$CONCLUSION" == "null" ]] then echo "Waiting for build-docker-image workflow to finish..." + sleep 30 fi done if [[ "$CONCLUSION" != "success" ]] From bd1a6788e022623b34dd3030c6c0d6b9cccbba16 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Sat, 10 Jun 2023 12:48:01 +0200 Subject: [PATCH 11/20] Allow integration tests branch dynamic customization --- .github/workflows/trigger-tests.yml | 78 ++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 12 deletions(-) diff --git a/.github/workflows/trigger-tests.yml b/.github/workflows/trigger-tests.yml index e2c51d8fe..fa3a3d865 100644 --- a/.github/workflows/trigger-tests.yml +++ b/.github/workflows/trigger-tests.yml @@ -2,6 +2,9 @@ name: Trigger external integration tests on: [push, pull_request_target] +env: + INTEGRATION_TESTS_BRANCH: ${{ vars.INTEGRATION_TESTS_BRANCH }} + jobs: trigger-tests: runs-on: ubuntu-latest @@ -33,23 +36,74 @@ jobs: echo "build-docker-image workflow failed" exit 1 fi + - name: Fetch integration tests branch from PR comment if provided + if: github.event_name == 'pull_request_target' + run: | + BRANCH=$( + curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ + | jq ' + .[] + | select( + (.author_association = "OWNER") or + (.author_association = "MEMBER") or + (.author_association = "CONTRIBUTOR") + ) + | select (.body | test("/set-integration-tests-branch +")) + | .body' + | cut -d ' ' -f 2 + ) + echo "INTEGRATION_TESTS_BRANCH=$BRANCH" >> $GITHUB_ENV - name: Trigger tests uses: benc-uk/workflow-dispatch@v1 with: - token: ${{ secrets.TRIGGER_TESTS_TOKEN }} + token: ${{ secrets.INTEGRATION_TESTS_TOKEN }} repo: ${{ vars.INTEGRATION_TESTS_REPO }} - ref: ${{ vars.INTEGRATION_TESTS_BRANCH }} + ref: ${{ env.INTEGRATION_TESTS_BRANCH }} workflow: run-network-tests.yml inputs: > { - "orion_sha": "${{ github.sha }}" + "orion_sha": "${{ github.sha }}", + "attempt": "${{ github.run_attempt }}" } - - name: Set pending status - uses: octokit/request-action@v2.x - with: - route: POST /repos/${{ github.repository }}/statuses/${{ github.sha }} - state: pending - description: Integration tests result - context: integration-tests - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get tests run result + run: | + ARTIFACT_URL="null" + while [[ "$ARTIFACT_URL" == "null" ]] + do + ARTIFACT_URL=$( + curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.INTEGRATION_TESTS_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{ vars.INTEGRATION_TESTS_REPO }}/actions/artifacts?name=orion-tests-${{ github.sha }}-${{ github.run_attempt }} \ + | jq -r '.artifacts[0].archive_download_url' + if [[ "$ARTIFACT_URL" != "null" ]] + then + # Download artifact + curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.INTEGRATION_TESTS_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + $ARTIFACT_URL \ + -o artifact.zip + # Unzip artifact + unzip artifact.zip + # Get result + RESULT=$(cat result.txt) + if [[ "$RESULT" == "success" ]] + then + echo "Tests passed" + exit 0 + else + echo "Tests failed" + exit 1 + fi + else + echo "Waiting for test results to be uploaded..." + sleep 30 + fi + done From 788147e6c606a2e6e6fec083eb7cc7602e300fc6 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Sat, 10 Jun 2023 13:09:34 +0200 Subject: [PATCH 12/20] Add missing parenthese --- .github/workflows/trigger-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/trigger-tests.yml b/.github/workflows/trigger-tests.yml index fa3a3d865..6338c5400 100644 --- a/.github/workflows/trigger-tests.yml +++ b/.github/workflows/trigger-tests.yml @@ -81,6 +81,7 @@ jobs: -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/${{ vars.INTEGRATION_TESTS_REPO }}/actions/artifacts?name=orion-tests-${{ github.sha }}-${{ github.run_attempt }} \ | jq -r '.artifacts[0].archive_download_url' + ) if [[ "$ARTIFACT_URL" != "null" ]] then # Download artifact From f61b5c5ecb13732dfd0f9f0567fcb3b99196a716 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Sat, 10 Jun 2023 14:06:26 +0200 Subject: [PATCH 13/20] Use pull_request.head.sha for pull requests (instead of github.sha) --- .github/workflows/build-docker-image.yml | 9 ++++++--- .github/workflows/trigger-tests.yml | 7 ++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 4786ad454..f749fcd01 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -2,6 +2,9 @@ name: Build and save docker image on: [push, pull_request] +env: + SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + jobs: build-docker-image: runs-on: ubuntu-latest @@ -10,9 +13,9 @@ jobs: - name: Build Docker image run: make build-docker - name: Save Docker image - run: docker save joystream/orion:latest | gzip > orion-${{ github.sha }}.tar.gz + run: docker save joystream/orion:latest | gzip > orion.tar.gz - name: Upload Docker image uses: actions/upload-artifact@v3 with: - name: joystream-orion-docker - path: orion-${{ github.sha }}.tar.gz + name: joystream-orion-docker-${{ env.SHA }} + path: orion.tar.gz diff --git a/.github/workflows/trigger-tests.yml b/.github/workflows/trigger-tests.yml index 6338c5400..65bd1c3f0 100644 --- a/.github/workflows/trigger-tests.yml +++ b/.github/workflows/trigger-tests.yml @@ -4,6 +4,7 @@ on: [push, pull_request_target] env: INTEGRATION_TESTS_BRANCH: ${{ vars.INTEGRATION_TESTS_BRANCH }} + SHA: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }} jobs: trigger-tests: @@ -21,7 +22,7 @@ jobs: -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/${{ github.repository }}/actions/workflows/build-docker-image.yml/runs?head_sha=${{ github.sha }} \ + https://api.github.com/repos/${{ github.repository }}/actions/workflows/build-docker-image.yml/runs?head_sha=${{ env.SHA }} \ | jq -r '.workflow_runs[0].conclusion' ) echo "build-docker-image workflow conclusion: $CONCLUSION" @@ -66,7 +67,7 @@ jobs: workflow: run-network-tests.yml inputs: > { - "orion_sha": "${{ github.sha }}", + "orion_sha": "${{ env.SHA }}", "attempt": "${{ github.run_attempt }}" } - name: Get tests run result @@ -79,7 +80,7 @@ jobs: -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer ${{ secrets.INTEGRATION_TESTS_TOKEN }}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/${{ vars.INTEGRATION_TESTS_REPO }}/actions/artifacts?name=orion-tests-${{ github.sha }}-${{ github.run_attempt }} \ + https://api.github.com/repos/${{ vars.INTEGRATION_TESTS_REPO }}/actions/artifacts?name=orion-tests-${{ env.SHA }}-${{ github.run_attempt }} \ | jq -r '.artifacts[0].archive_download_url' ) if [[ "$ARTIFACT_URL" != "null" ]] From 6e269d1e53bf2292bf368cbbaf59817f902e5a8c Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Mon, 12 Jun 2023 11:50:14 +0200 Subject: [PATCH 14/20] Fix syntax in trigger-tests comment fetching step --- .github/workflows/trigger-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger-tests.yml b/.github/workflows/trigger-tests.yml index 65bd1c3f0..a3348aefd 100644 --- a/.github/workflows/trigger-tests.yml +++ b/.github/workflows/trigger-tests.yml @@ -54,7 +54,7 @@ jobs: (.author_association = "CONTRIBUTOR") ) | select (.body | test("/set-integration-tests-branch +")) - | .body' + | .body' \ | cut -d ' ' -f 2 ) echo "INTEGRATION_TESTS_BRANCH=$BRANCH" >> $GITHUB_ENV From 65efeefde664152ca4ec9ee27135b533f8e6552f Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Mon, 12 Jun 2023 12:26:54 +0200 Subject: [PATCH 15/20] Add missing "-r" flag to jq --- .github/workflows/trigger-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger-tests.yml b/.github/workflows/trigger-tests.yml index a3348aefd..8249a0dcd 100644 --- a/.github/workflows/trigger-tests.yml +++ b/.github/workflows/trigger-tests.yml @@ -46,7 +46,7 @@ jobs: -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ - | jq ' + | jq -r ' .[] | select( (.author_association = "OWNER") or From e7382dddde3f6ba71295fd971b2bddb79106ad33 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Mon, 12 Jun 2023 12:54:11 +0200 Subject: [PATCH 16/20] Fix handling of integration tests branch selection in case of many valid comments provided --- .github/workflows/trigger-tests.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/trigger-tests.yml b/.github/workflows/trigger-tests.yml index 8249a0dcd..118d6a090 100644 --- a/.github/workflows/trigger-tests.yml +++ b/.github/workflows/trigger-tests.yml @@ -47,14 +47,15 @@ jobs: -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ | jq -r ' - .[] - | select( - (.author_association = "OWNER") or - (.author_association = "MEMBER") or - (.author_association = "CONTRIBUTOR") - ) - | select (.body | test("/set-integration-tests-branch +")) - | .body' \ + [.[] + | select( + (.author_association = "OWNER") or + (.author_association = "MEMBER") or + (.author_association = "CONTRIBUTOR") + ) + | select (.body | test("/set-integration-tests-branch +")) + | .body + ][-1]' \ | cut -d ' ' -f 2 ) echo "INTEGRATION_TESTS_BRANCH=$BRANCH" >> $GITHUB_ENV From 8c7243808c423736bdab34296673dd99303371d8 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Tue, 13 Jun 2023 13:57:45 +0200 Subject: [PATCH 17/20] trigger-tests.yml: Switch to `actions/checkout` approach --- .github/workflows/trigger-tests.yml | 85 +++++++++++++---------------- 1 file changed, 38 insertions(+), 47 deletions(-) diff --git a/.github/workflows/trigger-tests.yml b/.github/workflows/trigger-tests.yml index 118d6a090..01b37a395 100644 --- a/.github/workflows/trigger-tests.yml +++ b/.github/workflows/trigger-tests.yml @@ -37,6 +37,14 @@ jobs: echo "build-docker-image workflow failed" exit 1 fi + - name: Download Orion docker image + uses: dawidd6/action-download-artifact@v2 + with: + commit: ${{ env.SHA }} + name: joystream-orion-docker-${{ env.SHA }} + workflow: build-docker-image.yml + - name: Load Orion docker image + run: docker load -i orion.tar.gz - name: Fetch integration tests branch from PR comment if provided if: github.event_name == 'pull_request_target' run: | @@ -59,54 +67,37 @@ jobs: | cut -d ' ' -f 2 ) echo "INTEGRATION_TESTS_BRANCH=$BRANCH" >> $GITHUB_ENV - - name: Trigger tests - uses: benc-uk/workflow-dispatch@v1 + - name: Check-out the integration tests branch + uses: actions/checkout@v3 with: - token: ${{ secrets.INTEGRATION_TESTS_TOKEN }} - repo: ${{ vars.INTEGRATION_TESTS_REPO }} + repository: ${{ env.INTEGRATION_TESTS_REPO }} ref: ${{ env.INTEGRATION_TESTS_BRANCH }} + - name: Get SHA of the checked-out commit + run: | + SHA=$(git rev-parse HEAD) + echo "INTEGRATION_TESTS_COMMIT=$SHA" >> $GITHUB_ENV + - name: Download Joystream node docker image + uses: dawidd6/action-download-artifact@v2 + with: + github_token: ${{ secrets.INTEGRATION_TESTS_TOKEN }} + commit: ${{ env.INTEGRATION_TESTS_COMMIT }} + name_is_regexp: true + name: '[0-9a-f]+-joystream-node-docker-image.tar.gz' + repo: ${{ vars.INTEGRATION_TESTS_REPO }} workflow: run-network-tests.yml - inputs: > - { - "orion_sha": "${{ env.SHA }}", - "attempt": "${{ github.run_attempt }}" - } - - name: Get tests run result + - name: Load Joystream node docker image run: | - ARTIFACT_URL="null" - while [[ "$ARTIFACT_URL" == "null" ]] - do - ARTIFACT_URL=$( - curl -L \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.INTEGRATION_TESTS_TOKEN }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/${{ vars.INTEGRATION_TESTS_REPO }}/actions/artifacts?name=orion-tests-${{ env.SHA }}-${{ github.run_attempt }} \ - | jq -r '.artifacts[0].archive_download_url' - ) - if [[ "$ARTIFACT_URL" != "null" ]] - then - # Download artifact - curl -L \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.INTEGRATION_TESTS_TOKEN }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - $ARTIFACT_URL \ - -o artifact.zip - # Unzip artifact - unzip artifact.zip - # Get result - RESULT=$(cat result.txt) - if [[ "$RESULT" == "success" ]] - then - echo "Tests passed" - exit 0 - else - echo "Tests failed" - exit 1 - fi - else - echo "Waiting for test results to be uploaded..." - sleep 30 - fi - done + DOCKER_IMAGE_FILE=$(ls | grep joystream-node-docker-image.tar.gz) + JOYSTREAM_RUNTIME_SHA=$(echo $DOCKER_IMAGE_FILE | cut -d '-' -f1) + docker load -i $DOCKER_IMAGE_FILE + echo "JOYSTREAM_RUNTIME_SHA=$JOYSTREAM_RUNTIME_SHA" >> $GITHUB_ENV + - 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=$JOYSTREAM_RUNTIME_SHA + export SKIP_QUERY_NODE_CHECKS=true + ./tests/network-tests/run-tests.sh orion \ No newline at end of file From ac0634403868c9ea319768267dc3eec5edff126c Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Tue, 13 Jun 2023 14:35:22 +0200 Subject: [PATCH 18/20] Fix env.INTEGRATION_TESTS_REPO => vars.INTEGRATION_TESTS_REPO --- .github/workflows/trigger-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger-tests.yml b/.github/workflows/trigger-tests.yml index 01b37a395..15bfc8384 100644 --- a/.github/workflows/trigger-tests.yml +++ b/.github/workflows/trigger-tests.yml @@ -70,7 +70,7 @@ jobs: - name: Check-out the integration tests branch uses: actions/checkout@v3 with: - repository: ${{ env.INTEGRATION_TESTS_REPO }} + repository: ${{ vars.INTEGRATION_TESTS_REPO }} ref: ${{ env.INTEGRATION_TESTS_BRANCH }} - name: Get SHA of the checked-out commit run: | From c596d7ba6819c0ebb820c727a5922484ac035c31 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Tue, 13 Jun 2023 14:50:50 +0200 Subject: [PATCH 19/20] Fix loading Joystream node docker image --- .github/workflows/trigger-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/trigger-tests.yml b/.github/workflows/trigger-tests.yml index 15bfc8384..b55731f08 100644 --- a/.github/workflows/trigger-tests.yml +++ b/.github/workflows/trigger-tests.yml @@ -87,9 +87,9 @@ jobs: workflow: run-network-tests.yml - name: Load Joystream node docker image run: | - DOCKER_IMAGE_FILE=$(ls | grep joystream-node-docker-image.tar.gz) - JOYSTREAM_RUNTIME_SHA=$(echo $DOCKER_IMAGE_FILE | cut -d '-' -f1) - docker load -i $DOCKER_IMAGE_FILE + DOCKER_IMAGE_DIR=$(ls | grep joystream-node-docker-image.tar.gz) + JOYSTREAM_RUNTIME_SHA=$(echo $DOCKER_IMAGE_DIR | cut -d '-' -f1) + docker load -i "$DOCKER_IMAGE_DIR/joystream-node-docker-image.tar.gz" echo "JOYSTREAM_RUNTIME_SHA=$JOYSTREAM_RUNTIME_SHA" >> $GITHUB_ENV - name: Install packages and dependencies run: yarn build:packages From ca610a926f0e9de67bd7bcf1f0aeeaee2eba3ea4 Mon Sep 17 00:00:00 2001 From: Lezek123 Date: Tue, 13 Jun 2023 17:36:51 +0200 Subject: [PATCH 20/20] trigger-tests.yml -> integration-tests.yml rename + run only on push to master branch --- .../{trigger-tests.yml => integration-tests.yml} | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) rename .github/workflows/{trigger-tests.yml => integration-tests.yml} (96%) diff --git a/.github/workflows/trigger-tests.yml b/.github/workflows/integration-tests.yml similarity index 96% rename from .github/workflows/trigger-tests.yml rename to .github/workflows/integration-tests.yml index b55731f08..3ce64a906 100644 --- a/.github/workflows/trigger-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -1,13 +1,17 @@ -name: Trigger external integration tests +name: Run Orion integration tests -on: [push, pull_request_target] +on: + push: + branches: + - 'master' + pull_request_target: env: INTEGRATION_TESTS_BRANCH: ${{ vars.INTEGRATION_TESTS_BRANCH }} SHA: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }} jobs: - trigger-tests: + run-tests: runs-on: ubuntu-latest environment: name: ${{ github.ref_name }} @@ -100,4 +104,4 @@ jobs: run: | export RUNTIME=$JOYSTREAM_RUNTIME_SHA export SKIP_QUERY_NODE_CHECKS=true - ./tests/network-tests/run-tests.sh orion \ No newline at end of file + ./tests/network-tests/run-tests.sh orion