Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add integration testing workflow dispatcher #495

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
55 changes: 55 additions & 0 deletions .github/external-testing/createSummary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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")){
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();

if(data.Status != 'success')
core.setFailed();
}

function addLinks({core}, data){
console.log(data);
if(!data)
return;
data = data.replaceAll('[', '');
data = data.replaceAll('"', '');
const array = data.split("],");
for (i=0;i<array.length;i++) {
array[i] = array[i].replaceAll("]]", "");
array[i] = array[i].split(",");
}

for (i=0;i<array.length;i++) {
core.summary.addLink(array[i][0], array[i][1]);
}

}

function convertToArray({core}, data, suiteName, browser){
if(!data)
return;

data = data.replaceAll('[', '');
data = data.replaceAll('"', '');
const array = data.split("],");
for (i=0;i<array.length;i++) {
array[i] = array[i].replaceAll("]]", "");
array[i] = array[i].split(",");
}

const header = suiteName ? `${browser} - ${suiteName}` : "References";

core.summary.addHeading(header,3).addTable(array);
}
46 changes: 46 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Integration tests
on:
repository_dispatch:
workflow_dispatch:
inputs:
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", "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'
run: |
echo -e '${{toJSON(github.event.client_payload.summary)}}'
show-results:
runs-on: ubuntu-latest
if: github.event.action == 'Test results from external repository'
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
script: |
const createSummary = require('.github/external-testing/createSummary.js')
await createSummary({core}, ${{toJSON(github.event.client_payload.summary)}})