Skip to content

Commit

Permalink
Merge tag 'v1.12.10' into mconf-build
Browse files Browse the repository at this point in the history
  • Loading branch information
fcecagno committed Oct 15, 2022
2 parents 7d79b34 + dad7231 commit a4880ee
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 105 deletions.
127 changes: 24 additions & 103 deletions .github/workflows/build-test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
id: meta
uses: docker/metadata-action@v3
with:
images: thecodingmachine/workadventure-front
images: mconf/workadventure-front

- name: Build and push
uses: docker/build-push-action@v3
Expand All @@ -50,8 +50,8 @@ jobs:
file: front/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: thecodingmachine/workadventure-front:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=thecodingmachine/workadventure-front:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
tags: mconf/workadventure-front:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=mconf/workadventure-front:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}

Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
id: meta
uses: docker/metadata-action@v3
with:
images: thecodingmachine/workadventure-chat
images: mconf/workadventure-chat

- name: Build and push
uses: docker/build-push-action@v3
Expand All @@ -111,8 +111,8 @@ jobs:
file: front/chat/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: thecodingmachine/workadventure-chat:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=thecodingmachine/workadventure-chat:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
tags: mconf/workadventure-chat:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=mconf/workadventure-chat:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}

Expand Down Expand Up @@ -162,7 +162,7 @@ jobs:
id: meta
uses: docker/metadata-action@v3
with:
images: thecodingmachine/workadventure-back
images: mconf/workadventure-back

- name: Build and push
uses: docker/build-push-action@v3
Expand All @@ -172,8 +172,8 @@ jobs:
file: back/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: thecodingmachine/workadventure-back:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=thecodingmachine/workadventure-back:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
tags: mconf/workadventure-back:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=mconf/workadventure-back:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}

Expand Down Expand Up @@ -223,7 +223,7 @@ jobs:
id: meta
uses: docker/metadata-action@v3
with:
images: thecodingmachine/workadventure-pusher
images: mconf/workadventure-pusher

- name: Build and push
uses: docker/build-push-action@v3
Expand All @@ -233,8 +233,8 @@ jobs:
file: pusher/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: thecodingmachine/workadventure-pusher:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=thecodingmachine/workadventure-pusher:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
tags: mconf/workadventure-pusher:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=mconf/workadventure-pusher:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}

Expand Down Expand Up @@ -280,16 +280,16 @@ jobs:
id: meta
uses: docker/metadata-action@v3
with:
images: thecodingmachine/workadventure-uploader
images: mconf/workadventure-uploader

- name: Build and push
uses: docker/build-push-action@v3
if: ${{ github.event_name == 'push' || github.event_name == 'release' || github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'deploy') || contains(github.event.pull_request.labels.*.name, 'build')) }}
with:
file: uploader/Dockerfile
push: true
tags: thecodingmachine/workadventure-uploader:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=thecodingmachine/workadventure-uploader:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
tags: mconf/workadventure-uploader:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=mconf/workadventure-uploader:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}

Expand Down Expand Up @@ -336,7 +336,7 @@ jobs:
id: meta
uses: docker/metadata-action@v3
with:
images: thecodingmachine/workadventure-maps
images: mconf/workadventure-maps

- name: Build and push
uses: docker/build-push-action@v3
Expand All @@ -345,8 +345,8 @@ jobs:
context: maps/
file: maps/Dockerfile
push: true
tags: thecodingmachine/workadventure-maps:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=thecodingmachine/workadventure-maps:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
tags: mconf/workadventure-maps:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=mconf/workadventure-maps:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}

Expand Down Expand Up @@ -395,7 +395,7 @@ jobs:
id: meta
uses: docker/metadata-action@v3
with:
images: thecodingmachine/workadventure-map-storage
images: mconf/workadventure-map-storage

- name: Build and push
uses: docker/build-push-action@v3
Expand All @@ -405,8 +405,8 @@ jobs:
file: map-storage/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: thecodingmachine/workadventure-map-storage:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=thecodingmachine/workadventure-map-storage:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
tags: mconf/workadventure-map-storage:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=mconf/workadventure-map-storage:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}

Expand Down Expand Up @@ -456,7 +456,7 @@ jobs:
id: meta
uses: docker/metadata-action@v3
with:
images: thecodingmachine/workadventure-simple-ecs
images: mconf/workadventure-simple-ecs

