From 2cf5cdbe025b0e3c4948d30cbd467d409fbe551a Mon Sep 17 00:00:00 2001 From: Gaston Bogarin Date: Thu, 3 Nov 2022 15:19:38 -0300 Subject: [PATCH 1/8] Integration testing workflow --- .../integration-tests/createSummary.js | 35 ++++++++++++++++++ .../integration-tests/integration-tests.yml | 37 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/integration-tests/createSummary.js create mode 100644 .github/workflows/integration-tests/integration-tests.yml diff --git a/.github/workflows/integration-tests/createSummary.js b/.github/workflows/integration-tests/createSummary.js new file mode 100644 index 000000000..b44638a50 --- /dev/null +++ b/.github/workflows/integration-tests/createSummary.js @@ -0,0 +1,35 @@ +module.exports = async ({core}, data) => { + + const keys = Object.keys(data); + keys.forEach(async a =>{ + if(a.includes("Summary")){ + const suiteName = a.split("_")[1]; + const browser = a.split("_")[2]; + await convertToArray({core}, data[a], suiteName, browser); + } + }); + + if(data.Reference) + await convertToArray({core}, data.Reference, null, null); + + await core.summary.write(); + } + + async function convertToArray({core}, data, suiteName, browser){ + if(!data) + return; + + data = data.replaceAll('[', ''); + data = data.replaceAll('"', ''); + const array = data.split("],"); + for (i=0;i Date: Thu, 3 Nov 2022 15:33:42 -0300 Subject: [PATCH 2/8] Directories re-arranged --- .../integration-tests => external-testing}/createSummary.js | 0 .github/workflows/{integration-tests => }/integration-tests.yml | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/{workflows/integration-tests => external-testing}/createSummary.js (100%) rename .github/workflows/{integration-tests => }/integration-tests.yml (100%) diff --git a/.github/workflows/integration-tests/createSummary.js b/.github/external-testing/createSummary.js similarity index 100% rename from .github/workflows/integration-tests/createSummary.js rename to .github/external-testing/createSummary.js diff --git a/.github/workflows/integration-tests/integration-tests.yml b/.github/workflows/integration-tests.yml similarity index 100% rename from .github/workflows/integration-tests/integration-tests.yml rename to .github/workflows/integration-tests.yml From b35844a33cf34d429d1abab435b8d31365308ba9 Mon Sep 17 00:00:00 2001 From: Gaston Bogarin Date: Thu, 3 Nov 2022 15:49:22 -0300 Subject: [PATCH 3/8] Route fix --- .github/workflows/integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 5420a02fb..1d5403b66 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -33,5 +33,5 @@ jobs: - uses: actions/github-script@v6.3.3 with: script: | - const createSummary = require('.github/workflows/integration-tests/createSummary.js') + const createSummary = require('.github/external-testing/createSummary.js') await createSummary({core}, ${{toJSON(github.event.client_payload.summary)}}) \ No newline at end of file From 08d25b8fb7df7c0bd2ddb186fbe7914ee333f6ea Mon Sep 17 00:00:00 2001 From: Gaston Bogarin Date: Wed, 9 Nov 2022 12:35:08 -0300 Subject: [PATCH 4/8] Add links to summary --- .github/external-testing/createSummary.js | 75 ++++++++++++++--------- .github/workflows/integration-tests.yml | 4 +- 2 files changed, 48 insertions(+), 31 deletions(-) diff --git a/.github/external-testing/createSummary.js b/.github/external-testing/createSummary.js index b44638a50..d0105e29b 100644 --- a/.github/external-testing/createSummary.js +++ b/.github/external-testing/createSummary.js @@ -1,35 +1,52 @@ module.exports = async ({core}, data) => { + if(data.Reference) + convertToArray({core}, data.Reference, null, null); - const keys = Object.keys(data); - keys.forEach(async a =>{ - if(a.includes("Summary")){ - const suiteName = a.split("_")[1]; - const browser = a.split("_")[2]; - await convertToArray({core}, data[a], suiteName, browser); - } - }); - - if(data.Reference) - await convertToArray({core}, data.Reference, null, null); + let keys = Object.keys(data); + keys.forEach(a =>{ + if(a.includes("Summary")){ + const suiteName = a.split("_")[1]; + const browser = a.split("_")[2]; + convertToArray({core}, data[a], suiteName, browser); + const linkData = a.replaceAll("Summary", "Links"); + addLinks({core}, data[linkData]); + } + }); + + await core.summary.write(); +} + +function addLinks({core}, data){ + console.log(data); + if(!data) + return; + data = data.replaceAll('[', ''); + data = data.replaceAll('"', ''); + const array = data.split("],"); + for (i=0;i Date: Wed, 9 Nov 2022 13:39:03 -0300 Subject: [PATCH 5/8] fix repository url --- .github/workflows/integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 7b73f2b3a..82eaff4c3 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -19,7 +19,7 @@ jobs: curl -X POST https://api.github.com/repos/muxinc/playback-testing/dispatches \ -H 'Accept: application/vnd.github.everest-preview+json' \ -u ${{ secrets.ACCESS_TOKEN }} \ - --data '{"event_type": "Run integration tests", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'", "repositoryUrl": "https://api.github.com/repos/hernanr99/elements/dispatches", "players": "mux", "MUX_CDN_URL":"'${{ github.event.inputs.MUX_CDN_URL }}'" }}' + --data '{"event_type": "Run integration tests", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'", "repositoryUrl": "https://api.github.com/repos/muxinc/elements/dispatches", "players": "mux", "MUX_CDN_URL":"'${{ github.event.inputs.MUX_CDN_URL }}'" }}' echo "Integration tests will be run on a separate repository. Once results are ready, a workflow will be executed that will display the results." - name: Show test results from external repository if: github.event.action == 'Test results from external repository' From 85211be2aa1f6ab6a3457e206d4f03a9330f47da Mon Sep 17 00:00:00 2001 From: Gaston Bogarin Date: Wed, 9 Nov 2022 14:19:00 -0300 Subject: [PATCH 6/8] Mux version placeholder replaced --- .github/workflows/integration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 82eaff4c3..f77aaea60 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: inputs: MUX_CDN_URL: - description: 'Mux Player hosted script' + description: 'Mux Player version' required: false jobs: From c916e579d5ed43811f847fb48f5941f707eb53f2 Mon Sep 17 00:00:00 2001 From: Gaston Bogarin Date: Mon, 5 Dec 2022 17:12:25 -0300 Subject: [PATCH 7/8] Added checkbox to run tests on firefox conditionally --- .github/workflows/integration-tests.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index f77aaea60..635d1f688 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -1,5 +1,4 @@ name: Integration tests - on: repository_dispatch: workflow_dispatch: @@ -7,19 +6,29 @@ on: MUX_CDN_URL: description: 'Mux Player version' required: false - + include_firefox: + type: boolean + description: Include Firefox jobs: trigger-integration-tests: runs-on: ubuntu-latest timeout-minutes: 60 steps: + - name: Get testing drivers + if: github.event.action != 'Test results from external repository' + run: | + if ${{ github.event.inputs.include_firefox }} == true; then + echo "drivers=Chrome,Firefox" >> $GITHUB_ENV + else + echo "drivers=Chrome" >> $GITHUB_ENV + fi - name: Dispatch workflow on external repository if: github.event.action != 'Test results from external repository' run: | curl -X POST https://api.github.com/repos/muxinc/playback-testing/dispatches \ -H 'Accept: application/vnd.github.everest-preview+json' \ -u ${{ secrets.ACCESS_TOKEN }} \ - --data '{"event_type": "Run integration tests", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'", "repositoryUrl": "https://api.github.com/repos/muxinc/elements/dispatches", "players": "mux", "MUX_CDN_URL":"'${{ github.event.inputs.MUX_CDN_URL }}'" }}' + --data '{"event_type": "Run integration tests", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'", "repositoryUrl": "https://api.github.com/repos/muxinc/elements/dispatches", "players": "mux", "drivers": "'${{env.drivers}}'", "MUX_CDN_URL":"'${{ github.event.inputs.MUX_CDN_URL }}'" }}' echo "Integration tests will be run on a separate repository. Once results are ready, a workflow will be executed that will display the results." - name: Show test results from external repository if: github.event.action == 'Test results from external repository' @@ -34,4 +43,4 @@ jobs: with: script: | const createSummary = require('.github/external-testing/createSummary.js') - await createSummary({core}, ${{toJSON(github.event.client_payload.summary)}}) \ No newline at end of file + await createSummary({core}, ${{toJSON(github.event.client_payload.summary)}}) From 8a5f314e5386628664d24c7ffdc2a4c6bb5be9a4 Mon Sep 17 00:00:00 2001 From: ghbogarin <103210250+ghbogarin@users.noreply.github.com> Date: Fri, 10 Mar 2023 13:30:34 -0300 Subject: [PATCH 8/8] Update createSummary.js --- .github/external-testing/createSummary.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/external-testing/createSummary.js b/.github/external-testing/createSummary.js index d0105e29b..c80052289 100644 --- a/.github/external-testing/createSummary.js +++ b/.github/external-testing/createSummary.js @@ -1,7 +1,7 @@ module.exports = async ({core}, data) => { if(data.Reference) convertToArray({core}, data.Reference, null, null); - + let keys = Object.keys(data); keys.forEach(a =>{ if(a.includes("Summary")){ @@ -14,6 +14,9 @@ module.exports = async ({core}, data) => { }); await core.summary.write(); + + if(data.Status != 'success') + core.setFailed(); } function addLinks({core}, data){ @@ -49,4 +52,4 @@ function convertToArray({core}, data, suiteName, browser){ const header = suiteName ? `${browser} - ${suiteName}` : "References"; core.summary.addHeading(header,3).addTable(array); -} \ No newline at end of file +}