Merge branch 'master' of github.com:sipsorcery/webrtc-echoes #139
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: WebRTC Data Channel Interoperability Test | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
repository_dispatch: | |
types: [datachannel-test-command] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
# Job Description: Performs the Data Channel Test between each combination of the client and server for each library. | |
interoptests: | |
runs-on: ubuntu-latest | |
services: | |
echo-test-server: | |
image: ghcr.io/sipsorcery/${{ matrix.server }}-webrtc-echo | |
credentials: | |
username: ${{ github.actor }} | |
password: ${{ secrets.CR_PAT }} | |
#ports: | |
# - 8080:8080 | |
options: "--name echo-server" | |
outputs: | |
result_libdatachannel_libdatachannel: ${{ steps.set-output.outputs.result_libdatachannel_libdatachannel }} | |
result_libdatachannel_sipsorcery: ${{ steps.set-output.outputs.result_libdatachannel_sipsorcery }} | |
result_libdatachannel_werift: ${{ steps.set-output.outputs.result_libdatachannel_werift }} | |
result_sipsorcery_libdatachannel: ${{ steps.set-output.outputs.result_sipsorcery_libdatachannel }} | |
result_sipsorcery_sipsorcery: ${{ steps.set-output.outputs.result_sipsorcery_sipsorcery }} | |
result_sipsorcery_werift: ${{ steps.set-output.outputs.result_sipsorcery_werift }} | |
result_werift_libdatachannel: ${{ steps.set-output.outputs.result_werift_libdatachannel }} | |
result_werift_sipsorcery: ${{ steps.set-output.outputs.result_werift_sipsorcery }} | |
result_werift_werift: ${{ steps.set-output.outputs.result_werift_werift }} | |
strategy: | |
matrix: | |
server: ["libdatachannel", "sipsorcery", "werift"] | |
client: ["libdatachannel", "sipsorcery", "werift"] | |
steps: | |
- name: Data Channel test for server ${{ matrix.server }} and ${{ matrix.client }} client | |
id: check_connection | |
run: | | |
docker run --entrypoint "/client.sh" --network ${{ job.container.network }} ghcr.io/sipsorcery/${{ matrix.client }}-webrtc-echo "-s http://echo-server:8080/offer -t 1" | |
result=$? | |
echo "Check connection for ${{ matrix.server }} server and ${{ matrix.client }} client result $result." | |
echo "::set-output name=TEST_RESULT::$result" | |
continue-on-error: true | |
- name: Set output results | |
id: set-output | |
run: | | |
echo "result_${{ matrix.server }}_${{ matrix.client }}=${{ steps.check_connection.outputs.TEST_RESULT }}" >> "$GITHUB_OUTPUT" | |
# Job Description: Collates the results of the interop tests into a mark down table. | |
collate: | |
runs-on: ubuntu-latest | |
needs: [interoptests] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Create results file from interop test outputs | |
run: | | |
echo "Collating...." | |
# Capture the outputs as a JSON string | |
results='${{ toJSON(needs.interoptests.outputs) }}' | |
# Print the raw JSON for debugging | |
echo "The output from interop-test is: $results" | |
# Define the list of clients | |
clients=("libdatachannel", "sipsorcery", "werift") # Adjust based on actual client list | |
# Write the header of the Markdown file | |
echo "| Server | ${clients[@]} |" > DataChannel_Echo_test_results.md | |
echo "|--------|${clients[*]// /|}|" >> DataChannel_Echo_test_results.md | |
# Loop through servers to fill in the matrix | |
for server in $(echo "$results" | jq -r 'keys[] | capture("result_(?<server>.+)_(?<client>.+)") | .server' | sort -u); do | |
# Start the row with the server name | |
row="$server" | |
# Loop through each client to get the results | |
for client in "${clients[@]}"; do | |
# Get the result for this server-client combination | |
value=$(echo "$results" | jq -r --arg server "$server" --arg client "$client" '.["result_\($server)_\($client)"] // "N/A"') # Default to N/A if no value | |
# Append the value to the row | |
row+=" | $value" | |
done | |
# Write the row to the Markdown file | |
echo "| $row |" >> DataChannel_Echo_test_results.md | |
done | |
echo "" >> DataChannel_Echo_test_results.md | |
echo "Timestamp: $(date)" >> DataChannel_Echo_test_results.md | |
# Display the results file | |
cat DataChannel_Echo_test_results.md | |
- name: Commit the results to the git repository | |
if: github.event_name != 'pull_request' | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git pull | |
git add DataChannel_Echo_test_results.md | |
git commit DataChannel_Echo_test_results.md -m "Automated data channel echo test results." | |
git push |