- name: Build and push
uses: docker/build-push-action@v3
Expand All @@ -465,8 +465,8 @@ jobs:
context: xmpp/
platforms: linux/amd64,linux/arm64
push: true
tags: thecodingmachine/workadventure-simple-ecs:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=thecodingmachine/workadventure-simple-ecs:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
tags: mconf/workadventure-simple-ecs:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-from: type=registry,ref=mconf/workadventure-simple-ecs:${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
cache-to: type=inline
labels: ${{ steps.meta.outputs.labels }}

Expand Down Expand Up @@ -657,82 +657,3 @@ jobs:
path: tests/playwright-report/
retention-days: 30

deeploy:
needs:
- build-front
- build-chat
- build-back
- build-pusher
- build-maps
- build-uploader
- build-map-storage
- build-ejabberd
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy') }}

steps:
- name: Checkout
uses: actions/checkout@v2

# Create a slugified value of the branch
- uses: rlespinasse/[email protected]

- name: Set ADMIN_URL if "deploy-connect-to-admin" label is set
run: echo "ADMIN_API_URL=https://${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}.test.workadventu.re" >> $GITHUB_ENV
if: ${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy-connect-to-admin')) || env.GITHUB_REF_SLUG == 'develop' }}

- name: Write certificate
run: echo "${CERTS_PRIVATE_KEY}" > secret.key && chmod 0600 secret.key
env:
CERTS_PRIVATE_KEY: ${{ secrets.CERTS_PRIVATE_KEY }}

- name: Download certificate
run: mkdir secrets && scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i secret.key [email protected]:./config/live/workadventu.re/* secrets/

- name: Create namespace
uses: steebchen/[email protected]
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_FILE_BASE64 }}
with:
args: create namespace workadventure-${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
continue-on-error: true

- name: Delete old certificates in namespace
uses: steebchen/[email protected]
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_FILE_BASE64 }}
with:
args: -n workadventure-${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }} delete secret certificate-tls
continue-on-error: true

- name: Install certificates in namespace
uses: steebchen/[email protected]
env:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_FILE_BASE64 }}
with:
args: -n workadventure-${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }} create secret tls certificate-tls --key="secrets/privkey.pem" --cert="secrets/fullchain.pem"

- name: Deploy
uses: thecodingmachine/deeployer-action@master
env:
KUBE_CONFIG_FILE: ${{ secrets.KUBE_CONFIG_FILE }}
ADMIN_API_TOKEN: ${{ secrets.ADMIN_API_TOKEN }}
ADMIN_SOCKETS_TOKEN: ${{ secrets.ADMIN_SOCKETS_TOKEN }}
JITSI_ISS: ${{ secrets.JITSI_ISS }}
JITSI_URL: ${{ secrets.JITSI_URL }}
SECRET_JITSI_KEY: ${{ secrets.SECRET_JITSI_KEY }}
TURN_STATIC_AUTH_SECRET: ${{ secrets.TURN_STATIC_AUTH_SECRET }}
DEPLOY_REF: ${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
POSTHOG_URL: ${{ secrets.POSTHOG_URL }}
EJABBERD_JWT_SECRET: ${{ secrets.EJABBERD_JWT_SECRET }}
with:
namespace: workadventure-${{ github.event_name == 'pull_request' && env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}

- name: Add a comment in PR
uses: unsplash/comment-on-pr@master
if: ${{ github.event_name == 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: "Environment deployed at https://play-${{ env.GITHUB_HEAD_REF_SLUG }}.test.workadventu.re \nTests available at https://maps-${{ env.GITHUB_HEAD_REF_SLUG }}.test.workadventu.re/tests"
2 changes: 2 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ services:
ENABLE_OPENID: "$OPID_CLIENT_ID"
OPID_PROFILE_SCREEN_PROVIDER: "$OPID_PROFILE_SCREEN_PROVIDER"
CHAT_URL: //chat.workadventure.localhost
PEER_VIDEO_MAX_BANDWIDTH_KBITS_PS: "$PEER_VIDEO_MAX_BANDWIDTH_KBITS_PS"
PEER_SCREENSHARE_MAX_BANDWIDTH_KBITS_PS: "$PEER_SCREENSHARE_MAX_BANDWIDTH_KBITS_PS"
command: yarn run start
volumes:
- ./front:/usr/src/app
Expand Down
41 changes: 41 additions & 0 deletions front/src/Components/Video/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,44 @@ export function getIceServersConfig(user: UserSimplePeerInterface): RTCIceServer
}
return config;
}

export function getSdpTransform(videoBandwidth = 0) {
return (sdp: string) => {
sdp = updateBandwidthRestriction(sdp, videoBandwidth, "video");

return sdp;
};
}

function updateBandwidthRestriction(sdp: string, bandwidth: integer, mediaType: string): string {
if (bandwidth <= 0) {
return sdp;
}

for (
let targetMediaPos = sdp.indexOf(`m=${mediaType}`);
targetMediaPos !== -1;
targetMediaPos = sdp.indexOf(`m=${mediaType}`, targetMediaPos + 1)
) {
// offer TIAS and AS (in this order)
for (const modifier of ["AS", "TIAS"]) {
const nextMediaPos = sdp.indexOf(`m=`, targetMediaPos + 1);
const newBandwidth = modifier === "TIAS" ? (bandwidth >>> 0) * 1000 : bandwidth;
const nextBWPos = sdp.indexOf(`b=${modifier}:`, targetMediaPos + 1);

let mediaSlice = sdp.slice(targetMediaPos);
const bwFieldAlreadyExists = nextBWPos !== -1 && (nextBWPos < nextMediaPos || nextMediaPos === -1);
if (bwFieldAlreadyExists) {
// delete it
mediaSlice = mediaSlice.replace(new RegExp(`b=${modifier}:.*[\r?\n]`), "");
}
// insert b= after c= line.
mediaSlice = mediaSlice.replace(/c=IN (.*)(\r?\n)/, `c=IN $1$2b=${modifier}:${newBandwidth}$2`);

// update the sdp
sdp = sdp.slice(0, targetMediaPos) + mediaSlice;
}
}

return sdp;
}
6 changes: 6 additions & 0 deletions front/src/Enum/EnvironmentVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export const OPID_PROFILE_SCREEN_PROVIDER =
getEnvConfig("OPID_PROFILE_SCREEN_PROVIDER") || (ADMIN_URL ? ADMIN_URL + "/profile" : undefined);
const FALLBACK_LOCALE = getEnvConfig("FALLBACK_LOCALE") || undefined;
export const CHAT_URL = getEnvConfig("CHAT_URL") || "//chat.workadventure.localhost";
const PEER_VIDEO_MAX_BANDWIDTH_KBITS_PS = parseInt(getEnvConfig("PEER_VIDEO_MAX_BANDWIDTH_KBITS_PS") || "0");
const PEER_SCREENSHARE_MAX_BANDWIDTH_KBITS_PS = parseInt(
getEnvConfig("PEER_SCREENSHARE_MAX_BANDWIDTH_KBITS_PS") || "0"
);

export {
DEBUG_MODE,
Expand All @@ -48,4 +52,6 @@ export {
JITSI_PRIVATE_MODE,
ENABLE_FEATURE_MAP_EDITOR,
FALLBACK_LOCALE,
PEER_VIDEO_MAX_BANDWIDTH_KBITS_PS,
PEER_SCREENSHARE_MAX_BANDWIDTH_KBITS_PS,
};
4 changes: 3 additions & 1 deletion front/src/WebRtc/ScreenSharingPeer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import type { RoomConnection } from "../Connexion/RoomConnection";
import { MESSAGE_TYPE_CONSTRAINT, PeerStatus } from "./VideoPeer";
import type { UserSimplePeerInterface } from "./SimplePeer";
import { Readable, readable, writable, Writable } from "svelte/store";
import { getIceServersConfig } from "../Components/Video/utils";
import { getIceServersConfig, getSdpTransform } from "../Components/Video/utils";
import { highlightedEmbedScreen } from "../Stores/EmbedScreensStore";
import { isMediaBreakpointUp } from "../Utils/BreakpointsUtils";
import Peer from "simple-peer/simplepeer.min.js";
import { Buffer } from "buffer";
import { PEER_SCREENSHARE_MAX_BANDWIDTH_KBITS_PS } from "../Enum/EnvironmentVariable";

/**
* A peer connection used to transmit video / audio signals between 2 peers.
Expand Down Expand Up @@ -35,6 +36,7 @@ export class ScreenSharingPeer extends Peer {
config: {
iceServers: getIceServersConfig(user),
},
sdpTransform: getSdpTransform(PEER_SCREENSHARE_MAX_BANDWIDTH_KBITS_PS),
});

this.userId = user.userId;
Expand Down
4 changes: 3 additions & 1 deletion front/src/WebRtc/VideoPeer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import {
newChatMessageWritingStatusSubject,
writingStatusMessageStore,
} from "../Stores/ChatStore";
import { getIceServersConfig } from "../Components/Video/utils";
import { getIceServersConfig, getSdpTransform } from "../Components/Video/utils";
import { isMediaBreakpointUp } from "../Utils/BreakpointsUtils";
import { SoundMeter } from "../Phaser/Components/SoundMeter";
import Peer from "simple-peer/simplepeer.min.js";
import { Buffer } from "buffer";
import { gameManager } from "../Phaser/Game/GameManager";
import { PEER_VIDEO_MAX_BANDWIDTH_KBITS_PS } from "../Enum/EnvironmentVariable";

export type PeerStatus = "connecting" | "connected" | "error" | "closed";

Expand Down Expand Up @@ -60,6 +61,7 @@ export class VideoPeer extends Peer {
config: {
iceServers: getIceServersConfig(user),
},
sdpTransform: getSdpTransform(PEER_VIDEO_MAX_BANDWIDTH_KBITS_PS),
});

this.userId = user.userId;
Expand Down
Loading

0 comments on commit a4880ee

Please sign in to comment.